App Not Responding (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, ireespecitve 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.
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.
You can also opt out by disabling the integration.
options.DisableAnrIntegration();
To set the timeout use the following snippet.
options.AnrTimeout = TimeSpan.FromSeconds(5);
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").
- Package:
- upm:sentry-unity
- Version:
- 2.0.4
- Repository:
- https://github.com/getsentry/sentry-unity