bkonyi / FlutterGeofencing

Rough work for Flutter geofencing plugin
BSD 3-Clause "New" or "Revised" License
338 stars 220 forks source link

MissingPluginException on hot restart #26

Closed tashiwangdi closed 4 years ago

tashiwangdi commented 4 years ago

@bkonyi : Thank you for adding the fix for crash on hot restart. The fix for the issue - https://github.com/bkonyi/FlutterGeofencing/issues/24 fixes the crash. However, there is this MissingPluginException on hot restart that we have been struggling to get rid of. We tried the same approach to avoid the crash in our swift version but this MissingPluginException won't budge. Here is the stacktrace:

Performing hot restart...
Syncing files to device tashi’s iPhone...
flutter: Initializing...
Restarted application in 1,476ms.
flutter: Initializing...
flutter: Initialization done
[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: MissingPluginException(No implementation found for method GeofencingPlugin.initializeService on channel plugins.flutter.io/geofencing_plugin)
#0      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:314:7)
<asynchronous suspension>
#1      GeofencingManager.initialize (package:geofencing/src/geofencing.dart:108:20)
<asynchronous suspension>
#2      _MyAppState.initPlatformState (package:geofencing_example/main.dart:62:29)
<asynchronous suspension>
#3      _MyAppState.initState (package:geofencing_example/main.dart:49:5)
#4      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4068:58)
#5      ComponentElement.mount (package:flutter/src/widgets/framework.dart:3919:5)
#6      Element.inflateWidget (package:flutter/src/widgets/framework.dart:3101:14)
#7      Element.updateChild (package:flutter/src/widgets/framework.dart:2904:12)
#8      RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:998:16)
#9      RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:969:5)
#10     RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous closure> (package:flutter/src/widgets/binding.dart:915:17)
#11     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2328:19)
#12     RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:914:13)
#13     WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:795:7)
#14     runApp (package:flutter/src/widgets/binding.dart:845:7)
#15     main (package:geofencing_example/main.dart:12:16)
#16     _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:229:25)
#17     _rootRun (dart:async/zone.dart:1124:13)
#18     _CustomZone.run (dart:async/zone.dart:1021:19)
#19     _runZoned (dart:async/zone.dart:1516:10)
#20     runZoned (dart:async/zone.dart:1500:12)
#21     _runMainZoned.<anonymous closure> (dart:ui/hooks.dart:221:5)
#22     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:305:19)
#23     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)
bkonyi commented 4 years ago

Do you have a link to a repository I can look at? That channel should always be available after a hot restart since the native iOS state doesn't get reset. I'm also not seeing that in the Obj-C implementation so I suspect something is different in your implementation.

tashiwangdi commented 4 years ago

I checked out your repo and installed the example app. I will check again to see if I ran the correct example or something missing/wrong in my setup. Sorry if my comment was confusing.

tashiwangdi commented 4 years ago

I just checked the repo url:

tashis-mbp:ios tashiwangdi$ git config --get remote.origin.url
git@github.com:bkonyi/FlutterGeofencing.git
bkonyi commented 4 years ago

When you say "Swift version" do you mean an implementation of this plugin in Swift or that your Flutter application uses Swift?

tashiwangdi commented 4 years ago

We ran the example app in your repo - https://github.com/bkonyi/FlutterGeofencing and encountered the MissingPluginException. The stacktrace above is for the same example app.

tashiwangdi commented 4 years ago

@bkonyi : Could this comment be related - https://github.com/flutter/flutter/issues/12956#issuecomment-343309685 ? This one talks about android but could the statement - life span of the Dart isolate is 1-1 with that of the FlutterView be related in this case? Please pardon my ignorance if it is completely out of context.

bkonyi commented 4 years ago

@tashiwangdi sorry for the delay, I've been OOO for a few days. I'll take a closer look sometime in the next day or two.

tashiwangdi commented 4 years ago

Thanks for getting back @bkonyi . Eager to know about your observations on the same.

zeienko-vitalii commented 4 years ago

Hello, @bkonyi ! Is there any updates ? Facing the same issue iPhone 7+, iOS 11.4.1

Flutter (Channel stable, v1.9.1+hotfix.6, on Mac OS X 10.15.1 19B88)
    • Flutter version 1.9.1+hotfix.6
    • Framework revision 68587a0916 (3 months ago), 2019-09-13 19:46:58 -0700
    • Engine revision b863200c37
    • Dart version 2.5.0
bkonyi commented 4 years ago

Sorry all, I've been pretty swamped the past few weeks. I'll investigate this weekend, I promise!

bkonyi commented 4 years ago

Hi all, thanks for your patience. I've just tried a hot restart in the example application and I don't seem to be running into the same error, at least on the simulator (don't have access to an actual device at the moment). Do you happen to have code that I can try to use to reproduce myself?

JFreakDK commented 4 years ago

Hi @bkonyi. Nice that you looked into it. Which version of Flutter did you use? IIRC We tested with v1.9.1+hotfix.6 from the stable channel. Maybe something was fixed in the latest release? I don't have access to a Mac at the moment. We can retest this next week.

bkonyi commented 4 years ago

Hi @bkonyi. Nice that you looked into it. Which version of Flutter did you use? IIRC We tested with v1.9.1+hotfix.6 from the stable channel. Maybe something was fixed in the latest release? I don't have access to a Mac at the moment. We can retest this next week.

Hm, I'm doubtful that something has been fixed but it might be worth updating to at least v1.12 on stable and giving that a shot. I tested this on master last week on an iOS simulator, so this could potentially be something that's only reproducible on a physical device. In that case, I'll have to try when I get back to the office next week and find my iOS device.

tashiwangdi commented 4 years ago

@bkonyi : We upgraded to latest stable - 1.12.13+hotfix.5 and it works now on both physical as well as the simulator. Closing the issue. Thank you for looking into this.