[MINI GUIDE] App Optimization: Reducing Overdraw - Java for Android App Development

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:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
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!

thanks a lot.. a will be using this on my app and see the resaults

alobo said:
Code:
android:background="@null"
Click to expand...
Click to collapse
Where do you find the XML files to modify?

-deleted-

je2854 said:
Where do you find the XML files to modify?
Click to expand...
Click to collapse
I'm referring to your app's XML layout files, which can be found in res/layout.

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

molzz said:
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
Click to expand...
Click to collapse
Apparently you have to check 'User Host GPU' when creating your virtual device. Check this answer for more information.

Nice! I'll check it out

Yes, thanks Romain Guy for this tip. Actually I would recomend to watch all videos with him -- he gives a lot of valuable hints.

You should not use android:background = null, rather set the background to null in your onCreate.

Thanks a lot! I'll try it.

woaaa... great work!! it can be set generally? I mean with that code?

Related

increase the size of the soft keys at the bottom

is there any way to increase it to make it finger friendly. 5-7 extra pixels should be enough be enough.
anybody has idea?
THE GRIZZ said:
anybody has idea?
Click to expand...
Click to collapse
Unfortunately no. One thing that doesn't work: messing around with the system font size. I thought that might increase the size of the bar at the bottom but it didn't work. There may well be a registry entry that would increase the font size and thus the "touchability."
THE GRIZZ said:
is there any way to increase it to make it finger friendly. 5-7 extra pixels should be enough be enough.
Click to expand...
Click to collapse
Here is a pic of a stock Asus P565:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Idk how they do it, but you might want to look into it.
dwizzy130
the picture is exactlywhat i want i just hope this is not a photoshoped picture
Possibilities
There are several possibilities there.
I don't know the resolution of that thing, but it could be that the bars are stock, the fonts are smaller, could be that it's using a non standard today screen but infact a plugin/overlay/shell. The bars are images saved in the theme files, so it's possible that using an advanced theme editor they were able to create non standard layouts, but either way I'd hazard a guess it's not something you can just do with registry/font/file edits on the device.
through a lot of messing of my own, I have been able to acertain atleast that no one thing you change in the UI is going to stay at just that.
Changing the folder background colour for example (like I set the programs folder background to black and font to white) meant that in my mail app and many others i couldn't read the text because it also affected their font colours.
The highlights on a lot of text boxes inside apps are now black too, so unreadable text, certain sections of various windows changed, etc etc.
So, either way, it will need some theme editing or some extensive modifications to the theme layout.
THE GRIZZ said:
the picture is exactlywhat i want i just hope this is not a photoshoped picture
Click to expand...
Click to collapse
The pic is real. If you don't believe me, google asus p565.
dwizzy130
what I've come to realize, is that the icons and soft keys use the same pixel count as any other winmo phone, it's just that the pixels are smaller on our phones...lol
im bumping this in case someone knows something now

(Updated)(11-12)Create an Android Flip Clock in 30 Seconds

ATTN MODERATOR: If this is in the wrong thread, please relocate it. Thank you.
If you've worked on the Android Flip clock before then you know how much time is devoted to theming this bad boy. I've put together a nice "Action" that can be used in Adobe Photoshop.
This Action will do the following:
1) Mod the clock digit however you choose. You'll need to create the initial recorded action.
2) After you've created the initial recorded action, the "Actions" will go through 0-9, use your created action, save each digit's upper and bottom half using the correct dimensions on the flip clock.
3) It will also name the clock digits their correct name when opening the Fusion.apk (Based off of EVO & Thunderbolt) I'm not sure if this will carry over to other phones using the fusion.apk
All you'll need to do is rotate the clock digits upside down.
Adobe Photoshop Saved Actions
Change log:
11-12
*Added action to automatically cut and save the background image for the clock tabs. This way, you only have to create the background then run the action to export the two png's for the clock background.
*Includes actions posted on 11-06
Multi-http://www.multiupload.com/GI2VS462EK
11-06
*Started from Scratch by making the actions work from the root directory instead of my own personal directory which people were having problems replicating, including myself.lol.
*All PSD should be placed in C:\CLOCKMOD
*All PNG Output files should be placed in C:\CLOCKMOD\PNG_OUTPUT
Multi-http://www.multiupload.com/KYXQH64K0A
Here's a quick video demonstration:
*Sorry, but my mic wasn't working so no audio.
http://www.youtube.com/watch?v=KqsPjC3wvjw
At the request of another member, I've included a copy of the clock made with this "action." I've also included all the clocks I've designed so far. All I ask is that I be referenced if any of them are used in ROMS/Themes. Thanks.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Multi-http://www.multiupload.com/1E094Y1RGO
This is a awesome tutorial, I can't believe nobody has posted in this thread. Excellent work raider, you have some of the best themeing threads around. Keep up the good work.
Thanks! I've been trying to edit a flip clock for a bit now.
I'm a huge noob at this and i cant follow this at all.... can anyone give me easy instructions????
DJ1395 said:
I'm a huge noob at this and i cant follow this at all.... can anyone give me easy instructions????
Click to expand...
Click to collapse
This is only if you have Adobe photshop. Please pm me on this.
Sent from my ADR6400L using XDA Premium App
First of all thanks for your great work.
Could you please attach one of those clocks that you made this way?
Fantastic Job and excellent idea!
Is this for HTC Sense clock or not?
AdamiX said:
Is this for HTC Sense clock or not?
Click to expand...
Click to collapse
I'm confused on the whole sense thing. All I can tell you is it will work on the evo 3d clock, Thunderbolt and Evo. It was designed based on the clock in fusion.apk.
EDIT:
I'm uploading a bunch of clocks I made now. I don't mind if any themers or devs use them. All I ask if you reference me. Thanks
Sent from my ADR6400L using XDA Premium App
How do you install the clocks you've made? Thanks.
Any chance for support for those who can't afford photo shop and use Gimp?
Nice job man!
Thanks . Going to give this a shot right now.
would love to see these uploaded again i lost my set.

Cant get head around DPI changes on PA?

Hi guys,
I did do a search but couldnt find an answer to this. I have just rooted and installed PA rom to my phone to use the extended desktop etc. Thing is, there are 3 different tablet ui on their settings which i dont really understand? all are 1000p but diff dpi settings. Seems that if i 'lower' my dpi everything gets smaller, surely that should be the other way around as normally higher dpi = crisper image doesnt it? What ui are people using on PA?
I clicked on the help bit of the pa settings and it shows changing some stuff on the youtube app to make it look different but that doesnt seem to work either, was that only for tablets to get the 3d menu effect?
Thanks all
It's very easy. Dpi = size. That's it. Forget all this Tablet mode nonsense from the past. Dpi makes apps bigger or smaller nothing more.
Now apps bring layout containers, the programmer defines them. These containers tell the app how it should look on various devices and screen sizes. Paranoid android can read the actual layouts out of any app. And you can choose of course, again, app per app.
Every app on your system can have it's own size and layout. Everything is nicely listed on the hybrid manager. System Ui, the app that displays bars is no difference. We treat it in the same way. " tablet mode" means simply we set it to it's highest layout. There's several settings because you can decide how big you want it, these are presets that's all. You can finetune it in the interface section. Play around with it, almost nothing needs a reboot, not even switching UI's.
I sometimes wish xda would not ignore us. They haven't featured hybrid engine at least once so people still don't know what it is.
Ps here's a mini tutorial
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Right column sets Skype into a higher UI. This is how it looks on a nexus 10. Try any app you like there's literally hundreds with awesome UIs that work great on your phone.
molesarecoming said:
Ps here's a mini tutorial
Right column sets Skype into a higher UI. This is how it looks on a nexus 10. Try any app you like there's literally hundreds with awesome UIs that work great on your phone.
Click to expand...
Click to collapse
Thanks for the help mole, yeah i think i realise how the dpi works now it just confused me as i thought higher dpi would = smaller crisper text but i am clearly confusing that with resolution (thought they were the same thing).
Appreciate the mini tutorial will just keep playing with it

Tip for JB stock ROM users.

I am far from being an Android power user. I don't use mods, skins or launchers and prefer to stick to stock ROMs.
The farthest I go is to root my device, given the fact that some apps I need either work better with it or won't work at all without it.
So you have an idea, just the other day I posted I couldn't figure what "Greenify" was good for since, as I understood it, If we have to enter the app to hibernate/de-hibernate the target apps we might as well just launch and kill them, as needed, only to be kindly enlightened by another user about the fact of life that some apps do still run in the background, even after we've killed them.
...Pretty "tech challanged", right?
...but, coming from this "restricted" background, I do have a tip to share with you guys after having tried some online suggestions to deal with the relative "sluggishseness" and low Quadrant benchmarks I was faced with, after having migrated to JB XSP.
Apps took up to 3 seconds to launch and I was having this kind of values in Quadrant:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
I tried a bunch of stuff to improve things up. I removed a series of apps I rarely used, even some system ones, using SystemApp Remover and inhibited others like MacroDroid. Still, no improvements.
Until...
Today, acting on tip read online, I went to "Settings" ---> "Developer Options" ---> (Activate) ---> "Drawing" and changed "Window animation Scale", "Transition Animation Scale" and "Animation Duration Scale" from the default values to 0.5x.
I got definite improvement in launch response, general "sluggishseness" with Quadrant values jumping to this:
Happy Puppy now
Hope this helps!
XK
I tried your suggestion and here are my results
Before change
4488
After change
3446
Restored to original settings
4146
Sorry for lack of images but I am unable to attach them.
In my case those settings did not improved the performance it actually decreased it. This might be on a case by case scenario but a good tip nonetheless
Sent from my GT-P6800 using xda premium
Note the huge jump in the I/O score. Seems out of character with the other devices.
"media" app. is consuming too much battery n running constantly even after force stopped. How to solve this issue..?
aries8 said:
"media" app. is consuming too much battery n running constantly even after force stopped. How to solve this issue..?
Click to expand...
Click to collapse
use this https://play.google.com/store/apps/...SwxLDEsImNvbS5hZGR6Lm1lZGlhc2Nhbm5lcnJvb3QiXQ..
or
https://play.google.com/store/apps/details?id=com.addz.mediascanner&feature=more_from_developer
to stop the media scanner

