Android WebView Scrolling Performance

April 23rd, 2012

Our team is currently developing a web based application that needs to be consumed in Android WebView.    One of the biggest performance issues we noticed was scrolling a long list of users on one page.   The response to the gesture to scroll down through the list would often be met with a half second delay followed by very unsmooth scroll.

However, viewing the same page in the in the Android native browser didn’t produce the same results.  The response time to the gesture to scroll was almost instant and the scroll was smooth.

Just for reference, this was tested on Android Xoom (Android Version: 4.0.3) and a Toshiba AT100 (Android 3.1).

This post on StackOverflow helped resolve the issue:

The first suggestion was to setRenderPriority on the webview settings to high and set the cachemode to load no cache.  Setting these didn’t provide any noticeable gains in performance.

The following suggestion was to enable hardware acceleration.  This significantly increased the response to the gesture to scroll and the smoothness of the scrolling.

Checkout the Android document for more information on hardware acceleration.

In short, hardware acceleration renders all drawing operation in a view using the GPU, reducing CPU consumption and increasing the amount of RAM used by the application.  The problem is, the acceleration may cause rendering issue with older applications.  To work around that, you can target where you want to the acceleration to occur.  Hardware acceleration can be targeted at the application level, activity level, window level or view level.

For our fix, we enabled the acceleration at the application level through the manifest file by setting the application android:hardwareAccelerated=true:

If you are running a device with Android 4.0, you can ‘Force GPU rendering’ to test this functionality.  The downside is that this forces GPU rendering for all your applications and may cause issues with older apps, although it’s a nice way to quickly test if it fixes your issue.


Few Updated Notes:

  1. If you feel like the app is still slow, make sure to build a release version and test that on the device. The difference between debug and release mode seemed noticeable
  2. Here is a good article on how graphics are rendered in Android:

    It noted that “The main change in this regard in Android 4.0 is that now apps that are explicitly targeting 4.0 or higher will have acceleration enabled by default rather than having to put android:handwareAccelerated=”true” in their manifest.”