際際滷

際際滷Share a Scribd company logo
Android
App to the challenge


      Udi Cohen
We'll 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
whoami
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
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
Over Draw
Happens 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
                     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
Hierarchy Viewer
Traceview Profiling
   Performance of each method
   Graphical interface
   Run from DDMS or code
Traceview Profiling
Traceview Profiling




Inclusive: Includes child functions

Exclusive: This function only
Traceview Profiling
Traceview Profiling
So...what's 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
   Use any Java HPROF analyzer
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  good for preview
   Resource folders
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)
Log
   EventLog
         Adb logcat -b events
         Framework level logs
         DB and system operations
Hardware Acceleration
   android:hardwareAccelerated="true"
     or
     targetApi >= 14
   Efficient drawing model
   Compatibility issues
          Custom views
          Unsupported operations
Hardware Acceleration
   Good for animations
   View Layers
Tips
   Always Measure
   Lint
          Comes with the SDK
          Scan the project's 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
@udinic
http://www.udinic.com
udi@udinic.com



              Thank you

More Related Content

Android app to the challenge

  • 1. Android App to the challenge Udi Cohen
  • 2. We'll 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
  • 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. 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. Over Draw Happens to the best of us
  • 7. Tracer for OpenGL Layout tree step by step See redundant draw operations Heavy
  • 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
  • 10. Traceview Profiling Performance of each method Graphical interface Run from DDMS or code
  • 12. Traceview Profiling Inclusive: Includes child functions Exclusive: This function only
  • 15. Helping out the GC Allocation Tracker (DDMS)
  • 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. Helping out the GC Eclipse MAT (Memory Analyzer Tool)
  • 18. Helping out the GC Histogram & Dominator tree
  • 19. Tips - Bitmaps InJustDecodeBounds Load only properties InBitmap reuse other allocation InSampleSize good for preview Resource folders
  • 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. Log EventLog Adb logcat -b events Framework level logs DB and system operations
  • 22. Hardware Acceleration android:hardwareAccelerated="true" or targetApi >= 14 Efficient drawing model Compatibility issues Custom views Unsupported operations
  • 23. Hardware Acceleration Good for animations View Layers
  • 24. Tips Always Measure Lint Comes with the SDK Scan the project's 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