Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Hardware Acceleration - to use or not to use?

I'm developing an app that it functionality very similar to Facebook Android native app: social network that most of the time the user will spend in an endless ListView displaying lot's of images, entering an image gallery, and so on.

let's say for the discussion that I'm doing all the right things and best android practices to achieve smooth scroll (recycling views as it should, using different view types when needed, loading to memory only scaled bitmaps in the needed size, caching bitmaps, using ViewHolder design pattern, not blocking th UI thread when its possible and so on...)

let's say also that every thing else in my app written in the best way and following best practices (for the discussion... :->)

my app working not bad at all in that stage, but when turning on the hardware acceleration, as described and promised in Android Developers documentation it making my app much much more smooth and fast.

let's say that it does not affect in any nagative way on the UI as can happened, and I'm not performing any of the Unsupported Operations

according to Google's document on the subject, only reason I can see not to use this feature (besides all other reasons I already mentioned above) is that it can cause my app to use more RAM. but how much RAM? a lot more? I know that when my app consumes lot's of RAM - it becoming good candidate to be destroyed by the OS when it need to free some memory.

my question is basically -

  • is it "ok" under my circumstances to use this feature?
  • what other problems can raise from using it?

TIA

like image 505
Tal Kanel Avatar asked May 08 '13 04:05

Tal Kanel


People also ask

Should I turn on hardware acceleration on Android?

If your application uses only standard views and Drawable s, turning it on globally should not cause any adverse drawing effects. However, because hardware acceleration is not supported for all of the 2D drawing operations, turning it on might affect some of your custom views or drawing calls.

Should I use hardware acceleration or not?

Hardware acceleration is where certain processes - usually 3D graphics processing - is performed on specialist hardware on the graphics card (the GPU) rather than in software on the main CPU. In general you should always enable hardware acceleration as it will result in better performance of your application.

What is the use of hardware acceleration in Android?

Beginning in Android 3.0 (API level 11), the Android 2D rendering pipeline supports hardware acceleration, meaning that all drawing operations that are performed on a View 's canvas use the GPU. Because of the increased resources required to enable hardware acceleration, your app will consume more RAM.

Should U turn off hardware acceleration?

Faulty hardware acceleration doesn't help your PC or browser at all, so it's best to fix it or disable it. You might also run into error messages because of it. For example, when playing a video game, you could get an error warning you about slow performance.


1 Answers

To use or not to use

It is advised to use hardware acceleration only if you have complex custom computations for scaling, rotating and translating of images, but do not use it for drawing lines or curves (and other trivial operations) (source).

If you plan on having common transitions and also given that you have already considered scaling, recycling, caching etc, than it may not make sense to burden your project anymore. Also, any efforts spent reworking your code to support hardware acceleration will not effect users on versions below 3.0, which are ~36% of the market as of May 8, 2013.

Memory

Regarding memory usage (according to this article), by including Android Hardware the application loads up the OpenGL drivers for each process, takes memory usage of roughly 2MB, and boosts it to 8MB.

Other issues

Apart from API versions, I presume it will also affect battery life. Unfortunately there aren't any benchmarks on different use cases online in order to draw a line on this one. Some argue that in given cases because of multiple gpu cores, using acceleration may save battery life. Overall, I think it would be safe that the effect won't be too dramatic (or Google would have made this a major point).

like image 62
ılǝ Avatar answered Oct 04 '22 19:10

ılǝ