Hardware acceleration, poor performance in 3.1
As everyone know, a lot of modern mobile application developed using HTML5. It's simple to port them on other devices with different system using native webview or for example PhoneGap, etc, etc.
iOs, webOs and others do not have any problems with HTML5, but Android 3.x - have one big problem:
Starting from 3.0 hardware acceleration presented for android devices - http://android-developers.blogspot.c...eleration.html
And if you use webview - it's not possible to play video or flash without hardware acceleration, it's enabled by default in native browser and other apps and in theory should increase performance. It look like everything is ok, but WHEN YOU ENABLE HARDWARE ACCELERATION - PERFORMANCE OF YOU HTML5 APP BECOME VERY POOR, 2-3 TIMES LESS THAN WITHOUT ACCELERATION.
Tested on 3.0, 3.1, different ROMs, 2x 7500 and 2x 7510 samsung devices and on 2x acer iconia tab a500.
Please check attachments:
test_hw_acc_enabled_3.1.apk - test application that show difference between two WebViews with hardware acceleration enabled and disabled. Top view - HA enabled (and very slow), bottom view - HA disabled (fast, but not so fast as we want because of no hardware acc.)
Please note, that if you run this page in native browser that is pre-installed on Samsung Galaxy Tab 10.1 - you'll get same lags because HW acceleration enabled in this browser by default. So all Tegra 2 advantages lost here even in comparison with my 800mhz phone on Android 2.1.
No any 3rd-party libs or plugins used, here is small description:
enabling HW accell on application level
<application android:icon="@drawable/icon" android:label="@string/app_name" android:hardwareAccelerated="true" >
final WebView myWebView_hw_acc_enabled = (WebView) findViewById(R.id.webView1);
WebSettings webSettings1 = myWebView_hw_acc_enabled.getSettings();
//enable hardware acceleration for the 1st view, this line can be skipped
//as acceleration enabled on application level by AndroidManifest.xml
final WebView myWebView_hw_acc_disabled = (WebView) findViewById(R.id.webView2);
WebSettings webSettings2 = myWebView_hw_acc_disabled.getSettings();
//disable hardware acceleration for the 2nd view
index.html - simple setInterval used with 60fps estimate (move by 1px every 15 ms), with additional plugins (example:jQuery.animate) or libs we have much more lags:
<div id="box" style="left:50px;top:50px;width:150px;height:100px;position:absolute;background:#000;"></div>
var left = 50; //initial position
var delta = 1; //pixels per iteration
var dir = 1; // direction 1/-1
var div = document.getElementById('box'); //get box
if ((left>500)||(left<50)) dir = dir * -1; //change direction
left = left + delta*dir; //change position
div.style.left = left+'px'; //update style with new position
setInterval("move()",15); //every 15ms - 60fps estimate
Any idea how to fix this? I need HA enabled with expected performance increased but not decreased. As far as I understand - this is very big problem for android 3.0, because HTML5 is very popular and qty of HTML5 mobile application will only grow. Note that other modile systems work correctly (even 1st ipad and my motorola defy faster in HTML5 than overclocked honeycomb tegra 2 device)