elm / virtual-dom

The foundation of HTML and SVG in Elm.
https://package.elm-lang.org/packages/elm/virtual-dom/latest
BSD 3-Clause "New" or "Revised" License
209 stars 80 forks source link

Elm program stops working in JavaFX WebView #61

Closed TheoLassonder closed 7 years ago

TheoLassonder commented 7 years ago

I'm wanting to write an 0.18.0 Elm program and run it in a JavaFX WebView. When trying the first example from the Elm Architecture Tutorial (01-button.elm), the HTML is drawn correctly, but then when I hit e.g. the "+" button nothing happens (it's meant to update the counter). By adding Debug.log statements, I can see after hitting the button that update runs, but not the subsequent view.

I've tried running the latest version of Java 8 (1.8.0_112), as well as a few older versions all the way back to 1.8.0_51. They all exhibit the same behaviour. No errors are reported by the WebView or it's associated WebEngine.

The HTML file as produced by elm-make works just fine in all major browsers, as you'd expect. I've tried to look for which browser versions are supported by Elm, but can't find that information. WebView is based on WebKit (in Java 1.8.0_122 it's WebKit 602.1) - is it supported in Elm?

The below creates the test case in JavaFX:

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

public class WebViewPane extends Application {

    @Override
    public void start(Stage primaryStage) {
        StackPane root = new StackPane();
        WebView webView = new WebView();
        WebEngine webEngine = webView.getEngine();
        webEngine.load("http://localhost:5000/01-button.html");
        root.getChildren().add(webView);
        Scene scene = new Scene(root);
        primaryStage.setTitle("WebView");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }

}

Thanks!

process-bot commented 7 years ago

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

witoldsz commented 7 years ago

I was trying to debug it and I have failed as JavaFX's WebView is really terrible to figure out what's going on. My guess: this is the same issue as #55 which crashes on older browsers like IE < 10, Chrome 18 (and maybe some newer) or Android 4.1 (and maybe some newer) stock browsers. I would be really surprised if #55 would not apply here.

TheoLassonder commented 7 years ago

I can confirm that the work around mentioned in https://github.com/elm-lang/virtual-dom/issues/55#issuecomment-268914836 fixes this issue also.

evancz commented 7 years ago

In that #55 was resolved, I expect this was resolved as well.