1. Service ANR
Cause : The main thread did not complete the execution of each lifecycle function of the Service within the specified time (20s in the foreground and 200s in the background).
Prompt : Reason: Executing service + package name
Service ANR trigger process :
How to detect Service timeout:
Here, a timeout message is sent first. If the service task is completed within the threshold time range, serviceDoneExecuting will be called and the message will be removed, otherwise the ANR process will be triggered.
2. Broadcast ANR
Cause : The main thread did not finish executing the onReceive function of BroadcastReceiver within the specified time (10s in the foreground, 60s in the background).
Prompt : Reason: Broadcast of Intent { act=XXX flg=XXX cmp=XXX }
Broadcast ANR trigger process :
How to detect Broadcast timeout:
三、ContentProvider ANR
Cause : The main thread did not finish executing ContentProvider-related operations within the specified time (10s).
Prompt : Reason: timeout publishing content providers (ANR bullet box will not be reported).
ContentProvider ANR trigger process :
How to detect ContentProvider timeout:
4. Input ANR
Cause : The main thread has not finished processing the current input event within the specified time (5S), and the next Input time has come and is waiting for it to finish processing (the timeout will not happen if there is no next Input).
Prompt : Reason: Input dispatching timed out (reason has many reasons here)
Finally, let's take a look at the execution of ANR:
The previous major components, including Input, send a timeout message at the end. After a series of judgments, the appNotResponding method of AppErrors is finally called to perform ANR processing.
Here is mainly the ANR operation, the main content is the collection of ANR information in the main log, the execution of dump operation, the addition of DropBox, the pop-up window prompting ANR, etc.
Reprint: https://www.jianshu.com/p/fe7373d224ca