0

I've just tried to run a rudimentary example using OpenJFX 16 that is intended to open a webpage of a WebGL demo showing some blobs:

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

public class Main extends Application {

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

    @Override
    public void start(final Stage primaryStage) {
        primaryStage.setTitle("JavaFX WebView Example");

        WebView webView = new WebView();

        webView.getEngine().load("https://webglsamples.org/blob/blob.html");

        VBox vBox = new VBox(webView);
        Scene scene = new Scene(vBox, 960, 600);

        primaryStage.setScene(scene);
        primaryStage.show();
    }
}

However, I get the following error message:

This page requires a browser that supports WebGL. Click here to upgrade your browser.

I use Adoptium OpenJDK 16 under Mageia Linux. Is it the expected behaviour? I'm disappointed because a member of Gluon's support team told me:

there are some WebGL demos that run just fine in the WebView component

What can I do to solve this problem? Is it expected to work only with OpenJFX 17?

Edit.: Someone else tried with OpenJFX 18, it still doesn't work: https://jvm-gaming.org/t/openjfx-javafx-webview-not-working-with-webgl/70495/2

gouessej
  • 3,640
  • 3
  • 33
  • 67

1 Answers1

1

JavaFXs WebView does not support WebGL and I am not aware of any plans to change that. Who told you that there are working demos for that and where can they be found? There have only been some experiments to resolve this issue but no official solution yet. E.g., https://github.com/miho/NativeFX

mipa
  • 10,369
  • 2
  • 16
  • 35
  • It's mentioned here by Gluon itself: https://gluonhq.com/gluon-and-javafx-status-update/ https://www.youtube.com/watch?v=LoL30W0yo6g – gouessej Aug 21 '21 at 09:52
  • I suspect bck2brwsr is used to transpile Java to Javascript. – gouessej Aug 21 '21 at 09:55
  • What has bck2brwsr to do with WebView and WebGL? – mipa Aug 21 '21 at 16:02
  • I think you just misunderstood the statements in the above video. The prototype for running JavaFX in a browser is based on WebGL. This has nothing to do with WebGL inside the WebView of JavaFX. – mipa Aug 21 '21 at 16:11
  • I already know what you wrote and it's public, the source code is here: https://github.com/gluonhq/uongl/tree/master/src/main/java/com/gluonhq/webscheduler However, when I sent an email to Gluon's support team to ask whether WebGL is supported inside OpenJFX WebView, the recipient answered "there are some WebGL demos that run just fine in the WebView component". I think that you misread my question, I'm just repeating what I already wrote. The reply from Gluon's support talks about existing WebGL support in WebView, that's why I expected to get something working. – gouessej Aug 21 '21 at 22:03
  • Gluon's CTO contributes to bck2brwsr: https://github.com/johanvos/bck2brwsr/commit/0cbf6240e2536cd53e5afdd9ed71a7773ab0a91f Moreover, a sub-project already allows to run JavaFX in a web browser without any Java plugin: "We also managed to port JavaFX to Bck2Brwsr and here is a proof of that" http://wiki.apidesign.org/wiki/Bck2Brwsr http://xelfi.cz/fishsim/ – gouessej Aug 21 '21 at 22:10
  • "Thanks to Johan Vos, who managed to compile JavaFX with Bck2Brwsr transpiler and reported quite a few bugs" http://wiki.apidesign.org/wiki/Bck2Brwsr_0.50 – gouessej Aug 21 '21 at 22:12
  • Once again, I know about the work for bck2brwsr but it has nothing to do with JavaFXs WebView. – mipa Aug 21 '21 at 22:35
  • Yes, you're right but a member of Gluon's support team claimed that WebGL is already supported in WebView, that's why I expected it to work. – gouessej Aug 22 '21 at 08:11
  • I've just accepted your answer because WebGL in WebView doesn't even work in OpenJFX 18. You're totally right. I'll probably use Bck2Brwsr by myself and I'll remove OpenJFX from the equation. – gouessej Aug 22 '21 at 08:24
  • The final words are there: https://mail.openjdk.java.net/pipermail/openjfx-dev/2021-August/031736.html There won't be any WebGL support in WebView. – gouessej Aug 28 '21 at 09:10