diff --git a/common/settings.h b/common/settings.h index a62f1b44a82cb..0145f705b6aa1 100644 --- a/common/settings.h +++ b/common/settings.h @@ -229,6 +229,9 @@ struct Settings { bool enable_impeller = false; #endif + // Log a warning during shell initialization if Impeller is not enabled. + bool warn_on_impeller_opt_out = false; + // The selected Android rendering API. AndroidRenderingAPI android_rendering_api = AndroidRenderingAPI::kSkiaOpenGLES; diff --git a/shell/common/shell.cc b/shell/common/shell.cc index 8673f4e5c5515..a9a23d39ba3b3 100644 --- a/shell/common/shell.cc +++ b/shell/common/shell.cc @@ -450,6 +450,14 @@ Shell::Shell(DartVMRef vm, weak_factory_(this) { FML_CHECK(!settings.enable_software_rendering || !settings.enable_impeller) << "Software rendering is incompatible with Impeller."; + if (!settings.enable_impeller && settings.warn_on_impeller_opt_out) { + FML_LOG(IMPORTANT) + << "[Action Required] The application opted out of Impeller by either " + "using the --no-enable-impeller flag or FLTEnableImpeller=false " + "plist flag. This option is going to go away in an upcoming Flutter " + "release. Remove the explicit opt-out. If you need to opt-out, " + "report a bug describing the issue."; + } FML_CHECK(vm_) << "Must have access to VM to create a shell."; FML_DCHECK(task_runners_.IsValid()); FML_DCHECK(task_runners_.GetPlatformTaskRunner()->RunsTasksOnCurrentThread()); diff --git a/shell/common/shell_unittests.cc b/shell/common/shell_unittests.cc index 0046376bd0ca4..7754267f1e006 100644 --- a/shell/common/shell_unittests.cc +++ b/shell/common/shell_unittests.cc @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include #define FML_USED_ON_EMBEDDER #include @@ -10,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -4916,6 +4916,28 @@ TEST_F(ShellTest, RuntimeStageBackendWithImpeller) { } #endif // IMPELLER_SUPPORTS_RENDERING +TEST_F(ShellTest, WillLogWarningWhenImpellerIsOptedOut) { +#if !IMPELLER_SUPPORTS_RENDERING + GTEST_SKIP() << "This platform doesn't support Impeller."; +#endif + ASSERT_FALSE(DartVMRef::IsInstanceRunning()); + Settings settings = CreateSettingsForFixture(); + settings.enable_impeller = false; + settings.warn_on_impeller_opt_out = true; + // Log captures are thread specific. Just put the shell in single threaded + // configuration. + const auto& runner = fml::MessageLoop::GetCurrent().GetTaskRunner(); + TaskRunners task_runners("test", runner, runner, runner, runner); + std::ostringstream stream; + fml::LogMessage::CaptureNextLog(&stream); + std::unique_ptr shell = CreateShell(settings, task_runners); + ASSERT_TRUE(stream.str().find( + "[Action Required] The application opted out of Impeller") != + std::string::npos); + ASSERT_TRUE(shell); + DestroyShell(std::move(shell), task_runners); +} + } // namespace testing } // namespace flutter diff --git a/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm b/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm index 70c1ac7a4742d..2eaf9c359ce7d 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm @@ -200,6 +200,8 @@ static BOOL DoesHardwareSupportWideGamut() { } } + settings.warn_on_impeller_opt_out = true; + NSNumber* enableTraceSystrace = [mainBundle objectForInfoDictionaryKey:@"FLTTraceSystrace"]; // Change the default only if the option is present. if (enableTraceSystrace != nil) { diff --git a/shell/platform/darwin/ios/framework/Source/FlutterDartProjectTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterDartProjectTest.mm index 7de95d4771ae8..c68018bbdeb5f 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterDartProjectTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterDartProjectTest.mm @@ -235,6 +235,11 @@ - (void)testDisableImpellerSettingIsCorrectlyParsed { [mockMainBundle stopMocking]; } +- (void)testRequestsWarningWhenImpellerOptOut { + auto settings = FLTDefaultSettingsForBundle(); + XCTAssertEqual(settings.warn_on_impeller_opt_out, YES); +} + - (void)testEnableImpellerSettingIsCorrectlyParsed { id mockMainBundle = OCMPartialMock([NSBundle mainBundle]); OCMStub([mockMainBundle objectForInfoDictionaryKey:@"FLTEnableImpeller"]).andReturn(@"YES");