App Hangs

Learn about how to add app hang detection reporting.

This integration tracks app hangs. This feature is available on iOS, tvOS, and macOS.

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.

Every time an App Hang is detected Sentry creates an error event. App Hang Tracking is enabled by default. To disable it, set the enableAppHangTracking option to false:

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

Sentry.init({
  dsn: "DSN",
  enableAppHangTracking: false,
});

The app hang detection integration has a default timeout of two (2) seconds. This represents the minimum amount of time an app can be unresponsive before it is classified as hanging. You can change the timeout by setting the appHangTimeoutInterval option:

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

Sentry.init({
  dsn: "DSN",
  appHangTimeoutInterval: 1,
});

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.

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

Sentry.pauseAppHangTracking();

// Do something that might cause the app to hang,
// and you don't want the SDK to report it.

Sentry.resumeAppHangTracking();

To read more about how app hangs are detected, check out the sentry-cocoa documentation.

On iOS 15 and up, the operating system can also report hangs through MetricKit. These are separate from the app hangs described above, and the SDK reports them only if you enable the MetricKit integration. If you enable both, a single unresponsive period may be reported twice, once from each source.

Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").