XDA Xposed Tuesday: XHangouts Will Improve Your Hangouts

Ever since Google started supporting text messaging in Hangouts many people have … more

Shattered Screen? Turn Your Broken Device into a Complete Media Center!

A cracked screen usually means you’ll have to spend a hefty … more

Gmail 5.0: Material Design and Multiple Account Support

Google started to materialize many of its applications right after announcing the … more

Some of Our Favorite Features in Android 5.0 Lollipop

Android 5.0 Lollipop is the latest major revision to Google’s mobile operating … more
Post Reply

Hardware acceleration, poor performance in 3.1

OP z4gnom

11th August 2011, 09:20 AM   |  #1  
OP Junior Member
Thanks Meter: 0
 
11 posts
Join Date:Joined: Jan 2011
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.)
test_hw_acc_enabled_3.1.rar - android sources with html5/javascript page in assets (index.html).

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:

Android sources:
AndroidManifest.xml :
enabling HW accell on application level
Code:
<application android:icon="@drawable/icon" android:label="@string/app_name" android:hardwareAccelerated="true" >
hw_webview.java:
Code:
final WebView myWebView_hw_acc_enabled = (WebView) findViewById(R.id.webView1);
WebSettings webSettings1 = myWebView_hw_acc_enabled.getSettings();
webSettings1.setJavaScriptEnabled(true); 
myWebView_hw_acc_enabled.setWebChromeClient(new WebChromeClient());
//enable hardware acceleration for the 1st view, this line can be skipped 
//as acceleration enabled on application level by AndroidManifest.xml
myWebView_hw_acc_enabled.setLayerType(WebView.LAYER_TYPE_HARDWARE, null); 
myWebView_hw_acc_enabled.loadUrl("file:///android_asset/www/index.html");

     

final WebView myWebView_hw_acc_disabled = (WebView) findViewById(R.id.webView2);
WebSettings webSettings2 = myWebView_hw_acc_disabled.getSettings();
webSettings2.setJavaScriptEnabled(true);
myWebView_hw_acc_disabled.setWebChromeClient(new WebChromeClient());
//disable hardware acceleration for the 2nd view
myWebView_hw_acc_disabled.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
myWebView_hw_acc_disabled.loadUrl("file:///android_asset/www/index.html");


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:
Code:
	<div id="box" style="left:50px;top:50px;width:150px;height:100px;position:absolute;background:#000;"></div>
	<script>
		var left = 50; //initial position
		var delta = 1; //pixels per iteration
		var dir = 1;   // direction 1/-1
		function move()
		{
			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
	</script>
Example is only for simple html and javascript, but other modern features like CSS transitions, etc - have same problem.

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)
Attached Files
File Type: apk test_hw_acc_enabled_3.1.apk - [Click for QR Code] (14.6 KB, 365 views)
File Type: rar test_hw_acc_enabled_3.1.rar - [Click for QR Code] (41.3 KB, 135 views)
11th August 2011, 05:34 PM   |  #2  
MrSewerPickle's Avatar
Senior Member
Flag Frisco
Thanks Meter: 13
 
135 posts
Join Date:Joined: Aug 2010
More
I wonder if its because of the actual drivers being used. Is the video driver used by the kernel compiled in or insmod loaded during boot? I really havnt looked at how each driver is loaded in regards to Tegra 2 SOC.

Super wishful thinking would hope that maybe nVidia has a newer driver we could slap down and benchmark with HW accelleration?
11th August 2011, 05:54 PM   |  #3  
MrSewerPickle's Avatar
Senior Member
Flag Frisco
Thanks Meter: 13
 
135 posts
Join Date:Joined: Aug 2010
More
Also... On my Tab with the test apk you made, two webviews actually start out at the same speed then the hardware accellerated one begins to lag at roughly 2 seconds into the movement across.

It never regains that same speed as the non accellerated view so its not likely a GC running/inducing issue as it would likely speed up after the GC event (assuming it doesnt cause continous calls to the garabage collector).
16th August 2011, 09:29 AM   |  #4  
OP Junior Member
Thanks Meter: 0
 
11 posts
Join Date:Joined: Jan 2011
3.2?
any new ideas?

may be someone can run attached application on tablet with android 3.2 - just to check if bug fixed?
3rd September 2011, 07:33 PM   |  #5  
OP Junior Member
Thanks Meter: 0
 
11 posts
Join Date:Joined: Jan 2011
tested on acer iconia tab with 3.2 - same problem ;(
16th October 2011, 01:35 PM   |  #6  
Junior Member
Thanks Meter: 0
 
1 posts
Join Date:Joined: Oct 2011
I tested this on Asus Transformer TF101 (Andoid 3.2.1) and the issue exists there too.
20th October 2011, 09:58 PM   |  #7  
Member
Thanks Meter: 0
 
37 posts
Join Date:Joined: Aug 2007
Tested on Samsung galaxy tab 10.1. Same problem

Sent from my GT-P7500 using Tapatalk
1st December 2011, 02:32 PM   |  #8  
Junior Member
Flag Padua
Thanks Meter: 2
 
28 posts
Join Date:Joined: Jun 2010
Anyone have benchmarked accelerated webview performance of Android 4.0?
13th January 2012, 06:54 PM   |  #9  
Senior Member
Thanks Meter: 18
 
621 posts
Join Date:Joined: Nov 2011
Same problem here and with Android 4 on Galaxy Nexus,
android hardware acceleration is something that works bad and the problem is that they don't have fixed it yet.
The Following User Says Thank You to sblantipodi For This Useful Post: [ View ]
13th January 2012, 07:27 PM   |  #10  
Senior Member
Thanks Meter: 306
 
1,008 posts
Join Date:Joined: May 2010
Thumbs down
Quote:
Originally Posted by sblantipodi

Same problem here and with Android 4 on Galaxy Nexus,
android hardware acceleration is something that works bad and the problem is that they don't have fixed it yet.

Damn, hate it when I accidentally hit the "thanks" button...

BTW- this thread is 1) long dead, 2) discussing android 3.1 on a tablet, not android 4.0 on a phone.

Post Reply Subscribe to Thread

Tags
hardware acceleration, honeycomb, performance
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes