AndroidApp to the challenge      Udi Cohen
Well talk about..●   Graphics:       –   Over Draw       –   Detect UI glitches       –   Optimizing layouts with Hierarch...
whoami
Over Draw●   Draw something on top of     something else              4x●   Rule – aim overdraw to 2x    3x●   Could indic...
Over Draw – Solutions●   Remove default background●   getWindow().setBackgroundDrawable(null)●   <item name="android:windo...
Over DrawHappens to the best of us
Tracer for OpenGL●   Layout tree step by step●   See redundant draw operations●   Heavy
Dumpsys gfxinfo●   Since Jelly Bean●   Last 128 frames●   Frame < 16ms●   3 columns       –   Draw       –   Process   9  ...
Hierarchy Viewer
Traceview Profiling●   Performance of each method●   Graphical interface●   Run from DDMS or code
Traceview Profiling
Traceview ProfilingInclusive: Includes child functionsExclusive: This function only
Traceview Profiling
Traceview ProfilingSo...whats the problem here?
Helping out the GC●   Allocation Tracker (DDMS)●
Helping out the GC●   Memory profiling → Dalvik HPROF file    Use code or DDMS●   Use hprof-conv to convert to standard●  ...
Helping out the GC●   Eclipse MAT (Memory Analyzer Tool)
Helping out the GC●   Histogram & Dominator tree
Tips - Bitmaps●   InJustDecodeBounds – Load only      properties●   InBitmap – reuse other allocation●   InSampleSize – go...
StrictMode●   Problems Detector●   Single thread or the entire VM●   Show dialog, write to Log and more..●   Usually used ...
Log●   EventLog      –   Adb logcat -b events      –   Framework level logs      –   DB and system operations
Hardware Acceleration●   android:hardwareAccelerated="true"     or     targetApi >= 14●   Efficient drawing model●   Compa...
Hardware Acceleration●   Good for animations●   View Layers
Tips●   Always Measure●   Lint       –   Comes with the SDK       –   Scan the projects for optimizations       –   Great ...
@udinichttp://www.udinic.comudi@udinic.com              Thank you
Upcoming SlideShare
Loading in …5
×

Android app to the challenge

3,524 views

Published on

Writing an Android app is easy, but making it "smooth" is not always simple. The UX demands and over 1000 different Android devices present a big challenge for any new and existing app. Learn some methods to optimize your app an make it up to the challenge

Published in: Technology
0 Comments
10 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,524
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
48
Comments
0
Likes
10
Embeds 0
No embeds

No notes for slide

Android app to the challenge

  1. 1. AndroidApp to the challenge Udi Cohen
  2. 2. Well talk about..● Graphics: – Over Draw – Detect UI glitches – Optimizing layouts with HierarchyViewer● Profiling with Traceview● Helping the GC with HPROF● Playing tough with StrictMode● Getting intimate with the OS using EventLog● Hardware Accelerate your app● Tips
  3. 3. whoami
  4. 4. Over Draw● Draw something on top of something else 4x● Rule – aim overdraw to 2x 3x● Could indicate a complex 2x hierarchy● “Show GPU overdraws” on Developer options (4.2+) 1x
  5. 5. Over Draw – Solutions● Remove default background● getWindow().setBackgroundDrawable(null)● <item name="android:windowBackground">@null </item>● Transparent regions in 9patches● Use tools● Tracer for OpenGL● Hierarchy Viewer
  6. 6. Over DrawHappens to the best of us
  7. 7. Tracer for OpenGL● Layout tree step by step● See redundant draw operations● Heavy
  8. 8. Dumpsys gfxinfo● Since Jelly Bean● Last 128 frames● Frame < 16ms● 3 columns – Draw – Process 9 8 7 – Execute 6 5 Execute 4 Process● 3 Draw 2 1 0 5 13 21 29 37 45 53 61 69 77 85 93 101 109 117 125 1 9 17 25 33 41 49 57 65 73 81 89 97 105 113 121
  9. 9. Hierarchy Viewer
  10. 10. Traceview Profiling● Performance of each method● Graphical interface● Run from DDMS or code
  11. 11. Traceview Profiling
  12. 12. Traceview ProfilingInclusive: Includes child functionsExclusive: This function only
  13. 13. Traceview Profiling
  14. 14. Traceview ProfilingSo...whats the problem here?
  15. 15. Helping out the GC● Allocation Tracker (DDMS)●
  16. 16. Helping out the GC● Memory profiling → Dalvik HPROF file Use code or DDMS● Use hprof-conv to convert to standard● Use any Java HPROF analyzer
  17. 17. Helping out the GC● Eclipse MAT (Memory Analyzer Tool)
  18. 18. Helping out the GC● Histogram & Dominator tree
  19. 19. Tips - Bitmaps● InJustDecodeBounds – Load only properties● InBitmap – reuse other allocation● InSampleSize – good for preview● Resource folders
  20. 20. StrictMode● Problems Detector● Single thread or the entire VM● Show dialog, write to Log and more..● Usually used to detect slow operations on UI thread● Came with Gingerbread (2.3)
  21. 21. Log● EventLog – Adb logcat -b events – Framework level logs – DB and system operations
  22. 22. Hardware Acceleration● android:hardwareAccelerated="true" or targetApi >= 14● Efficient drawing model● Compatibility issues – Custom views – Unsupported operations
  23. 23. Hardware Acceleration● Good for animations● View Layers
  24. 24. Tips● Always Measure● Lint – Comes with the SDK – Scan the projects for optimizations – Great Eclipse/IntelliJ integration● ListView – Easy on the getView()● Alpha – Watch it...● Storage Read/Write● Direct access inside the class (!Get/Set)● SQLite indexes
  25. 25. @udinichttp://www.udinic.comudi@udinic.com Thank you

×