diff --git a/ios/Classes/FlutterIsolatePlugin.m b/ios/Classes/FlutterIsolatePlugin.m index 2d679af..b65a6d8 100644 --- a/ios/Classes/FlutterIsolatePlugin.m +++ b/ios/Classes/FlutterIsolatePlugin.m @@ -68,26 +68,17 @@ - (void)startNextIsolate { FlutterCallbackInformation *info = [FlutterCallbackCache lookupCallbackInformation:isolate.entryPoint]; - 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 - [isolate.engine initWithName:isolate.isolateId project:nil]; - } + isolate.engine = [[self.engineGroup makeEngineWithEntrypoint:info.callbackName libraryURI:info.callbackLibraryPath] + initWithName:isolate.isolateId project:nil allowHeadlessExecution:YES]; - /* 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. */ + // 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]; + isolate.controlChannel = [FlutterMethodChannel methodChannelWithName:FLUTTER_ISOLATE_NAMESPACE @"/control" binaryMessenger:isolate.engine.binaryMessenger]; - isolate.startupChannel = [FlutterEventChannel eventChannelWithName:FLUTTER_ISOLATE_NAMESPACE @"/event" - binaryMessenger:isolate.engine]; + isolate.startupChannel = [FlutterEventChannel eventChannelWithName:FLUTTER_ISOLATE_NAMESPACE @"/event" binaryMessenger:isolate.engine.binaryMessenger]; [isolate.startupChannel setStreamHandler:self]; [_registrar addMethodCallDelegate:self channel:isolate.controlChannel]; diff --git a/macos/Classes/FlutterIsolatePluginMacOS.m b/macos/Classes/FlutterIsolatePluginMacOS.m index 0377c2a..71575f0 100644 --- a/macos/Classes/FlutterIsolatePluginMacOS.m +++ b/macos/Classes/FlutterIsolatePluginMacOS.m @@ -79,7 +79,6 @@ - (void)startNextIsolate * then this will be a race on the FlutterEventChannels initialization, and could deadlock. */ [isolate.engine runWithEntrypoint:@"_flutterIsolateEntryPoint"]; - isolate.controlChannel = [FlutterMethodChannel methodChannelWithName:FLUTTER_ISOLATE_NAMESPACE @"/control" binaryMessenger:isolate.engine.binaryMessenger]; @@ -87,6 +86,7 @@ - (void)startNextIsolate binaryMessenger:isolate.engine.binaryMessenger]; [isolate.startupChannel setStreamHandler:self]; + [_registrar addMethodCallDelegate:self channel:isolate.controlChannel]; [[FlutterIsolatePluginMacOS lookupGeneratedPluginRegistrant] registerWithRegistry:isolate.engine];