When your app fails to respond to interactions in real time it causes user frustration and can lead them to abandon your app altogether.
An app hang or freeze is a specific instance of the main thread failing to respond in a reasonable amount of time and can be caused by performing CPU intensive work or performing blocking I/O on the main thread. If your app hangs for 10 seconds or longer, it may be terminated by the system watchdog as described in Apple’s documentation.
BugSnag automatically captures the stack trace of the main thread if an app hang is detected and ends with termination by the system watchdog or being force-quit by the user, helping you to identify the underlying cause. You can also report non-fatal app hangs (i.e. hangs that did not result in the app being killed) by configuring a minimum threshold hang duration.
App hangs that end with termination by the system watchdog or being force-quit by the user are considered to be “fatal”. By default BugSnag reports these types of app hangs when a threshold of 2000ms is exceeded.
The system watchdog does not terminate apps launched by Xcode.
Fatal app hangs are sent to your BugSnag dashboard when the app next launches.
To enable reporting of non-fatal app hangs, set
appHangThresholdMillis to a number of milliseconds. It can be configured to a minimum of 250 milliseconds (0.25 seconds). This threshold applies to both fatal and non-fatal app hangs and is used by BugSnag to prepare an app hang event report when it is exceeded; if the app subsequently recovers from the hang, a non-fatal hang is reported.
BugsnagConfiguration *config = [BugsnagConfiguration loadConfig]; config.appHangThresholdMillis = 5000; [Bugsnag startWithConfiguration:config];
let config = BugsnagConfiguration.loadConfig() config.appHangThresholdMillis = 5000 Bugsnag.start(with: config)
To enable reporting of app hangs that occur while an app is running in the background, set
reportBackgroundAppHangs to true.
By default BugSnag does not report these hangs because some operating system functions are known to hang in response to an app entering the background.
BugsnagConfiguration *config = [BugsnagConfiguration loadConfig]; config.reportBackgroundAppHangs = YES; [Bugsnag startWithConfiguration:config];
let config = BugsnagConfiguration.loadConfig() config.reportBackgroundAppHangs = true Bugsnag.start(with: config)
BugSnag’s App hang detection can be completely disabled by setting the Enabled Error Types configuration option.
BugsnagConfiguration *config = [BugsnagConfiguration loadConfig]; config.enabledErrorTypes.appHangs = NO; [Bugsnag startWithConfiguration:config];
let config = BugsnagConfiguration.loadConfig() config.enabledErrorTypes.appHangs = false Bugsnag.start(with: config)