My app works with regular webview but it's very slow under Android 4.0 - 4.2 and just slow on 4.3 and 4.4.
I've already done lot of optimalizations in html/js/css, but still is too slow. So decided to take a look at Crosswalk project.
It's almost all great even with +20mb size for apk, except for one thing..
You cannot create XWalkView (equivalent of WebView) with Service context (like you can do with regular WebView) only Activity context is an option for Crosswalk view.
Why it's bad?
The website that I load into WebView/XWalkView uses WebSockets, it has to be always alive! But Android likes to kill apps, especially on older devices with Android 4.0-4.2.
Solution is to create WebView with Service context and keep reference to it in Service (Service is in foreground mode so hard to kill!).
Then if Activity will crash or will be garbage-collected, simply user taps to it, Activity recreates himself and gets reference to WebView (from Service class) to add it to his hierarchy again. :) (and in the meantime when activity didn't exist, webview was still working along with websocket connection)
All works, but with WebView and WebView is slow..
Why I am writing it? Need advice from you what to do or maybe solution how to force CrossWalk view to works with Service context.
Is it other way to keep XWalkView "always" alive?
Thanks!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire