Identifying crashes at launch

If your app crashes whilst it is launching, you may want to give the crash more attention. Bugsnag provides an API to mark events that occur during startup and also allows you to detect recurrent launch crashes.

This documentation is for version 6 of the Bugsnag Unity notifier. If you are using older versions, we recommend upgrading to the latest release using our Upgrade guide. Documentation for the previous release can be found on our legacy pages.

Controlling the launch period

By default, Bugsnag will treat crashes that occur during the first 5 seconds after calling Bugsnag.Start() as having occurred during launch. Events that occur during the app launch have their App.IsLaunching property set to true.

To modify this launch time period, use the Launch Duration configuration option. You can also manually indicate that your app has finished launching:

You can also indicate that your app has finished launching by calling Bugsnag.MarkLaunchCompleted().

Bugsnag.MarkLaunchCompleted();

To disable the automatic ending of the launch period, set the Launch Duration configuration option to 0 — in this case the app will be considered to be launching until Bugsnag.MarkLaunchCompleted() is called.

var config = BugsnagSettingsObject.LoadConfiguration();
config.LaunchDurationMillis = 0;
Bugsnag.Start(config);

// Once your app has finished launching;
Bugsnag.MarkLaunchCompleted();

Sending launch crashes

Not available on Windows or WebGL.

If the previous run of your app crashed during launch, Bugsnag.Start() will block the calling thread for up to 2 seconds to allow the crash report to be sent before the app continues launching. In cases where a launch crash is persistent, this improves the reliability of crash reporting.

This behavior can be disabled using the SendLaunchCrashesSynchronously configuration option.

Recovering after launch crashes

Not available on Windows or WebGL.

After a launch crash, it may be appropriate to take some actions in your app, such as removing cached data or resetting some persistent state, to make another one less likely to occur.

var config = BugsnagSettingsObject.LoadConfiguration();
Bugsnag.Start(config);

if (Bugsnag.GetLastRunInfo().CrashedDuringLaunch) {
    // Enable "safe mode"
}

On Windows, WebGL or in the Unity Editor Bugsnag.GetLastRunInfo() will return null.

The LastRunInfo object contains the following properties;

property type description
ConsecutiveLaunchCrashes int The number of consecutive runs that have ended with a crash while launching.
Crashed bool true if the previous run crashed.
CrashedDuringLaunch bool true if the previous run crashed while launching.