I have a JavaFX application that incorporates OpenLayers into its WebView. I have a simple popup that displays the name of a feature when you move the mouse over it. Problem that I'm facing is that whatever is going on inside WebView is highly inaccurate. For example when a popup is triggered it does not disappear immediately after mouse moves away from the feature. I've prepared a small gist that highlights this issue here. I am using this code inside JavaFX for WebView:
private void initialize() {
WebView view = new WebView();
webEngine = view.getEngine();
URL urlOpenLayers = getClass().getResource("/html/trainmap.html");
webEngine.setJavaScriptEnabled(true);
webEngine.load(urlOpenOpenLayers.toExternalForm());
}
I posted this here instead of GIS StackExchange because this appears to be a JavaFX WebView problem rather than an issue with OpenLayers. Same code works as intended in Chrome.
This is my WebView version when I call view.getEngine().getUserAgent()
: Mozilla/5.0 (Linux x86_64) AppleWebKit/602.1 (KHTML, like Gecko) JavaFX/8.0 Safari/602.1
It appears that WebView is using Java Graphics 2D API for rendering web pages. After running some tests it becomes clear that this component of JavaFX hasn't been updated for years and thus cannot work with a lot of modern web content, like OpenLayers.
One solution I've come across is switching to JxBrowser, which is instead running on Chromium. It should be noted that JxBrowser is not free to use, but it does have a 30-day trial.