android app to the challenge
Post on 22-Nov-2014
2.440 Views
Preview:
DESCRIPTION
TRANSCRIPT
AndroidApp 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● Rule – aim overdraw to 2x● Could indicate a complex
hierarchy● “Show GPU overdraws” on
Developer options (4.2+)
4x
3x
2x
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 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
– Execute
●
113
2537
4961
7385
975
9 1721 29
33 4145 53
57 6569 77
81 8993 101
105109
113117
121125
0
1
2
3
4
5
6
7
8
9
Execute
Process
Draw
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"ortargetApi >= 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
Thank you
@udinic
http://www.udinic.com
udi@udinic.com
top related