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.
By default, BugSnag will treat crashes that occur during the first 5 seconds after starting BugSnag 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:
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 markLaunchCompleted()
is called.
void main() => bugsnag.start(
runApp: () => runApp(const MyFlutterApp()),
launchDurationMillis: 0,
);
// Once your app has finished launching
bugsnag.markLaunchCompleted();
If the previous run of your app crashed during app launch, BugSnag will block the calling thread for up to 2 seconds when it starts 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.
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.
final lastRunInfo = await bugsnag.getLastRunInfo();
if (lastRunInfo?.crashedDuringLaunch == true) {
// Enable "safe mode"
}
The BugsnagLastRunInfo
object contains the following properties;
property | type | description |
---|---|---|
consecutiveLaunchCrashes |
Number |
The number of consecutive runs that have ended with a crash while launching. |
crashed |
Boolean |
true if the previous run crashed. |
crashedDuringLaunch |
Boolean |
true if the previous run crashed while launching. |