Android performance optimization—ANR problem location analysis

ANR (Application Not Response) The application is not responding. When the main thread is blocked, the following pop-up window will pop up.
Insert image description here

1. traces.txt file

Android's traces.txt file records the stack status of the process, which is very helpful for analyzing the reasons for slow application response and ANR. The location of the traces.txt file is located in /data/anr/.
Insert image description here

2. Export traces.txt file

adb pull /data/anr/traces.txt D:/

Insert image description here

3. Traces.txt file analysis

Insert image description here

  • The starting point is this "main"
  • The last call is the destroy method, which is called by jni
  • Implementation of jni layer
    Insert image description here
    It can be known that the implementation of jni layer involves time-consuming operations , so we should call this method in the child thread.

Guess you like

Origin blog.csdn.net/u011557841/article/details/131960561