Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion docs/platforms/react-native/common/configuration/app-hangs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sidebar_order: 11
description: "Learn about how to add app hang detection reporting."
---

This integration tracks app hangs. This feature is available on iOS, tvOS, and macOS.
This integration tracks app hangs. It's available on iOS, tvOS, and macOS, and on Android through NDK-based detection (see [App Hang Tracking on Android](#app-hang-tracking-on-android)).

Trying to use an unresponsive app is extremely frustrating for users. There are many reasons why an app may become unresponsive, such as long-running code, infinite loop bugs, and so on. With app hang tracking you can detect and fix them.

Expand All @@ -30,6 +30,31 @@ Sentry.init({
});
```

### App Hang Tracking on Android

The `enableAppHangTracking` and `appHangTimeoutInterval` options above apply to iOS, tvOS, and macOS. On Android, you can enable `sentry-native`'s heartbeat-based app hang detection with the `enableNdkAppHangTracking` option. This is independent of the JVM-based ANR detection and requires NDK to be enabled. It's disabled by default:

```javascript
import * as Sentry from "@sentry/react-native";

Sentry.init({
dsn: "DSN",
enableNdkAppHangTracking: true,
});
```

The default timeout is 5000 milliseconds. This represents the minimum amount of time the app can be unresponsive before it's classified as hanging. You can change the timeout by setting the `ndkAppHangTimeoutIntervalMillis` option:

```javascript
import * as Sentry from "@sentry/react-native";

Sentry.init({
dsn: "DSN",
enableNdkAppHangTracking: true,
ndkAppHangTimeoutIntervalMillis: 3000,
});
```

### Pause and Resume App Hang Tracking (iOS only)

Starting with version 8.13.0, you can pause and resume app hang tracking at runtime. This is useful when showing system dialogs (for example, permission prompts) that block the main thread but aren't real app hangs.
Expand Down
12 changes: 12 additions & 0 deletions docs/platforms/react-native/common/configuration/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,18 @@ When enabled, ANR events whose stacktraces contain only system frames (for examp

</SdkOption>

<SdkOption name="enableNdkAppHangTracking" type="boolean" defaultValue="false">

Set this boolean to `true` to enable `sentry-native`'s heartbeat-based app hang detection on Android. This is independent of the JVM-based ANR detection and requires NDK to be enabled. Use `ndkAppHangTimeoutIntervalMillis` to configure the threshold.

</SdkOption>

<SdkOption name="ndkAppHangTimeoutIntervalMillis" type="number" defaultValue="5000">

The minimum amount of time (in milliseconds) an app must be unresponsive before it's classified as an app hang when using NDK app hang detection on Android. Only has an effect if `enableNdkAppHangTracking` is `true`.

</SdkOption>

<SdkOption name="enableAutoPerformanceTracing" type="boolean" defaultValue="true">

Set this boolean to `false` to disable auto [performance monitoring](/product/dashboards/sentry-dashboards/) tracking.
Expand Down
Loading