gree / unity-webview

zlib License
2.25k stars 688 forks source link

WKWebView iOS HTML5 poor performance #649

Open diablo85xxx opened 3 years ago

diablo85xxx commented 3 years ago

Hi, i've some html5 games (built with easeljs library) embedded in local streamingassets of unity, and run in the WebView thanks to your plugin.

The games run very fine and smooth when previously i used UIWebView. But with the recent iOS API change (from UIWebView to WKWebVew) i notice that all my games are really slower in the new API (WKWebVew).

There is any know issue, or maybe any hardware acceleration to be enable for iOS?

Thanks in advance for your answer

KojiNakamaru commented 3 years ago

For iOS, there is no such setting like android:hardwareAccelerated. Generally WKWebView should be faster than UIWebView. For investigating your content, you can utilize Web Inspector, which allows you to debug/investigate your content running on your device:

https://developer.apple.com/library/archive/documentation/NetworkingInternetWeb/Conceptual/Web_Inspector_Tutorial/EnableWebInspector/EnableWebInspector.html

diablo85xxx commented 3 years ago

Ok i made a first test, i built 2 versions of the iOS WKWebView app in which:

v.1) Game is loaded from streamingAssetPath - The game seems to run really slow, like previously i wrote in this post v.2) Game is loaded from a http link of the same game - The game run perfectly!

So, now i'm thinking that should be some problem related to the loading from the streamingAssetPath (even load from persistentDataPath not change the situation).

Any ideas?

Meanwhile I would run further tests

diablo85xxx commented 3 years ago

Ok, i made a second test, i built a native iOS app (without using unity) that load from a local asset, following this solution: https://stackoverflow.com/questions/49638653/load-local-web-files-resources-in-wkwebview

Seems even in this case, the game have the very same performance problems.

Still no problems if i load the game from http with the native iOS app (like in the Unity case).

So, the problem it's something in the middle with the WKWebView (since i had no problem with UIWebView) and the html5 framework that i use (easeljs). It would be interesting to see if anyone have same problems with different frameworks

diablo85xxx commented 3 years ago

Googleing into the web, i found some general problems concerning WKWebView: https://stackoverflow.com/questions/43169989/when-i-use-wkwebview-to-load-local-html-i-find-it-renders-slower-than-uiwebview

I tried some of this solutions in the native WebView, but without any success