[engine] add back opt out for merged thread mode. (flutter/engine#56242)

Leave an opt out in the engine for iOS as well. This will give developers an escape hatch in case there are problems we miss...
This commit is contained in:
Jonah Williams
2024-10-30 13:00:22 -07:00
committed by GitHub
parent d24eb30b3d
commit b1b224f8e8
3 changed files with 12 additions and 5 deletions

View File

@@ -218,6 +218,12 @@ flutter::Settings FLTDefaultSettingsForBundle(NSBundle* bundle, NSProcessInfo* p
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.

View File

@@ -706,7 +706,7 @@ static flutter::ThreadHost MakeThreadHost(NSString* thread_label,
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 @@ static void SetEntryPoint(flutter::Settings* settings, NSString* entrypoint, NSS
[](flutter::Shell& shell) { return std::make_unique<flutter::Rasterizer>(shell); };
fml::RefPtr<fml::TaskRunner> 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();

View File

@@ -472,16 +472,17 @@ FLUTTER_ASSERT_ARC
#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
}