JavaFX中WebView的性能 [英] Performance of WebView in JavaFX

查看:892
本文介绍了JavaFX中WebView的性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个HTML5用户界面和一个Java后端,并希望避免在普通的java中重建HTML ui,所以我的想法是运行本地网络服务器并使用webview在本机窗口中呈现它。解决方案似乎是使用可以嵌入摇摆的JavaFX WebView。在纸上听起来很棒(特别是因为他们声称使用的WebKit在Chrome / Safari中的UI性能明显更好)。

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

它有效,但是:表现令人难以置信。在Chrome,Safari(甚至是速度较慢的Firefox)中,数量级的速度比同样的速度慢。它几乎无法使用(我的UI大量使用JQuery / JS)。顺便说一句,我使用的是这篇文章

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.

问题是:


  1. 任何人都可以介绍我的经验吗?我只是做错了什么,或者这是由JavaFX引起的,因此正常?

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


推荐答案

我已经使用了很多WebView,通常表现非常完美很好,非常实用。

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


  • Html5合规性很好。

  • JavaScript性能各不相同,但我发现它根据谷歌的V8基准测试(Chrome可能针对其进行调整),大约是最新版本Chrome的三分之一速度。

  • 渲染性能似乎不是什么大问题。

  • 非常密集的HTML Web应用程序(例如Chrome实验库中的某些应用程序)启动速度不如其他浏览器那么快。

  • 不支持WebGL回归到WebGL图形软件渲染的网站要慢得多。

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

我对WebView的最大问题是它不是与其他浏览器一样稳定的前沿功能和密集使用,但实际上并没有任何严重的性能问题。

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.

这里有几个b enchmark stats(使用的WebView版本来自JavaFX 2.2 build 9):

Here are a few benchmark stats (WebView version used was sourced from JavaFX 2.2 build 9):

合规性

运行 html5 测试以测试html5合规性(分数超过500):

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

运行 acid3 测试,webview得分与其他测试浏览器相同,但是,与IE9一样,最终渲染有一点点不完美。

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基准测试(越低越好):

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基准测试(越高越好) :

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基准(越低越好):

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

密集画布

旋转 3D佛(越高越好):


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

JQuery

JQuery测试套件执行(越低越好):


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

根据上述基准测试(在我的Windows 7桌面上运行),只要WebView稳定且功能足够,那么WebView与其他浏览器的性能不应成为问题(只要您的应用程序没有很多3D旋转的佛像。 。 。 : - )。

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

更新

正如uta的答案所述,JavaScript JIT编译器已打开,用于JavaFX 2.2的Win 32位版本和关闭Win 64位版本 JavaFX 2.2。这意味着运行64位JavaFX版本与32位JavaFX版本时,WebView JavaScript基准测试速度明显变慢(通常慢4到5倍)。

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.

这篇关于JavaFX中WebView的性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