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 5 of the BugSnag Unity notifier. We recommend upgrading to the latest release using our Upgrade guide. Documentation for the current release can be found here.
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.
You can modify the launch time period using the LaunchDurationMillis
configuration option.
Configuration config = new Configuration("your-api-key-here");
config.LaunchDurationMillis = 10000;
Bugsnag.Start(config);
You can also indicate that your app has finished launching by calling Bugsnag.MarkLaunchCompleted()
.
Bugsnag.MarkLaunchCompleted();
You can disable the automatic ending of the launch period by setting LaunchDurationMillis
to 0
- in this case the app will be considered to be launching until Bugsnag.MarkLaunchCompleted()
is called.
Configuration config = new Configuration("your-api-key-here");
config.LaunchDurationMillis = 0;
Bugsnag.Start(config);
// Once your app has finished launching;
Bugsnag.MarkLaunchCompleted();
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 behaviour can be disabled using the SendLaunchCrashesSynchronously
option.
Configuration config = new Configuration("your-api-key-here");
config.SendLaunchCrashesSynchronously = false;
Bugsnag.Start(config);
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.
Configuration config = new Configuration("your-api-key-here");
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. |