diff --git a/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm b/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm index 8232fe100167c..613cdfaa73973 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm @@ -218,6 +218,12 @@ static BOOL DoesHardwareSupportWideGamut() { settings.leak_vm = leakDartVM.boolValue; } + NSNumber* enableMergedPlatformUIThread = + [mainBundle objectForInfoDictionaryKey:@"FLTEnableMergedPlatformUIThread"]; + if (enableMergedPlatformUIThread != nil) { + settings.merged_platform_ui_thread = enableMergedPlatformUIThread.boolValue; + } + #if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG // There are no ownership concerns here as all mappings are owned by the // embedder and not the engine. diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm index d5b69257f7173..8ab4cf61c0ac3 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm @@ -706,7 +706,7 @@ + (NSString*)generateThreadLabel:(NSString*)labelPrefix { fml::MessageLoop::EnsureInitializedForCurrentThread(); uint32_t threadHostType = flutter::ThreadHost::Type::kRaster | flutter::ThreadHost::Type::kIo; - if (!settings.enable_impeller) { + if (!settings.enable_impeller || !settings.merged_platform_ui_thread) { threadHostType |= flutter::ThreadHost::Type::kUi; } @@ -795,7 +795,7 @@ - (BOOL)createShell:(NSString*)entrypoint [](flutter::Shell& shell) { return std::make_unique(shell); }; fml::RefPtr ui_runner; - if (settings.enable_impeller) { + if (settings.enable_impeller && settings.merged_platform_ui_thread) { ui_runner = fml::MessageLoop::GetCurrent().GetTaskRunner(); } else { ui_runner = _threadHost->ui_thread->GetTaskRunner(); diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm index 2e044dd4b9830..ddc18c542969a 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm @@ -472,16 +472,17 @@ - (void)testCanMergePlatformAndUIThread { #endif // defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR } -- (void)testCanNotUnMergePlatformAndUIThread { +- (void)testCanUnMergePlatformAndUIThread { #if defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR auto settings = FLTDefaultSettingsForBundle(); settings.enable_impeller = true; + settings.merged_platform_ui_thread = false; FlutterDartProject* project = [[FlutterDartProject alloc] initWithSettings:settings]; FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar" project:project]; [engine run]; - XCTAssertEqual(engine.shell.GetTaskRunners().GetUITaskRunner(), - engine.shell.GetTaskRunners().GetPlatformTaskRunner()); + XCTAssertNotEqual(engine.shell.GetTaskRunners().GetUITaskRunner(), + engine.shell.GetTaskRunners().GetPlatformTaskRunner()); #endif // defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR }