Skip to content

Commit bde17b2

Browse files
romtsnshanamatthewsgetsantry[bot]
authored
feat(android): Add docs for new ANR implementation (#6973)
Co-authored-by: Shana Matthews <[email protected]> Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
1 parent 7261538 commit bde17b2

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

src/platforms/android/configuration/app-not-respond.mdx

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,50 @@ sidebar_order: 3
44
description: "Learn how to turn off or specify ANR."
55
---
66

7-
Whenever the main UI thread of the application is blocked for more than five seconds, the SDK will report the problem to the server.
7+
The Android SDK uses different implementations to detect ANRs, depending on what version of Android the device is running:
8+
9+
- Below Android 11: Running a Watchdog thread (v1)
10+
- Android 11 and above: Reading [ApplicationExitInfo](https://developer.android.com/reference/android/app/ApplicationExitInfo) (v2)
11+
12+
The new implementation (v2) uses the same data source as Google Play Console. This means the reported ANR events and [ANR rate](/platforms/android/performance/instrumentation/performance-metrics/#application-not-responding-anr-rate) should match with what you see on Sentry. The new implementation also captures a thread dump with additional information, like held locks, to help you resolve ANRs more efficiently.
13+
14+
While the original Watchdog approach (v1) reports many false positives and is based on heuristics, it still has some advantages over v2, like capturing screenshots and transactions with profiles at the time of ANR.
815

916
<Note>
1017

11-
Sentry does not report the ANR if the application is in debug mode.
18+
We're considering SDK support for both approaches working alongside each other on Android 11 and up. Please upvote [this GitHub discussion](https://github.com/getsentry/sentry-java/discussions/2716) and share your feedback if you have a case for v1 and v2 working together.
1219

1320
</Note>
1421

15-
You can turn off monitoring the ANR by adding the following to your `AndroidManifest.xml`:
22+
Both ANR detection implementations are controlled by the same flag:
1623

1724
```xml {filename:AndroidManifest.xml}
1825
<application>
1926
<meta-data android:name="io.sentry.anr.enable" android:value="false" />
2027
</application>
2128
```
2229

30+
## Watchdog (v1)
31+
32+
Whenever the main UI thread of the application is blocked for more than five seconds, the SDK will report the problem to the server.
33+
34+
<Note>
35+
36+
Sentry does not report the ANR if the application is in debug mode.
37+
38+
</Note>
39+
2340
You can also specify how long the thread should be blocked before the ANR is reported. Provide the duration in the attribute `io.sentry.anr.timeout-interval-millis` in your `AndroidManifest.xml`:
2441

2542
```xml {filename:AndroidManifest.xml}
2643
<application>
2744
<meta-data android:name="io.sentry.anr.timeout-interval-millis" android:value="2000" />
2845
</application>
2946
```
47+
48+
## ApplicationExitInfo (v2)
49+
50+
This approach reads the [ApplicationExitInfo](https://developer.android.com/reference/android/app/ApplicationExitInfo) API on the next app launch
51+
and asynchronously sends ANR events to Sentry for each ANR in the history, enriching only the latest one with breadcrumbs, contexts, tags, etc.
52+
53+
![ANR](app-not-respond.png)
Loading

0 commit comments

Comments
 (0)