androidperformance-testingtraceandroid-anr-dialog

Understanding .trace file of an Android application


My application gives ANR popup. To find out the reason I have generated a sample.trace file using this line:

Debug.startMethodTracing("sample");

in onCreate method of my activity, and I have added this line to stop tracing to the onDestroy method of the activity:

Debug.stopMethodTracing();

I get the sample.trace file after I destroy the activity. But when I review the file I do not understand it. As I learn there is an online tool which is Perfetto.

However when I open the file in there, it shows blank page while I am expecting some UI.

As a result I need to understand the file and find out the problems that cause the ANR issue but I do not know how to do.

This is a piece of my sample.trace file :

*version
3
data-file-overflow=true
clock=dual
elapsed-time-usec=165959496
num-method-calls=599184
clock-call-overhead-nsec=3338
vm=art
pid=13695
*threads
14436   RxIoScheduler-2
14460   Okio Watchdog
14589   AsyncTask #5
14612   Timer-0
15013   AsyncTask #6
15014   AsyncTask #7
15015   AsyncTask #8
15049   Timer-4
13695   main
13718   Jit thread pool worker thread 0
13724   Signal Catcher
13726   ADB-JDWP Connection Control Thread
13728   FinalizerDaemon
13729   FinalizerWatchdogDaemon
13727   ReferenceQueueDaemon
13730   HeapTaskDaemon
13732   Binder:13695_1
13733   Binder:13695_2
13736   Binder:13695_3
13895   Profile Saver
13909   Queue
13910   Queue
13911   Queue
13912   Queue
13913   Queue
13914   Queue
13916   Queue
13917   Queue
13915   Queue
13936   Answers Events Handler1
13937   queued-work-looper
13941   Crashlytics Exception Handler1
13950   StethoListener-main
13970   OkHttp ConnectionPool
13977   Binder:13695_4
13978   process reaper
13980   process reaper
14016   RenderThread
14023   Binder:13695_5
14026   Binder:13695_6
14021   Thread-16
14152   Thread-17
14153   Thread-18
14156   Studio:InputCon
14165   magnifier pixel copy result handler
14151   Thread-19
14435   RxIoScheduler-1 (Evictor)
14459   OkHttp ConnectionPool
14476   RealmFinalizingDaemon
14480   pool-3-thread-1
14481   pool-3-thread-2
14482   pool-3-thread-3
14483   pool-3-thread-4
14484   pool-3-thread-5
14487   pool-3-thread-6
14489   pool-3-thread-7
14490   pool-3-thread-8
14491   pool-3-thread-9
14602   glide-disk-cache-thread-0
14604   glide-source-thread-0
14614   Timer-1
14615   IntentService[]
14628   glide-source-thread-1
14630   OkHttp ConnectionPool
14633   glide-active-resources
14780   pool-3-thread-10
14788   Picasso-Stats
14789   Picasso-Dispatcher
14790   Picasso-refQueue
14805   Timer-3
14973   SpotScheduleThread
14974   PlaylistScheduleThread
14980   pool-3-thread-11
15000   pool-3-thread-12
15021   RxComputationScheduler-1
15025   RxComputationScheduler-2
15028   OkHttp ConnectionPool
15050   Timer-5
15052   pool-3-thread-13
15053   pool-3-thread-14
15767   pool-3-thread-15
15771   pool-3-thread-16
15772   pool-3-thread-17
*methods
0x18c8  java.lang.BootClassLoader   getInstance ()Ljava/lang/BootClassLoader;   ClassLoader.java
0x6ba0  java.lang.BootClassLoader   findClass   (Ljava/lang/String;)Ljava/lang/Class;   ClassLoader.java
0x6b9c  java.lang.BootClassLoader   loadClass   (Ljava/lang/String;Z)Ljava/lang/Class;  ClassLoader.java
0x7878  java.lang.ClassLoader   <init>  (Ljava/lang/ClassLoader;)V  ClassLoader.java
0x7880  java.lang.ClassLoader   <init>  (Ljava/lang/Void;Ljava/lang/ClassLoader;)V  ClassLoader.java

Thanks in advance.


Solution

  • As I learned I can use Android Studio to see which process is taking more place on cpu and etc.

    The only thing that I need to do is opening Profiler window then click the + button and Load from file. Then it will show the statistics of the .trace file.

    Thanks!