App Hangs

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

There are many reasons an app can become unresponsive, from long running code to an infinite loop bug, and this can be frustrating to the end user. With app hang tracking, you can detect and fix this problem.

The app hang detection integration has a default timeout of two (2) seconds, which means if the app becomes unresponsive for two seconds, an error event is created. The event has the stack trace of all running threads so you can easily detect where the problem occurred. The SDK reports an app hang immediately but doesn't report the exact duration because the watchdog could kill the app any time when blocking the main thread.

The app hangs code runs in the background when disabled when keeping out-of-memory tracking enabled, but it won't report app hangs. The out-of-memory tracking otherwise would report false errors if the OS kills your app caused by an app hang.

Because the app hang detection integration uses SentryCrashIntegration to capture the stack trace when creating app hang events, if SentryCrashIntegration is disabled, the integration won’t work.

To use this feature, add this to your code:

Copied
import Sentry

SentrySDK.start { options in
    options.dsn = "https://examplePublicKey@o0.ingest.sentry.io/0"
    options.enableAppHangTracking = true
}

If you want to change the timeout, you can do so by changing the appHangTimeoutInterval option:

Copied
import Sentry

SentrySDK.start { options in
    options.dsn = "https://examplePublicKey@o0.ingest.sentry.io/0"
    options.appHangTimeoutInterval = 1
}
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").