Performance of WebView in JavaFX
Asked Answered
I

5

36

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:

  1. Can anybody second my experience? Am I simply doing something wrong or is this caused by JavaFX and thus "normal"?

  2. 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). 

Imbecility answered 26/5, 2012 at 1:29 Comment(9)
Can you provide a link to the content you are testing?Etherify
What is your system hardware/software configuration?Etherify
The sample code post you referenced mixes Swing and JavaFX. Try accessing the same pages using a pure JavaFX app.Etherify
I have also done exactly that and the performance impact was ridiculous.Minsk
I tried the embedded Swing version and a pure JavaFX version and performance perceptions and benchmarks for both versions were exactly the same for me.Etherify
thanks for the elaborate testing! Unfortunately I cannot share my code (yet), but for some (odd) reason I have trouble getting it to run in the pure JavaFX version for comparison. I will post a link here as soon as we have gone live.Imbecility
Also note an open WebView performance Jira which indicates that sometimes a Swing JFXPanel embedded WebView may have worse performance than a pure JavaFX version - this should be addressed in a future release.Etherify
I have tried making a pure JavaFX version and its damn slow. My code where a minimal test in order to try out the WebEngine. Visiting some standard site like this CPU consumption grew a lot. When I visited YouTube yeah it worked but that's it. It played videos so slow that finally I killed the process.Headless
Have you solved the problem with perfomance? What is OS you tested the application on? Is it virtual machine? I had same problems but only on win 7 (on linux everything is ok). #30654432Lalonde
E
46

I have used WebView quite a bit and usually the performance was perfectly fine and very usable.

  • Html5 compliance is good.
  • JavaScript performance varies but I found it about one third the speed of a recent version of Chrome according to Google's V8 benchmark (which Chrome is presumably tuned against).
  • Rendering performance didn't seem to be much of an issue.
  • Very intensive HTML Webapps such as some in the Chrome experiment library did not start up as quick as in some other browsers.
  • WebGL is not supported so sites which fall back to software rendering of graphics from WebGL are much slower.

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):

Chrome 19      402 + 13 bonus points
Firefox 12     345 +  9 bonus points
WebView 2.2b9  296 +  7 bonus points 
IE 9.0.6       138 +  5 bonus points

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):

IE 9.0.6       146.7ms 
Chrome 19      151.5ms
Firefox 12     185.8ms
WebView 2.2b9  199.5ms 

Google V8 Javascript benchmark (higher is better):

Chrome 19      15323
Firefox 12     9557
WebView 2.2b9  5145
IE 9.0.6       3661

Mozilla Kraken Javascript benchmark (lower is better):

Chrome 19      2416.8ms
Firefox 12     2112.9ms
WebView 2.2b9  7988.9ms
IE 9.0.6       9403.0ms

Intensive Canvas

Spinning 3D buddha (higher is better):

Chrome 19      60fps
Firefox 12     43fps
IE 9.0.6       16fps
WebView 2.2b9  7fps

JQuery

JQuery test suite execution (lower is better):

Chrome 19      21826ms
WebView 2.2b9  22742ms
Firefox 12     23554ms
IE 9.0.6       28247ms

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.

Etherify answered 26/5, 2012 at 2:56 Comment(9)
any update on whether the JIT compiler situation is the same, or has improved?Obryant
No update from me at this time. If you have a Windows machine, you could try running some benchmarks to test the performance of recent versions of WebView running in 32bit vs 64bit JVMs.Etherify
I'm not sure why, but the rendering quality is a lot lower than either chrome or firefox on my system(linux64/ubuntu) Is there anything I can do to fix this?Pelayo
@thouliha rendering quality is an unrelated question to the performance question. Please ask you rendering quality question as a new question, thanks.Etherify
the performance is bad under linux and especially bad under mac. However on Windows it is okeish.Seamanship
@JOKe I believe that objective, quantified benchmark results may be more useful than subjective analysis. You may wish to create your own answer with your results.Etherify
forget the benchmarks.. open www.oracle.com with WebView and enjoy... it even doesnt render sometimes... it is a TRUE that oracle site is one of the few with really BIG performance issues but it is noticable !Seamanship
I can't replicate slowness or issues rendering www.oracle.com (OS X 10.9.5, MacBook Pro, Java 8u72). If you have issues with a specific configuration, I advise you to log a bug report at bugreport.java.comEtherify
I was with 8u20 will try with 72... good it is just me :) if it is not a common issue its not that important.Seamanship
M
8

JavaScript JIT is switched off in WebNode for Windows x64. That could be a reason of your problem.

Matrilateral answered 25/7, 2012 at 12:25 Comment(3)
interesting. Any way to switch it on manually / programmatically?Imbecility
The switch to enable/disable JavaScript JIT is either an internal flag or in internal code, there is no publicly supported way for an external user to control this setting. AFAIK, the JavaScript JIT was only switched off for some developer preview versions of Java, but is switched on for all release versions. For the above benchmarks I believe the JavaScript JIT was switched on.Etherify
is this still the case?Obryant
F
6

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).

Fought answered 18/6, 2015 at 15:45 Comment(3)
Is JxBrowser free or paid tool? if paid is there other free alternatives? and thanks.Dyandyana
JxBrowser is free for open-source and academic projects: teamdev.com/jxbrowser#evaluateDempstor
NOT TRUE its paid. You can try it only for 30 daysOnondaga
B
5

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

Brabant answered 4/4, 2014 at 12:9 Comment(1)
There is news ! Check the javafx jira ! :) @ImbecilityBrabant
C
4

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.

Courtyard answered 29/7, 2013 at 7:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.