You released an Android Application to the Play store. You even have some Advertising to make some money. The next step is to improve the code by looking at the crashes the Users are experiencing, and fixing them. The talk will cover current services to collect crash data, explain how to analyze the information. We will present an example crash analysis, and go in depth into the Android Garbage Collector, and the way it works for different versions of Android. We will also provide with a GC benchmarking tool, and some tips and tricks.
3. 3
Intro
• App on the market
• Crashes will happen
• Need to Fix the Bugs!
• Identify the root issues
4. 4
Who?
• Developing for Android since 2008
• The first employee of DroidSecurity
– First company to release An antivirus to the Android
market (2009)
– Later acquired by AVG (2011)
• Mobile Security Research Team Leader @AVG
• B.Sc Information System Engineering from BGU
7. 7
What to fix first?
• Easy to fix
• Affects most users
• The ones users complain most about
• Affects the most popular device
8. 8
Root cause analysis
• Stare at data:
–Crash type
–Exception Type
–Device
–Manufacturer
–OS version
–Locale
• And stare some more…
9. 9
Ultimate debugging method!
• What is the answer to this bug?
– 42
• We don’t know the answer
– Brainstorming
– Developing tools
• Learning something new…
10. 10
Root cause analysis – Real world example
• Concurrent.Timeout exception
– ~10% of total crashes for AVG antivirus.
– Unhelpful stack traces
– Second place in top 10 crashes (and number 5, and number 9)
java.util.concurrent.TimeoutException: android.os.BinderProxy.finalize() timed out after 10
seconds
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:401)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:102)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:73)
at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:170)
at java.lang.Thread.run(Thread.java:841)
java.util.concurrent.TimeoutException: com.android.internal.os.BinderInternal$GcWatcher.finalize() timed out after 10 seconds
java.util.concurrent.TimeoutException: android.os.Parcel.finalize() timed out after 10 seconds
java.util.concurrent.TimeoutException: java.io.FileInputStream.finalize() timed out after 10 seconds
11. 11
Device and OS analysis
33%
66%
Device
Galaxy S3
49%
38%
13%
19%
10%
71%
OS
Crash Dashboard
4.2.2
4.3
Other OS
Versions
20. 20
Garbage collector observed behavior
Cause Effect
GC_FOR_MALLOC Stop The world GC
Use complex Objects GC takes longer
A lot of small objects GC take Longer
Use more memory GC takes longer
USE_LARGE_HEAP All of the above
21. 21
Trying to replicate the problem
• The GC_Test project
– Test the GC performance under load
– Android app to test the behavior of the GC on android
– https://github.com/oba2cat3/GCTest
• Useful logcat python script
– https://github.com/oba2cat3/logcat2memorygraph
• Available from GitHub
34. 34
Tips for managing GC
Do How
Avoid GC_FOR_ALLOC Load stuff in Splash
Use Object Pools For large/heavy objects
Avoid Complex Objects Use simpler Objects
Perform Heap analysis Use MAT and DDMS
Reduce memory use …