[firebase_crashlytics] Crashlytics cannot report every error by design #5757
Replies: 4 comments 5 replies
-
Beta Was this translation helpful? Give feedback.
-
|
cross-reference https://www.reddit.com/r/FlutterDev/comments/mpy2am/proper_flutter_error_reporting/ cc @Salakar What do you think of a void main() {
runCrashlyticsApp(
MyApp();
);
}which would take care of everything and fixes more advanced issues? |
Beta Was this translation helpful? Give feedback.
-
|
You can solve 1 with: void main() {
runZonedGuarded<Future<void>>(() async {
FlutterError.onError = (details) => FirebaseCrashlytics.instance.recordFlutterError(details);
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(CrashyApp());
}, (error, stackTrace) => FirebaseCrashlytics.instance.recordError(error, stackTrace));
}For 2, we can make Crashlytics independent from For |
Beta Was this translation helpful? Give feedback.
-
|
After thinking a bit, I don't think This solves simple use-cases, but people may put logic in their What I'm considering at the moment is: void main() {
startCrashlytics(() async {
await whatever;
runApp(MyApp();
});
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
From what we know from flutter/flutter#10761, flutter/website#5612 and the proposal flutter/flutter#34862, to catch all errors, there must be a few things set up.
FlutterError.onErrorcallback must be assigned.runApp()must be called inside runZoneGuarded.WidgetsFlutterBinding.ensureInitialized()must be the first thing called insiderunZoneGuardedBut if we try to implement Crashlytics the following way:
Few problems occur:
FlutterErroroccurs beforeonErroris assigned it won't be caught.Firebase.initializeApp()is finished, callingFirebaseCrashlytics.instance.recordErrorwill cause a Default app not initialised error.In this situation it looks like there can always be some errors which may be never caught.
Beta Was this translation helpful? Give feedback.
All reactions