YotaPhone 2: sub-optimal e-ink text rendering

Besides from turning on high contrast fonts in Accessibility, does anyone have any other ideas on how to improve the reading experience on the back screen? After doing actual long-form reading on it, I'm finding that it's rather...lacking. FYI, here's a comparison of the e-ink text on my Paperwhite (212 ppi) vs. the YP2 (234 ppi):
Kindle Paperwhite (1st gen), Caecilia font:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Kindle for Android, Caecilia font:
Moon+ Reader, default serif font:
Full-res pics are here:
http://imgur.com/a/GCOe0
Pardon the low contrast on the Paperwhite snapshot -- it's because of the screen protector. Since the Kindle app is using the same font as the Paperwhite, the software tuning that Amazon made obviously goes beyond just the fonts; it seems they also tweaked the font rendering itself to offer some sort of subpixel anti-aliasing. The YP2 e-ink text looks so jagged and rather ugly compared to the Paperwhite when I have the two devices sitting next to each other.
You can try the mirror config app http://forum.xda-developers.com/yotaphone-one/development/yotaphone2-yotamirrorcfg-1-0-0-t3326208. When setting waveform to PARTIAL (may also need to set "dithering" argument to STEINBERG or NONE), the display quality improves a lot, though the screen refresh rate goes down, also take a look at my explanation and attachments at #22 and OP's at #20
chbinnc said:
You can try the mirror config app http://forum.xda-developers.com/yotaphone-one/development/yotaphone2-yotamirrorcfg-1-0-0-t3326208. When setting waveform to PARTIAL (may also need to set "dithering" argument to STEINBERG or NONE), the display quality improves a lot, though the screen refresh rate goes down, also take a look at my explanation and attachments at #22 and OP's at #20
Click to expand...
Click to collapse
Thanks a lot, I didn't know there was such an app -- will have to check it out!
The font don't look that bad on my phone, event it's not as good as my kindle.
http://nsm08.casimages.com/img/2016/12/14//1612140220422066714706144.jpg
Android 5 EU 1.1.124b
I have those lines in the TitaniumManager/mirroring.cfg located in the sd card :
[com.amazon.kindle]
# Amazon Kindle
# https://play.google.com/store/apps/details?id=com.amazon.kindle&hl=ru
contrast=40
brightness=-10
sharpening=1.0
nosleep=true
slowmode=true
main_waveform=PARTIAL
main_dithering=NONE
spidermoon said:
The font don't look that bad on my phone, event it's not as good as my kindle.
Click to expand...
Click to collapse
Thanks for posting the screenshot -- it does indeed look quite nice, at least a lot better than mine. Two questions:
1. Does the "slowmode" have a negative impact on swiping?
2. What font are you using?
UPDATE: I just opened this file I have the exact same settings as you (it seems like it's the default settings for the Kindle app). How come yours looks better -- do I have to install the YotaMirrorCFG app to make this work or something?
10basetom said:
Thanks for posting the screenshot -- it does indeed look quite nice, at least a lot better than mine. Two questions:
1. Does the "slowmode" have a negative impact on swiping?
2. What font are you using?
UPDATE: I just opened this file I have the exact same settings as you (it seems like it's the default settings for the Kindle app). How come yours looks better -- do I have to install the YotaMirrorCFG app to make this work or something?
Click to expand...
Click to collapse
It's Caecilia font, like your screenshot. Personnaly, i prefer Lucida. I don't know what "slowmode" do. With this default setting, pages swipe quickly, almost without gosthing efffect. I don't use YotaMirrorCFG, it's look's good like that.
It's the 7.6.0.42 version of kindle apps.

Categories

Resources