5,600,335 Members 35,056 Now Online
XDA Developers Android and Mobile Development Forum

[MINI GUIDE] App Optimization: Reducing Overdraw

Tip us?
 
alobo
Old
#1  
Senior Member - OP
Thanks Meter 207
Posts: 160
Join Date: Mar 2012
Location: Waterloo
Default [MINI GUIDE] App Optimization: Reducing Overdraw

Hey XDA - I just wanted to share some useful information I came across while developing my app:


App performance is crucial if you want your users to enjoy using your app - the goal is to reduce lag.

There are many ways one can achieve this:
  • Using multithreading
  • Simplifying View hierarchy
  • Reducing Overdraw

Pixel Overdraw occurs when an app repaints a pixel multiple times. This is something we don't really think about, but can have a massive effect on our performance.

Enabling Profiling:

Fortunately, Android has some built in tools to help us developers. (You can find these under Developer Settings)
You'll want to turn on:
1) Force GPU Rendering
2) Show GPU Overdraw

Next, simply restart the app you want to profile and voila - areas of the screen are 'painted' in a variety of colours!


Interpreting Results:

These colours have significant meaning
  • No color: No overdraw.The pixel was painted only once.
  • Blue: 1x Overdraw
  • Green 2x Overdraw
  • Light red: 3x Overdraw
  • Dark red: 4x Overdraw


Fixing The Problem:
You'll want to dig in your XML layout files and look for areas of overlap. The biggest issue is if you are drawing backgrounds on top of each other. In my case, my app was drawing 4 backgrounds: one for the activity, one for the fragment, one for the ListView and one for the list item. Then text was drawn on top. As the the image at the bottom of this post suggests, it wasn't pretty.

The solution was simple:

Code:
android:background="@null"
I simply removed the unnecessary backgrounds.

Your solutions may not be as easy, but it doesn't hurt to give it a try. In fact, the scrolling performance of my app improved dramatically - it's now buttery smooth!

Some Results:





Credits to Romain Guy. He has a full tutorial on his blog that you should definitely check out.

Please let me know what worked for you and do share any tips you have to optimize app performance!
Hit thanks if I helped!

My Work:

OA Digital
The Following 34 Users Say Thank You to alobo For This Useful Post: [ Click to Expand ]
 
salam0smy
Old
#2  
Junior Member
Thanks Meter 1
Posts: 6
Join Date: Jul 2012
thanks a lot.. a will be using this on my app and see the resaults
 
je2854
Old
#3  
je2854's Avatar
Senior Member
Thanks Meter 158
Posts: 545
Join Date: Oct 2010
Location: Montgomery, TX (birthplace of the Tx Flag!)
Quote:
Originally Posted by alobo View Post
Code:
android:background="@null"
Where do you find the XML files to modify?
If I have helped you in anyway, please hit the Thanks button (:

LG G2
Moment, OG EVO4G, OG DROID, D2G, D3, D4, Droid Charge, ThunderBolt, Rezound, DROID X, HTC DNA, DROID Razr


Want 20GB free cloud storage? Copy.com
 
officialavram
Old
(Last edited by officialavram; 24th August 2013 at 04:51 AM.)
#4  
officialavram's Avatar
Member
Thanks Meter 1
Posts: 31
Join Date: Aug 2013
Location: World
-deleted-
 
alobo
Old
#5  
Senior Member - OP
Thanks Meter 207
Posts: 160
Join Date: Mar 2012
Location: Waterloo
Quote:
Originally Posted by je2854 View Post
Where do you find the XML files to modify?
I'm referring to your app's XML layout files, which can be found in res/layout.
Hit thanks if I helped!

My Work:

OA Digital
 
molzz
Old
#6  
Member
Thanks Meter 1
Posts: 33
Join Date: Nov 2012
does this work with emulators?i tried checking both overdraw and gpu rendering from dev setting in 4.2 emulator but opening apps does not show me anything
 
alobo
Old
#7  
Senior Member - OP
Thanks Meter 207
Posts: 160
Join Date: Mar 2012
Location: Waterloo
Quote:
Originally Posted by molzz View Post
does this work with emulators?i tried checking both overdraw and gpu rendering from dev setting in 4.2 emulator but opening apps does not show me anything
Apparently you have to check 'User Host GPU' when creating your virtual device. Check this answer for more information.
Hit thanks if I helped!

My Work:

OA Digital
 
zyngawow
Old
#8  
Junior Member
Thanks Meter 0
Posts: 2
Join Date: Jan 2013
Nice! I'll check it out
 
SergeyPo
Old
#9  
Junior Member
Thanks Meter 0
Posts: 11
Join Date: Apr 2013
Yes, thanks Romain Guy for this tip. Actually I would recomend to watch all videos with him -- he gives a lot of valuable hints.
 
adicool
Old
#10  
Senior Member
Thanks Meter 25
Posts: 136
Join Date: Jun 2011
You should not use android:background = null, rather set the background to null in your onCreate.

Tags
app, development, optimization, overdraw
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


XDA PORTAL POSTS

Intelligently Place Contacts on Your Home Screen with CallWho Widget

There are plenty of ways to get your contacts to show up on your … more

Control TWRP from within Android with TWRP Coordinator

You may recall that back when TWRP2 introduced a couple of years ago, it brought with … more

Keep Track of Everything Your Device Does with Event Logger

Regardless of their OS choice, computing power users generally share one common … more

A More Competitive Spin on the Addictive 2048 Puzzle

You may recall that a few weeks ago, we talked about a rather interesting take on … more