Unverified Commit 7e88acfb authored by Zachary Anderson's avatar Zachary Anderson Committed by GitHub

[flutter_tool] Adds a flag to disable Impeller (#122960)

parent e260dd2a
......@@ -660,8 +660,10 @@ class AndroidDevice extends Device {
...<String>['--ez', 'cache-sksl', 'true'],
if (debuggingOptions.purgePersistentCache)
...<String>['--ez', 'purge-persistent-cache', 'true'],
if (debuggingOptions.enableImpeller)
if (debuggingOptions.enableImpeller == ImpellerStatus.enabled)
...<String>['--ez', 'enable-impeller', 'true'],
if (debuggingOptions.enableImpeller == ImpellerStatus.disabled)
...<String>['--ez', 'enable-impeller', 'false'],
if (debuggingOptions.debuggingEnabled) ...<String>[
if (debuggingOptions.buildInfo.isDebug) ...<String>[
...<String>['--ez', 'enable-checked-mode', 'true'],
......
......@@ -17,6 +17,7 @@ import '../../base/logger.dart';
import '../../build_info.dart';
import '../../convert.dart';
import '../../devfs.dart';
import '../../device.dart';
import '../build_system.dart';
/// The output shader format that should be used by the [ShaderCompiler].
......@@ -51,7 +52,7 @@ class DevelopmentShaderCompiler {
/// Configure the output format of the shader compiler for a particular
/// flutter device.
void configureCompiler(TargetPlatform? platform, { required bool enableImpeller }) {
void configureCompiler(TargetPlatform? platform, { required ImpellerStatus impellerStatus }) {
switch (platform) {
case TargetPlatform.ios:
_shaderTarget = ShaderTarget.impelleriOS;
......@@ -61,7 +62,9 @@ class DevelopmentShaderCompiler {
case TargetPlatform.android_x86:
case TargetPlatform.android_arm:
case TargetPlatform.android:
_shaderTarget = enableImpeller ? ShaderTarget.impellerAndroid : ShaderTarget.sksl;
_shaderTarget = impellerStatus == ImpellerStatus.enabled
? ShaderTarget.impellerAndroid
: ShaderTarget.sksl;
break;
case TargetPlatform.darwin:
case TargetPlatform.linux_x64:
......@@ -70,11 +73,11 @@ class DevelopmentShaderCompiler {
case TargetPlatform.fuchsia_arm64:
case TargetPlatform.fuchsia_x64:
case TargetPlatform.tester:
assert(!enableImpeller);
assert(impellerStatus != ImpellerStatus.enabled);
_shaderTarget = ShaderTarget.sksl;
break;
case TargetPlatform.web_javascript:
assert(!enableImpeller);
assert(impellerStatus != ImpellerStatus.enabled);
_shaderTarget = ShaderTarget.sksl;
_jsonMode = true;
break;
......
......@@ -193,7 +193,7 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
bool get cacheStartupProfile => boolArg('cache-startup-profile');
bool get runningWithPrebuiltApplication => argResults![FlutterOptions.kUseApplicationBinary] != null;
bool get trackWidgetCreation => boolArg('track-widget-creation');
bool get enableImpeller => boolArg('enable-impeller');
ImpellerStatus get enableImpeller => ImpellerStatus.fromBool(argResults!['enable-impeller'] as bool?);
bool get uninstallFirst => boolArg('uninstall-first');
bool get enableEmbedderApi => boolArg('enable-embedder-api');
......@@ -478,7 +478,7 @@ class RunCommand extends RunCommandBase {
commandRunProjectModule: FlutterProject.current().isModule,
commandRunProjectHostLanguage: hostLanguage.join(','),
commandRunAndroidEmbeddingVersion: androidEmbeddingVersion,
commandRunEnableImpeller: enableImpeller,
commandRunEnableImpeller: enableImpeller.asBool,
commandRunIOSInterfaceType: iOSInterfaceType,
);
}
......
......@@ -877,6 +877,23 @@ class _NoMemoryInfo implements MemoryInfo {
Map<String, Object> toJson() => <String, Object>{};
}
enum ImpellerStatus {
platformDefault._(null),
enabled._(true),
disabled._(false);
const ImpellerStatus._(this.asBool);
factory ImpellerStatus.fromBool(bool? b) {
if (b == null) {
return platformDefault;
}
return b ? enabled : disabled;
}
final bool? asBool;
}
class DebuggingOptions {
DebuggingOptions.enabled(
this.buildInfo, {
......@@ -917,7 +934,7 @@ class DebuggingOptions {
this.vmserviceOutFile,
this.fastStart = false,
this.nativeNullAssertions = false,
this.enableImpeller = false,
this.enableImpeller = ImpellerStatus.platformDefault,
this.uninstallFirst = false,
this.serveObservatory = true,
this.enableDartProfiling = true,
......@@ -938,7 +955,7 @@ class DebuggingOptions {
this.webLaunchUrl,
this.cacheSkSL = false,
this.traceAllowlist,
this.enableImpeller = false,
this.enableImpeller = ImpellerStatus.platformDefault,
this.uninstallFirst = false,
this.enableDartProfiling = true,
this.enableEmbedderApi = false,
......@@ -1048,7 +1065,7 @@ class DebuggingOptions {
final bool webUseSseForDebugProxy;
final bool webUseSseForDebugBackend;
final bool webUseSseForInjectedClient;
final bool enableImpeller;
final ImpellerStatus enableImpeller;
final bool serveObservatory;
final bool enableDartProfiling;
final bool enableEmbedderApi;
......@@ -1123,7 +1140,8 @@ class DebuggingOptions {
if (purgePersistentCache) '--purge-persistent-cache',
if (route != null) '--route=$route',
if (platformArgs['trace-startup'] as bool? ?? false) '--trace-startup',
if (enableImpeller) '--enable-impeller',
if (enableImpeller == ImpellerStatus.enabled) '--enable-impeller=true',
if (enableImpeller == ImpellerStatus.disabled) '--enable-impeller=false',
if (environmentType == EnvironmentType.physical && deviceVmServicePort != null)
'--vm-service-port=$deviceVmServicePort',
// The simulator "device" is actually on the host machine so no ports will be forwarded.
......@@ -1176,7 +1194,7 @@ class DebuggingOptions {
'vmserviceOutFile': vmserviceOutFile,
'fastStart': fastStart,
'nativeNullAssertions': nativeNullAssertions,
'enableImpeller': enableImpeller,
'enableImpeller': enableImpeller.asBool,
'serveObservatory': serveObservatory,
'enableDartProfiling': enableDartProfiling,
'enableEmbedderApi': enableEmbedderApi,
......@@ -1223,7 +1241,7 @@ class DebuggingOptions {
vmserviceOutFile: json['vmserviceOutFile'] as String?,
fastStart: json['fastStart']! as bool,
nativeNullAssertions: json['nativeNullAssertions']! as bool,
enableImpeller: (json['enableImpeller'] as bool?) ?? false,
enableImpeller: ImpellerStatus.fromBool(json['enableImpeller'] as bool?),
uninstallFirst: (json['uninstallFirst'] as bool?) ?? false,
serveObservatory: (json['serveObservatory'] as bool?) ?? false,
enableDartProfiling: (json['enableDartProfiling'] as bool?) ?? true,
......
......@@ -253,7 +253,10 @@ class HotRunner extends ResidentRunner {
await device!.initLogReader();
device
.developmentShaderCompiler
.configureCompiler(device.targetPlatform, enableImpeller: debuggingOptions.enableImpeller);
.configureCompiler(
device.targetPlatform,
impellerStatus: debuggingOptions.enableImpeller,
);
}
try {
final List<Uri?> baseUris = await _initDevFS();
......
......@@ -1017,11 +1017,13 @@ abstract class FlutterCommand extends Command<void> {
void addEnableImpellerFlag({required bool verboseHelp}) {
argParser.addFlag('enable-impeller',
negatable: false,
hide: !verboseHelp,
help: 'Whether to enable the experimental Impeller rendering engine. '
'Impeller is currently only supported on iOS and Android. This flag will '
'be ignored when targeting other platforms.',
defaultsTo: null,
help: 'Whether to enable the Impeller rendering engine. '
'Impeller is the default renderer on iOS. On Android, Impeller '
'is available but not the default. This flag will cause Impeller '
'to be used on Android. On other platforms, this flag will be '
'ignored.',
);
}
......
......@@ -397,7 +397,7 @@ void main() {
expect(options.traceSystrace, true);
expect(options.verboseSystemLogs, true);
expect(options.nativeNullAssertions, true);
expect(options.enableImpeller, true);
expect(options.enableImpeller, ImpellerStatus.enabled);
expect(options.traceSystrace, true);
expect(options.enableSoftwareRendering, true);
expect(options.skiaDeterministicRendering, true);
......
......@@ -428,7 +428,7 @@ void main() {
TestUsageCommand('run', parameters: CustomDimensions.fromMap(<String, String>{
'cd3': 'false', 'cd4': 'ios', 'cd22': 'iOS 13',
'cd23': 'debug', 'cd18': 'false', 'cd15': 'swift', 'cd31': 'true',
'cd56': 'false', 'cd57': 'usb',
'cd57': 'usb',
})
)));
}, overrides: <Type, Generator>{
......@@ -699,7 +699,6 @@ void main() {
commandRunModeName: 'debug',
commandRunProjectModule: false,
commandRunProjectHostLanguage: '',
commandRunEnableImpeller: false,
));
}, overrides: <Type, Generator>{
DeviceManager: () => testDeviceManager,
......@@ -739,7 +738,6 @@ void main() {
commandRunModeName: 'debug',
commandRunProjectModule: false,
commandRunProjectHostLanguage: '',
commandRunEnableImpeller: false,
commandRunIOSInterfaceType: 'usb',
));
}, overrides: <Type, Generator>{
......@@ -783,7 +781,6 @@ void main() {
commandRunModeName: 'debug',
commandRunProjectModule: false,
commandRunProjectHostLanguage: '',
commandRunEnableImpeller: false,
commandRunIOSInterfaceType: 'wireless',
));
}, overrides: <Type, Generator>{
......@@ -827,7 +824,6 @@ void main() {
commandRunModeName: 'debug',
commandRunProjectModule: false,
commandRunProjectHostLanguage: '',
commandRunEnableImpeller: false,
commandRunIOSInterfaceType: 'wireless',
));
}, overrides: <Type, Generator>{
......@@ -1023,7 +1019,7 @@ void main() {
expect(options.verboseSystemLogs, true);
expect(options.nativeNullAssertions, true);
expect(options.traceSystrace, true);
expect(options.enableImpeller, true);
expect(options.enableImpeller, ImpellerStatus.enabled);
expect(options.enableSoftwareRendering, true);
expect(options.skiaDeterministicRendering, true);
}, overrides: <Type, Generator>{
......
......@@ -278,7 +278,7 @@ void main() {
purgePersistentCache: true,
useTestFonts: true,
verboseSystemLogs: true,
enableImpeller: true,
enableImpeller: ImpellerStatus.enabled,
),
platformArgs: <String, dynamic>{},
userIdentifier: '10',
......
......@@ -11,6 +11,7 @@ import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/build_system/targets/shader_compiler.dart';
import 'package:flutter_tools/src/devfs.dart';
import 'package:flutter_tools/src/device.dart';
import '../../../src/common.dart';
import '../../../src/fake_process_manager.dart';
......@@ -272,7 +273,10 @@ void main() {
random: math.Random(0),
);
developmentShaderCompiler.configureCompiler(TargetPlatform.android, enableImpeller: false);
developmentShaderCompiler.configureCompiler(
TargetPlatform.android,
impellerStatus: ImpellerStatus.disabled,
);
final DevFSContent? content = await developmentShaderCompiler
.recompileShader(DevFSFileContent(fileSystem.file(fragPath)));
......@@ -317,7 +321,10 @@ void main() {
random: math.Random(0),
);
developmentShaderCompiler.configureCompiler(TargetPlatform.android, enableImpeller: true);
developmentShaderCompiler.configureCompiler(
TargetPlatform.android,
impellerStatus: ImpellerStatus.enabled,
);
final DevFSContent? content = await developmentShaderCompiler
.recompileShader(DevFSFileContent(fileSystem.file(fragPath)));
......@@ -363,7 +370,10 @@ void main() {
random: math.Random(0),
);
developmentShaderCompiler.configureCompiler(TargetPlatform.web_javascript, enableImpeller: false);
developmentShaderCompiler.configureCompiler(
TargetPlatform.web_javascript,
impellerStatus: ImpellerStatus.disabled,
);
final DevFSContent? content = await developmentShaderCompiler
.recompileShader(DevFSFileContent(fileSystem.file(fragPath)));
......
......@@ -282,7 +282,10 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler {
const FakeShaderCompiler();
@override
void configureCompiler(TargetPlatform? platform, { required bool enableImpeller }) { }
void configureCompiler(
TargetPlatform? platform, {
required ImpellerStatus impellerStatus,
}) { }
@override
Future<DevFSContent> recompileShader(DevFSContent inputShader) {
......
......@@ -20,6 +20,7 @@ import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/build_system/targets/shader_compiler.dart';
import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/devfs.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/vmservice.dart';
import 'package:package_config/package_config.dart';
import 'package:test/fake.dart';
......@@ -807,7 +808,10 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler {
const FakeShaderCompiler();
@override
void configureCompiler(TargetPlatform? platform, { required bool enableImpeller }) { }
void configureCompiler(
TargetPlatform? platform, {
required ImpellerStatus impellerStatus,
}) { }
@override
Future<DevFSContent> recompileShader(DevFSContent inputShader) async {
......
......@@ -716,7 +716,7 @@ void main() {
dartEntrypointArgs: <String>['a', 'b'],
dartFlags: 'c',
deviceVmServicePort: 1234,
enableImpeller: true,
enableImpeller: ImpellerStatus.enabled,
enableDartProfiling: false,
enableEmbedderApi: true,
);
......@@ -755,7 +755,7 @@ void main() {
cacheSkSL: true,
purgePersistentCache: true,
verboseSystemLogs: true,
enableImpeller: true,
enableImpeller: ImpellerStatus.disabled,
deviceVmServicePort: 0,
hostVmServicePort: 1,
);
......@@ -792,7 +792,7 @@ void main() {
'--purge-persistent-cache',
'--route=/test',
'--trace-startup',
'--enable-impeller',
'--enable-impeller=false',
'--vm-service-port=0',
].join(' '),
);
......@@ -871,7 +871,7 @@ void main() {
BuildInfo.debug,
traceAllowlist: 'foo',
cacheSkSL: true,
enableImpeller: true,
enableImpeller: ImpellerStatus.disabled,
);
final List<String> launchArguments = original.getIOSLaunchArguments(
......@@ -890,7 +890,7 @@ void main() {
'--cache-sksl',
'--route=/test',
'--trace-startup',
'--enable-impeller',
'--enable-impeller=false',
].join(' '),
);
});
......@@ -914,7 +914,7 @@ void main() {
cacheSkSL: true,
purgePersistentCache: true,
verboseSystemLogs: true,
enableImpeller: true,
enableImpeller: ImpellerStatus.disabled,
deviceVmServicePort: 0,
hostVmServicePort: 1,
);
......@@ -951,7 +951,7 @@ void main() {
'--purge-persistent-cache',
'--route=/test',
'--trace-startup',
'--enable-impeller',
'--enable-impeller=false',
'--vm-service-port=1',
].join(' '),
);
......
......@@ -752,7 +752,10 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler {
const FakeShaderCompiler();
@override
void configureCompiler(TargetPlatform? platform, { required bool enableImpeller }) { }
void configureCompiler(
TargetPlatform? platform, {
required ImpellerStatus impellerStatus,
}) { }
@override
Future<DevFSContent> recompileShader(DevFSContent inputShader) {
......
......@@ -352,7 +352,7 @@ void main() {
'--verbose-logging',
'--cache-sksl',
'--purge-persistent-cache',
'--enable-impeller',
'--enable-impeller=false',
'--enable-embedder-api',
].join(' '),
],
......@@ -404,7 +404,7 @@ void main() {
cacheSkSL: true,
purgePersistentCache: true,
verboseSystemLogs: true,
enableImpeller: true,
enableImpeller: ImpellerStatus.disabled,
enableEmbedderApi: true,
),
platformArgs: <String, dynamic>{},
......
......@@ -1041,7 +1041,7 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
cacheSkSL: true,
purgePersistentCache: true,
dartFlags: '--baz',
enableImpeller: true,
enableImpeller: ImpellerStatus.disabled,
hostVmServicePort: 0,
);
......@@ -1065,7 +1065,7 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
'--cache-sksl',
'--purge-persistent-cache',
'--dart-flags=--baz',
'--enable-impeller',
'--enable-impeller=false',
'--vm-service-port=0',
]));
}, overrides: <Type, Generator>{
......
......@@ -2817,7 +2817,10 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler {
const FakeShaderCompiler();
@override
void configureCompiler(TargetPlatform? platform, { required bool enableImpeller }) { }
void configureCompiler(
TargetPlatform? platform, {
required ImpellerStatus impellerStatus,
}) { }
@override
Future<DevFSContent> recompileShader(DevFSContent inputShader) {
......
......@@ -1682,7 +1682,10 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler {
const FakeShaderCompiler();
@override
void configureCompiler(TargetPlatform? platform, { required bool enableImpeller }) { }
void configureCompiler(
TargetPlatform? platform, {
required ImpellerStatus impellerStatus,
}) { }
@override
Future<DevFSContent> recompileShader(DevFSContent inputShader) {
......
......@@ -1518,7 +1518,10 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler {
const FakeShaderCompiler();
@override
void configureCompiler(TargetPlatform? platform, { required bool enableImpeller }) { }
void configureCompiler(
TargetPlatform? platform, {
required ImpellerStatus impellerStatus,
}) { }
@override
Future<DevFSContent> recompileShader(DevFSContent inputShader) {
......
......@@ -16,6 +16,7 @@ import 'package:flutter_tools/src/build_system/targets/shader_compiler.dart';
import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/devfs.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/html_utils.dart';
import 'package:flutter_tools/src/isolated/devfs_web.dart';
......@@ -1176,7 +1177,10 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler {
const FakeShaderCompiler();
@override
void configureCompiler(TargetPlatform? platform, { required bool enableImpeller }) { }
void configureCompiler(
TargetPlatform? platform, {
required ImpellerStatus impellerStatus,
}) { }
@override
Future<DevFSContent> recompileShader(DevFSContent inputShader) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment