After #13937, platform channels work on background isolates. Plugins should work as well, but if a plugin relies on a dart plugin registrant (example
shared_preferences usage to set the platform_interface subclass) the registrant isn't executed on the background isolate, so the plugin doesn't function correctly. Specifically there aren't handlers registered for the platform channels.
The solution should be to execute the Dart plugin registrant on the background isolate when it registers with the root isolate.
I tried the naive solution of calling
PlatformConfigurationNativeApi::RegisterBackgroundIsolate but oddly crashes. Ideally we can fix this under the covers so
BackgroundIsolateBinaryMessenger.ensureInitialized calls the registrant.
Does calling the Dart plugin ensure-initialized method (I forget the exact name) from the Dart side work?
Are you talking about calling the generated dart code directly? The generated code is private (
class _PluginRegistrant), I wonder if I may have to end up exposing a function that is calling it. I don't know if there already is one. I didn't see one.
I suspect the crash on the c++ solution may be something weird about jumping back into dart after dart calls c++ (ie Dart-> C++-> Dart ).
|Issue Title||Created Date||Updated Date|