Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions ios/Classes/FlutterIsolatePlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ @implementation IsolateHolder

@interface FlutterIsolatePlugin()
@property(nonatomic) NSObject<FlutterPluginRegistrar> * registrar;
@property(nonatomic) FlutterEngineGroup* engineGroup;
@property(nonatomic) FlutterMethodChannel* controlChannel;
@property FlutterEventSink sink;
@end
Expand All @@ -39,6 +40,8 @@ + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
FlutterIsolatePlugin *plugin = [[FlutterIsolatePlugin alloc] init];

plugin.registrar = registrar;

plugin.engineGroup = [[FlutterEngineGroup alloc] initWithName:@"flutter_isolate" project:nil];

plugin.controlChannel = [FlutterMethodChannel methodChannelWithName:FLUTTER_ISOLATE_NAMESPACE @"/control"
binaryMessenger:[registrar messenger]];
Expand All @@ -65,20 +68,21 @@ - (void)startNextIsolate {

FlutterCallbackInformation *info = [FlutterCallbackCache lookupCallbackInformation:isolate.entryPoint];

isolate.engine = [FlutterEngine alloc];
isolate.engine = [self.engineGroup makeEngineWithEntrypoint:info.callbackName libraryURI:info.callbackLibraryPath];

if ([isolate.engine respondsToSelector:@selector(initWithName:project:allowHeadlessExecution:)]) {
// use headless execution, if we can
((id(*)(id,SEL,id,id,id))objc_msgSend)(isolate.engine, @selector(initWithName:project:allowHeadlessExecution:) , isolate.isolateId, nil, @(YES));
}
else // older versions before above is available
} else {
// older versions before above is available
[isolate.engine initWithName:isolate.isolateId project:nil];

}

/* not entire sure if a listen on an event channel will be queued
* as we cannot register the event channel until after runWithEntryPoint has been called. If it is not queued
* then this will be a race on the FlutterEventChannels initialization, and could deadlock. */
[isolate.engine runWithEntrypoint:info.callbackName libraryURI:info.callbackLibraryPath];


isolate.controlChannel = [FlutterMethodChannel methodChannelWithName:FLUTTER_ISOLATE_NAMESPACE @"/control"
binaryMessenger:isolate.engine];

Expand Down