0

This code replicates the problem I am having with some web sites. You will notice that the entire page is not shown. Yet a few days ago everything was working perfectly. I would like to understand what is happening. I am no longer able to see some videos, especially those from vimeo.

public class WebViewEx extends Application {

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

public void start(Stage primaryStage) {
    primaryStage.setTitle("JavaFX WebView");

    WebView webView = new WebView();

    webView.getEngine().load("https://vimeo.com/761107839");

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

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

}
}
iose
  • 47
  • 6
  • Please provide info on the JavaFX/JDK versions you are using. Try the most recent versions of each, in case it is some issue which was fixed in later versions. I am guessing you aren't using jlink, but if you were (and even if not) it is probably a good idea to `requires jdk.crypto.cryptoki;` in your module-info.java to allow [https from webview for some sites](https://stackoverflow.com/questions/60081037/modular-java-13-javafx-webwiew-fails-to-display-when-jlinked). – jewelsea Nov 06 '22 at 10:36
  • I tried it in JDK 19.01, JavaFX 19 on Windows 11. It failed to play the video at your link in WebView (worked in Edge). Enabling [console logging](https://stackoverflow.com/questions/57167872/webconsolelistener-illegalaccesserror-in-javafx-12) output "[GSI_LOGGER]: The browser is not supported.[at 44]". Calling `webView.getEngine().setUserAgent` to set the user agent to a recent Chrome version got rid of the unsupported browser message, but the video still didn't play. I guess the WebView browser in JavaFX 19 is not supported by the site. You could contact the site and ask them to fix it – jewelsea Nov 06 '22 at 11:07
  • jewelsea I suppose they are using other sturments to identify the browser. By setting different user agents, even going so far as to set it as if it were a cell phone browser, the website doesn't work. One peculiarity I have noticed is the cokies. In javaFx the disclaimer does not appear. Probably the site appears only after accepting them. However doing a test with a normal browser, even though you delete the cokies, the site still recognizes you because it doesn't ask you to accept them the next times. I also tried it with Tor! – iose Nov 07 '22 at 02:06
  • No. The issue is not about browser identification. If you set the user agent string to a well-known browser like Chrome, the vimeo website thinks it is a compatible browser and tries to play the video using whatever technology the site is using. But whatever technology that is. it is not compatible with WebView in JavaFX 19. Cookie handling may be a completely different, unrelated issue, IMO. Perhaps it is looking for a [persistent rather than in-memory cookie](https://stackoverflow.com/questions/14385233/setting-a-cookie-using-javafxs-webengine-webview), I didn't investigate it. – jewelsea Nov 07 '22 at 10:54
  • ok but how do they know that we are connecting through javaFx? If you set the user agent of a browser I expect the content to display. Yet the server is not responding. If you get the error "browser not supported," even though you set the user agent, it means that they are somehow tracking you and they understand that you are using javafx. So how do they do that? By understanding that, you could make the server think that you are connecting directly from a common browser. – iose Nov 08 '22 at 00:20
  • Please reread my comments. If you set the user agent to a common browser it does not output that the browser is not supported. The website does not know or care that the client is JavaFX. A website can track through cookies or authenticate identity and credentials to authorize access, then run different logic based on that. But likely none of that is the fundamental issue. Each http client implementation has a different feature set. Likely the website is using some features not supported by a JavaFX WebView client, what they are, I do not know. – jewelsea Nov 08 '22 at 01:41
  • Yes, sorry I had misunderstood! Anyway the same problem occurs on a site hosted in cloudflare. Do you know of any alternatives to JavaFx? – iose Nov 08 '22 at 04:13
  • Call [showDocument](https://openjfx.io/javadoc/19/javafx.graphics/javafx/application/HostServices.html#showDocument(java.lang.String)). There are alternatives if you search and are willing to pay. You know your app requirements best, so can best search for other tech that may meet your requirements. – jewelsea Nov 08 '22 at 04:19

0 Answers0