Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to make a brief introduction to ANR

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

How to carry out a brief description of ANR, in view of this problem, this article introduces the corresponding analysis and answers in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.

Brief introduction of ANR and analysis process ANR

What is ANR? ANR is Application Not Responding, that is, the application is unresponsive.

Reasons for ANR

In Android system, ActivityManagerService (referred to as AMS) and WindowManagerService (referred to as WMS) will detect the response time of App. If the App cannot correspond to the screen touch or keyboard input time at a specific time, or if a specific event has not been handled, ANR will appear.

Generally speaking, there are three reasons for ANR:

1. Click, touch, keyboard input events did not respond in time within 5s (inputdispatch timeout)

two。 Broadcast timeout does not respond, foreground broadcast 10s does not respond, background broadcast 60s does not respond (Broadcast timeout)

3.service 20s is not responding (service timeout)

Analysis process of ANR

Now we use an analysis example to illustrate how to analyze the problem of anr.

1. First, we need to analyze a systemlog of anr.

You can locate where anr occurs in log by searching for the keyword "anr", as shown in the following figure

From this log in systemlog, we can know several key points.

The name and number of the process that occurred in 1.anr (PID: 1531)

The reason for the occurrence of 2.anr (for example, the time-out of the above click event did not respond)

When 3.anr occurs, the cpu of the process at that time is occupied, and the resources of the upper layer and Kernel layer occupied by the process are specified.

two。 Through the rough description of the previous step, we can find the time when anr occurred.

As you can see above, the anr is caused by the non-response of the click event timeout, so we can check what the specific anr process (Pid 1531) is doing in the first 5s of this time point (the time may not be 5s for some customized platforms).

Look at the specific time when anr occurs in systemlog, so that we can understand what the system process is doing at that time, and at the same time, we can simply take a look at what our specific process is doing.

3. Find the trcace file and see the stack of the process (the most important step)

From this screenshot, we first find the process main process with a pid of 1531 and see where the main process was stuck at that time.

From the point of view of the status native, the process is stuck in the native layer and does not return in time. From the stack point of view, the process is operating imagePlayerManager.init.

When the interprocess communication is carried out, the card owner in the native layer does not return in time.

So at this point, find the location of the corresponding stack in the code and see the specific time-consuming operation. Check the specific reason why the card owner did not return.

Avoid the occurrence of anr in the time-consuming operation position.

There are many other situations that lead to ANR, such as process deadloops, deadlocks, and time-consuming operations (network requests, image processing, database processing, etc.).

Follow-up to find classic cases to continue to supplement.

It is very important that trace files are needed to analyze ANR.

This is the answer to the question about how to carry out the ANR brief. I hope the above content can be of some help to you. If you still have a lot of doubts to solve, you can follow the industry information channel for more related knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report