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

  • 相关阅读:
    C#调用C++代码遇到的问题总结
    ASP.NET MVC Controller的激活
    利用fis3自动化处理asp.net项目静态资源时遇到的一个编码问题
    工作中遇到的一个多线程下导致RCW无法释放的问题
    在mongoose中使用$match对id失效的解决方法
    passport源码研究
    android手机旋转屏幕时让GridView的列数与列宽度自适应
    git 版本回退
    梦之解读:如何成为牛人
    DataTable与DTO对象的简易转换类
  • 原文地址:https://www.cnblogs.com/lexus/p/2798236.html
Copyright © 2020-2023  润新知