newrelic / newrelic-flutter-agent

New Relic agent SDK for Flutter hybrid mobile apps
Apache License 2.0
6 stars 12 forks source link

Zoned Guard issue #64

Closed everfinal88 closed 7 months ago

everfinal88 commented 11 months ago

Been getting this exception after adding new relic 1.0.4. After some research, it seem like the zone guard is deprecated starting with Flutter 3.10.

Here are some references :

So far, the app can still run properly but i'm not sure if this issue might get problematic in the future. I'm hoping I can get some answer or possible future update about this issue. Thanks.

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() { }).

ndesai-newrelic commented 11 months ago

@everfinal88 we will check this and we will fix this in future release.

asegurola commented 10 months ago

@everfinal88 I managed to get rid of the error by using the "alternative" method # 2 described in the "Flutter Setup" plugin readme section and making sure that ensureInitialized is happening in the same zone as the newrelic startAgent() method call.

So basically image

everfinal88 commented 10 months ago

@asegurola Thanks, the error went away. I guess I missed the alternative method. Since @ndesai-newrelic said will update this in the future so I'm not sure I should close this issue or not.

I'll leave the "close" decision to him or any new relic dev. Thanks.

ndesai-newrelic commented 8 months ago

@everfinal88 Is the line "WidgetsFlutterBinding.ensureInitialized();" present in your main function? There is no need to include the line "WidgetsFlutterBinding.ensureInitialized();" in your main function because it is already handled and initialized within the New Relic Start function. Please refer this article for this error. Zone Mismatch Issue