Problem:
The ability to call back to Java from JavaScript breaks after loading a page
the 2nd time. The callback only survives the 1st page load.
Platform:
The bug applies to both Java 8u112 Mac + Windows
Java Version:
Current Java 9 early edition. It may exist in earlier editions too.
How to reproduce:
1) Create and install a WebView component in a UI
2) Install a Javascript-to-java callback in accordance with
https://docs.oracle.com/javase/8/javafx/api/javafx/scene/web/WebEngine.html
3) Load a page that triggers the javascript-to-java callback
4) Test the page. Should work
5) Now reload the page
6) The callback mechanism is now broken (nothing happens). Trying to
reinstall it in the StateProperty callback doesn��t help either.
Workaround:
Create another WebView+WebEngine instance and set up the callback mechanism
once again. However, this causes other problems: On Mac one sometimes get
complaints about lock files in the file system:
javafx.scene.web.DirectoryLock$DirectoryAlreadyInUseException:
/Users/david/Library/Application Support/Java/webview
at javafx.scene.web.DirectoryLock.<init>(DirectoryLock.java:61)
at javafx.scene.web.WebEngine.applyUserDataDirectory(WebEngine.java:1060)
at javafx.scene.web.WebEngine.load(WebEngine.java:929)
at net.jalbum.browser.WebViewBrowser.lambda$load$7(WebViewBrowser.java:185)
at
com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at
com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:
294)
at
com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)