Skip to content

Commit 7509de8

Browse files
authored
[Impeller] Ignore opt-outs on iOS devices. (flutter#55808)
Addresses flutter/flutter#155541 This does **not** remove Skia itself from the build. I'll stage that in a followup. Want to keep the scope of this patch small. This is the new behavior: * Impeller is the default on iOS devices **and** simulators. * On iOS devices **only**, all flags and plist options are ignored. * On iOS simulators **only**, Flutter will used Impeller's Metal backend by default and fallback to the Null backend if Metal device access is not available. * On iOS simulators **only**, Flutter can pick Skia using the command line flags or plist flags. This is to allow users one more month to migrate as communicated by @zanderso. The settings objects `enable_impeller` field is now `static constexpr` to avoid accidentally disabling the flag while it still exists.
1 parent c2e5e2e commit 7509de8

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

common/settings.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,12 @@ struct Settings {
224224
// Enable the Impeller renderer on supported platforms. Ignored if Impeller is
225225
// not supported on the platform.
226226
#if FML_OS_ANDROID || FML_OS_IOS || FML_OS_IOS_SIMULATOR
227-
bool enable_impeller = true;
227+
// On iOS devices, Impeller is the default with no opt-out and this field is
228+
// const.
229+
#if FML_OS_IOS && !FML_OS_IOS_SIMULATOR
230+
static constexpr const
231+
#endif // FML_OS_IOS && !FML_OS_IOS_SIMULATOR
232+
bool enable_impeller = true;
228233
#else
229234
bool enable_impeller = false;
230235
#endif

shell/common/switches.cc

+5
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,10 @@ Settings SettingsFromCommandLine(const fml::CommandLine& command_line) {
443443
settings.use_asset_fonts =
444444
!command_line.HasOption(FlagForSwitch(Switch::DisableAssetFonts));
445445

446+
#if FML_OS_IOS && !FML_OS_IOS_SIMULATOR
447+
// On these configurations, the Impeller flags are completely ignored with the
448+
// default taking hold.
449+
#else // FML_OS_IOS && !FML_OS_IOS_SIMULATOR
446450
{
447451
std::string enable_impeller_value;
448452
if (command_line.GetOptionValue(FlagForSwitch(Switch::EnableImpeller),
@@ -451,6 +455,7 @@ Settings SettingsFromCommandLine(const fml::CommandLine& command_line) {
451455
enable_impeller_value.empty() || "true" == enable_impeller_value;
452456
}
453457
}
458+
#endif // FML_OS_IOS && !FML_OS_IOS_SIMULATOR
454459

455460
{
456461
std::string impeller_backend_value;

shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
#include <syslog.h>
1313

1414
#include "flutter/common/constants.h"
15+
#include "flutter/fml/build_config.h"
1516
#include "flutter/shell/common/switches.h"
16-
#import "flutter/shell/platform/darwin/common/command_line.h"
17+
#include "flutter/shell/platform/darwin/common/command_line.h"
1718

1819
FLUTTER_ASSERT_ARC
1920

@@ -176,6 +177,7 @@ static BOOL DoesHardwareSupportWideGamut() {
176177
settings.enable_wide_gamut = enableWideGamut;
177178
#endif
178179

180+
#if FML_OS_IOS_SIMULATOR
179181
if (!command_line.HasOption("enable-impeller")) {
180182
// Next, look in the app bundle.
181183
NSNumber* enableImpeller = [bundle objectForInfoDictionaryKey:@"FLTEnableImpeller"];
@@ -188,6 +190,7 @@ static BOOL DoesHardwareSupportWideGamut() {
188190
settings.enable_impeller = enableImpeller.boolValue;
189191
}
190192
}
193+
#endif // FML_OS_IOS_SIMULATOR
191194

192195
settings.warn_on_impeller_opt_out = true;
193196

shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm

+4-11
Original file line numberDiff line numberDiff line change
@@ -239,17 +239,6 @@ - (void)testPlatformViewsControllerRenderingMetalBackend {
239239
XCTAssertEqual(renderingApi, flutter::IOSRenderingAPI::kMetal);
240240
}
241241

242-
- (void)testPlatformViewsControllerRenderingSoftware {
243-
auto settings = FLTDefaultSettingsForBundle();
244-
settings.enable_software_rendering = true;
245-
FlutterDartProject* project = [[FlutterDartProject alloc] initWithSettings:settings];
246-
FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar" project:project];
247-
[engine run];
248-
flutter::IOSRenderingAPI renderingApi = [engine platformViewsRenderingAPI];
249-
250-
XCTAssertEqual(renderingApi, flutter::IOSRenderingAPI::kSoftware);
251-
}
252-
253242
- (void)testWaitForFirstFrameTimeout {
254243
FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar"];
255244
[engine run];
@@ -471,6 +460,7 @@ - (void)testEnableSemanticsWhenFlutterViewAccessibilityDidCall {
471460
}
472461

473462
- (void)testCanMergePlatformAndUIThread {
463+
#if defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR
474464
auto settings = FLTDefaultSettingsForBundle();
475465
settings.enable_impeller = true;
476466
FlutterDartProject* project = [[FlutterDartProject alloc] initWithSettings:settings];
@@ -479,9 +469,11 @@ - (void)testCanMergePlatformAndUIThread {
479469

480470
XCTAssertEqual(engine.shell.GetTaskRunners().GetUITaskRunner(),
481471
engine.shell.GetTaskRunners().GetPlatformTaskRunner());
472+
#endif // defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR
482473
}
483474

484475
- (void)testCanNotUnMergePlatformAndUIThread {
476+
#if defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR
485477
auto settings = FLTDefaultSettingsForBundle();
486478
settings.enable_impeller = true;
487479
FlutterDartProject* project = [[FlutterDartProject alloc] initWithSettings:settings];
@@ -490,6 +482,7 @@ - (void)testCanNotUnMergePlatformAndUIThread {
490482

491483
XCTAssertEqual(engine.shell.GetTaskRunners().GetUITaskRunner(),
492484
engine.shell.GetTaskRunners().GetPlatformTaskRunner());
485+
#endif // defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR
493486
}
494487

495488
@end

0 commit comments

Comments
 (0)