Crash-Free Sessions for Flutter
Overview
In Flutter, unhandled exceptions can be thrown from two sides:
- Native Side
- Dart/Flutter Side
User Exceptions
Native Exceptions
When a native exception occurs:
- The app crashes.
- The user needs to reopen the app.
- A crash report is sent to the Instabug dashboard.
![](https://files.readme.io/382d33f-Flutter_Native_Crash.gif)
Flutter Exceptions
When a Flutter exception occurs:
- The app does not crash; the user can continue their flow.
- The user may reach a point where the app becomes unresponsive (e.g., a button stops working).
- A crash report is sent to the Instabug dashboard.
![](https://files.readme.io/babd38f-Flutter_Crashes.gif)
Crash-Free Sessions Calculation
Crash-Free sessions are calculated as follows:
- Crash Rate = (Total number of crash occurrences) / (Total number of sessions)
- Crash-Free Sessions = 100% - Crash Rate
Common Issue: Low Crash-Free Session Rate on Flutter
A low crash-free session rate can occur because:
- A single session might have multiple Flutter crashes.
- Flutter crashes do not terminate the session, leading to multiple crash reports within the same session.
User Frustration
Users may become frustrated when the app doesn't respond rather than crashing. To mitigate this:
- Terminate the App (Force a Crash):
- Use exit(0) to forcefully close the app.
- Display a Recoverable Error Alert:
- Show an alert message, such as "A problem happened here," to inform the user of the issue.
Summary of Exception Handling
Native Exceptions
- User Experience: App crashes, user reopens the app.
- Reporting: Native Stacktrace is collected and sent to Instabug.
- Impact: One session can contain only one crash.
Dart/Flutter Exceptions
- User Experience: App does not crash but becomes unresponsive.
- Reporting: Dart Stacktrace is collected and sent to Instabug.
- Impact: One session can contain multiple crashes.
For more details on managing exceptions and improving crash-free sessions, refer to the Instabug documentation.
Updated 2 months ago