Skip to content

Commit 04242f7

Browse files
authored
feat(Unity): ANR (#7537)
1 parent 28bc405 commit 04242f7

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: App Not Responding (ANR)
3+
sidebar_order: 20
4+
description: "Learn how to turn off or specify ANR."
5+
---
6+
7+
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.
8+
9+
## ANR Implementation Details
10+
11+
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.
12+
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.
13+
14+
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.
15+
16+
## Configuration
17+
18+
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.
19+
20+
![ANR Detection](unity-anr.jpg)
21+
22+
You can also opt out by disabling the integration.
23+
24+
```csharp
25+
options.DisableAnrIntegration();
26+
```
27+
28+
To set the timeout use the following snippet.
29+
30+
```csharp
31+
options.AnrTimeout = TimeSpan.FromSeconds(5);
32+
```
90.2 KB
Loading

0 commit comments

Comments
 (0)