Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to optimize renderspeed in android webview

Is there a possibility to enhance the rendering speed in webview? With a simple innerHTML it takes close to 1 sec to display the content although the js rendering takes a few ms. With IOS, exactly the same code is running swiftly and perfectly, even with less performant hardware.

Tested under Android: 2.3, 3.2, 4.0 (Desire HD, Galaxy Nexus, Galaxy Tab) IOS: 4, 5 (iPhones 3gs, 4)

Appreciate any helpful responses!

like image 309
nonnnnn Avatar asked Jan 10 '12 21:01

nonnnnn


People also ask

How to improve WebView performance Android?

Enhance webView performance - disable the WebView cache to make WebView much faster. Supercharging the Android WebView - cache critical assets that drastically reduce the load time.

Is WebView slow?

Using WebViews in your native application is very common these days but when it comes to performance, rendering of a WebView is quite slow. As most of the heavy lifting done by WebView is loading images.

What is the use of WebView in android?

The WebView class is an extension of Android's View class that allows you to display web pages as a part of your activity layout. It does not include any features of a fully developed web browser, such as navigation controls or an address bar. All that WebView does, by default, is show a web page.

What is WebView browser?

Android WebView is a system component for the Android operating system (OS) that allows Android apps to display content from the web directly inside an application.


1 Answers

There are a few things you can try:

  • Turn on hardware acceleration by adding android:hardwareAccelerated="true" to the application or activity tag in the Android manifest file. More info here: http://developer.android.com/guide/topics/graphics/hardware-accel.html

  • Modify the RenderPriority of the webview - http://developer.android.com/reference/android/webkit/WebSettings.RenderPriority.html

  • Optimize your javaScript and CSS to minimize the number of reflows, memory used, and DOM size - http://www.html5rocks.com/en/mobile/mobifying.html#toc-optimizations

Personally, I found that keeping the DOM as small as possible, and enabling hardware acceleration made all of the difference between an unusable app, and a fairly smooth app.

like image 191
Jonathan Avatar answered Oct 11 '22 02:10

Jonathan