I have a HTML5 UI and a Java backend and want to avoid rebuilding the HTML ui in plain java, so my idea was to run a local webserver and use a webview to render it in a "native" window. The solution seems to be to use a JavaFX WebView which can be embedded in swing. On the paper it sounds great (especially since they claim to use WebKit which has a significantly better performance for my UI in Chrome / Safari).
It works, but: the performance is INCREDIBLY BAD. Orders of magnitude slower than the same thing in Chrome, Safari (or even the slower Firefox). It is literally unusable (my UI makes quite heavy use of JQuery / JS). Btw, I am using the code from this post.
The question is:
Can anybody second my experience? Am I simply doing something wrong or is this caused by JavaFX and thus "normal"?
Any better idea how to achieve this? I am currently simply firing up the system browser which works but is not as nice (does not look as integrated).
I have used WebView quite a bit and usually the performance was perfectly fine and very usable.
The biggest issue I had with WebView is that it is not quite as stable for cutting edge features and intensive use as other browsers, but not really any serious performance issues.
Here are a few benchmark stats (WebView version used was sourced from JavaFX 2.2 build 9):
Compliance
Running a html5 test to test html5 compliance (scores out of 500):
Running an acid3 test, webview scores 100/100 same as the other test browsers, but, like IE9, the final rendering has a slight imperfection.
Javascript
Sunspider Javascript benchmark (lower is better):
Google V8 Javascript benchmark (higher is better):
Mozilla Kraken Javascript benchmark (lower is better):
Intensive Canvas
Spinning 3D buddha (higher is better):
JQuery
JQuery test suite execution (lower is better):
Based on the above benchmarks (run on my Windows 7 desktop), as long as WebView is stable and functional enough for you, then performance of WebView vs other browsers should not be an issue (as long as your app does not feature a lot of 3D spinning buddhas . . . :-).
Update
As uta's answer states, the JavaScript JIT compiler is switched on for the Win 32 bit build of JavaFX 2.2 and off for the Win 64 bit build of JavaFX 2.2. This means that WebView JavaScript benchmarks are significantly slower (typically 4 to 5 times slower) when running the 64 bit JavaFX version vs the 32 bit JavaFX version.
I also encountered JavaFX WebView poor performance (slowness, repaint issues) for my website (https://mdemo.cqg.com). After some googling I came across the topic Integrating JavaFX 2.0 WebView into a Swing Java SE 6 Application. Among the answers there is a proposal to use JxBrowser (http://www.teamdev.com/jxbrowser) -- Chromium-based Swing/JavaFX component for Java. I tried it for my site. Site performed well -- no slowness nor repaint issues (that happen in original WebView).
You are not alone in this situation. I still have problem with the webview and google maps. You can see the link below. For the moment I do not have any answer for you and it's very unpleasant I know ...
Some examples of my post : - https://community.oracle.com/message/12356161
Upvote this if you can : - https://javafx-jira.kenai.com/browse/RT-33217
One reason that JavaFX webView appears to be slower is because unlike a web browser it does not cache anything. This has to be inplemented.
JavaScript JIT is switched off in WebNode for Windows x64. That could be a reason of your problem.