Sounds plugin's MethodChannel will loose connection to the underlying FlutterEngine #46
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I recognised that I'll need to cross-post this issue on Flutter repo also, while I was still creating this Pull Request. Please keep it here just for a record. Better wait for Flutter team to response
I ran into an issue with Sounds when I used Android Alarm Manager plugin
invokeMethod
calling from Android won't be executed on the main appHow to reproduce, for instance, assume that we need to use AndroidAlarmManager for our Flutter app (it's actually thanks to that plugin that I found this bug)
await AndroidAlarmManager.initialize();
AndroidAlarmManager
is initialised, Sounds plugin will not be able to communicate with Dart code anymore, allinvokeMethod
calling from Android still being executed, but the Dart side won't be reached.I've spent some time to debug and found out that the method below of the main plugin class
will be called whenever a
FlutterEngine
got created, so it will triggered allonAttachedToEngine
on the Plugins registry (the auto generatedGeneratedPluginRegistrant
). This will cause Sounds to attach to the newly created background FlutterEngine.I have made some changes by following what have been done in Android Alarm Manager in handling this. I have tried to research the documents but doesn't seem like the Flutter doc mentioned anything relating to this. So, I'm not 100% sure this fix should be implemented on
Sounds
plugin or on theFlutterEngine
itself...PS: Android Studio automatically removed unused imports, I didn't recognise it until I were looking at the changed files below. It's a good change though I reckon?!