App Not Responding (ANR)

Learn how to turn off or specify ANR.

Application Not Responding (ANR) errors are triggered when the Unity thread of the game is blocked for more than five seconds. The Unity SDK reports ANR errors as Sentry events.

The ANR detection in the Unity SDK strictly works within the Unity game, irrespective of the targeted platform and works in two parts. First the SDK starts a coroutine that periodically notes the time it last got called. Second, a background thread checks the time since the last update against the ANR threshold from the options. The detection is sensitive of the app losing and regaining focus and gets paused accordingly. It is also using WaitForSecondsRealtime so pausing your game by modifying the Time.timeScale will not trigger false ANR reports.

On platforms that do no support multithreading the ANR detection falls back to relying on the coroutine itself to report if the last time it executed exceeds the timeout.

Since the ANR integration creates an exception on a background thread, based on a coroutine not resetting in time, the stack trace will not show the main thread's stack trace.

Since the Unity SDKs line number support is limited to actually thrown exceptions, the integration does not provide you with line numbers in the captured ANR issues.

ANR detection is enabled by default in Sentry, but you can opt-out through the editor window by going to Tools -> Sentry -> Advanced -> ANR Detection. You can also set the ANR timeout there.

ANR Detection

You can also opt out by disabling the integration.

Copied
options.DisableAnrIntegration();

To set the timeout use the following snippet.

Copied
options.AnrTimeout = TimeSpan.FromSeconds(5);
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").