Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android): Add ANR docs around root cause analysis #7180

Merged
merged 11 commits into from
Jun 16, 2023
Merged
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 24 additions & 2 deletions src/platforms/android/configuration/app-not-respond.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Both ANR detection implementations are controlled by the same flag:
</application>
```

## Watchdog (v1)
### Watchdog (v1)

Whenever the main UI thread of the application is blocked for more than five seconds, the SDK will report the problem to the server.

Expand All @@ -47,11 +47,33 @@ You can also specify how long the thread should be blocked before the ANR is rep
</application>
```

## ApplicationExitInfo (v2)
### ApplicationExitInfo (v2)

This approach reads the [ApplicationExitInfo](https://developer.android.com/reference/android/app/ApplicationExitInfo) API on the next app launch
and asynchronously sends ANR events to Sentry for each ANR in the history, enriching only the latest one with breadcrumbs, contexts, tags, etc.

The integration reports ANR events with `mechanism:AppExitInfo`.

![ANR](app-not-respond.png)

## ANR Root Cause Analysis

Sentry performs various root cause analyses to give you insights about why certain ANRs might appear. If a potential root cause is detected, it'll be displayed in a new section underneath the ANR stacktrace. Sentry is capable of detecting the following root causes:

romtsn marked this conversation as resolved.
Show resolved Hide resolved
### Performance Issues

If an ANR is connected to one of the Performance Issues detected by Sentry (for example, [File I/O on Main Thread](https://docs.sentry.io/product/issues/issue-details/performance-issues/file-main-thread-io/) or [DB on Main Thread](https://docs.sentry.io/product/issues/issue-details/performance-issues/db-main-thread-io/)), the offending span will be linked to the ANR event, showing you exactly which slow operation contributed to this ANR.

![ANR Root Cause File I/O](anr-rootcause-fileio.png)
romtsn marked this conversation as resolved.
Show resolved Hide resolved

### Common Patterns

This detector looks at the stacktrace of the ANR and tries to identify common pitfalls, such as accessing files, assets or heavy resources on the main thread. If an offending stack frame is found, it will be highlighted in the stacktrace alongside some materials on how to prevent this type of ANR:

romtsn marked this conversation as resolved.
Show resolved Hide resolved
![ANR Root Cause Suspect Frame](anr-rootcause-frame.png)

### Deadlock Detection

Sentry will try to detect deadlocks and point out potential reasons. If, for example, the main thread is blocked waiting on a lock object held by another thread, the suspect frame that is waiting on the lock will be highlighted. Additionally, the stacktrace of the offending thread that is holding the lock will be shown, as well as the offending frame of that thread:

romtsn marked this conversation as resolved.
Show resolved Hide resolved
![ANR Root Cause Deadlock](anr-rootcause-deadlock.png)