bugsnag / bugsnag-flutter

BugSnag crash reporting for Flutter apps
https://docs.bugsnag.com/platforms/flutter/
MIT License
10 stars 8 forks source link

Zone Mismatch #200

Closed behnamsattar closed 1 year ago

behnamsattar commented 1 year ago

Starting from Flutter 3.10.0, there is a check for a "Zone Mismatch". Considering that bugsnag.start() creates a new zone, in cases where user wants to run WidgetsFlutterBinding.ensureInitialized(); there is a need to access the same zone. Otherwise, there will be zone mismatch error thrown.

Steps to reproduce

  1. Create a new Flutter application using version ^3.10.0.
  2. In the main method, add: dart``` WidgetsFlutterBinding.ensureInitialized(); bugsnag.start(...);
  3. Run the app and observe the framework error.

Environment

Error messages: ``` ════════ Exception caught by Flutter framework ═════════════════════════════════ The following assertion was thrown during runApp: Zone mismatch. The Flutter bindings were initialized in a different zone than is now being used. This will likely cause confusion and bugs as any zone-specific configuration will inconsistently use the configuration of the original binding initialization zone or this zone based on hard-to-predict factors such as which zone was active when a particular callback was set. It is important to use the same zone when calling `ensureInitialized` on the binding as when calling `runApp` later. To make this warning fatal, set BindingBase.debugZoneErrorsAreFatal to true before the bindings are initialized (i.e. as the first statement in `void main() { }`). When the exception was thrown, this was the stack #0 BindingBase.debugCheckZone. binding.dart:497åc #1 BindingBase.debugCheckZone binding.dart:502 #2 runApp binding.dart:1080 #3 main. main.dart:120 #4 Bugsnag.attach. client.dart:631 #5 Bugsnag._runWithErrorDetection. client.dart:764 #10 Bugsnag._runWithErrorDetection client.dart:763 #11 Bugsnag.attach client.dart:629 (elided 4 frames from dart:async) ════════════════════════════════════════════════════════════════════════════════ ```
johnkiely1 commented 1 year ago

Hi @behnamsattar , it looks like this is a duplicate of https://github.com/bugsnag/bugsnag-flutter/issues/197, closing this in favor of that one.