zoukankan      html  css  js  c++  java
  • Android WebView Scrolling Performance

    RIA Mobile Solutions

     

    Android WebView Scrolling Performance

    Posted on 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:

    http://stackoverflow.com/questions/7422427/android-webview-slow

    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. 

    http://developer.android.com/guide/topics/graphics/hardware-accel.html

    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.

    image

    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:  https://plus.google.com/105051985738280261832/posts/2FXDCz8x93s

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

  • 相关阅读:
    django--orm操作
    路由
    django ----视图和路由
    DJango 前三天小结
    JQuery----操作01
    前端---JQuery初识
    前端----jsDOM
    前端---js02
    前端-----js
    面向对象
  • 原文地址:https://www.cnblogs.com/lexus/p/2798236.html
Copyright © 2011-2022 走看看