flutter_isolate
flutter_isolate copied to clipboard
Another flutter engine is created..
Though it's an awesome solution to make the isolates support the plugins or channels , the solution seems to create a new flutter engine then mark it as the root isolate , all the messages or operations will be finished on it. So I guess it may raise some memory issues if two engines exists at the same time....
yes, its probably not ideal. Although I don't know how much memory launching another engine actually uses, I suspect there is a lot of stuff loaded that doesn't need to be and is left unused. Unfortunately there is nothing more granular in the api that I could see for launching dart code in another isolate.
I have also wondered whether a FlutterEngine is actually needed - in theory it should be possible to spawn a plain Dart isolate and just hook up the corresponding plugin channels manually. This would avoid all the overhead associated with an actual FlutterEngine, but would obviously require care to ensure that any spawned isolates do not assume the existence of any engine-specific behaviour.
If anyone wants to look into this, PRs are welcome.
Note this is separate from the work here https://github.com/rmawatson/flutter_isolate/issues/73 - using FlutterEngineGroup still spawns a FlutterEngine, even if it's slightly lighter weight.