diff --git a/packages/flutter_tools/lib/src/desktop_device.dart b/packages/flutter_tools/lib/src/desktop_device.dart index 02d7534a9f..c8937258dd 100644 --- a/packages/flutter_tools/lib/src/desktop_device.dart +++ b/packages/flutter_tools/lib/src/desktop_device.dart @@ -209,6 +209,8 @@ abstract class DesktopDevice extends Device { /// steps to be run. void onAttached(ApplicationPackage package, BuildInfo buildInfo, Process process) {} + bool get supportsImpeller => false; + /// Computes a set of environment variables used to pass debugging information /// to the engine without interfering with application level command line /// arguments. @@ -266,6 +268,15 @@ abstract class DesktopDevice extends Device { if (debuggingOptions.purgePersistentCache) { addFlag('purge-persistent-cache=true'); } + if (supportsImpeller) { + switch (debuggingOptions.enableImpeller) { + case ImpellerStatus.enabled: + addFlag('enable-impeller=true'); + case ImpellerStatus.disabled: + case ImpellerStatus.platformDefault: + addFlag('enable-impeller=false'); + } + } // Options only supported when there is a VM Service connection between the // tool and the device, usually in debug or profile mode. if (debuggingOptions.debuggingEnabled) { diff --git a/packages/flutter_tools/lib/src/macos/macos_device.dart b/packages/flutter_tools/lib/src/macos/macos_device.dart index 1de3ad9ce5..478c8ac27c 100644 --- a/packages/flutter_tools/lib/src/macos/macos_device.dart +++ b/packages/flutter_tools/lib/src/macos/macos_device.dart @@ -47,6 +47,9 @@ class MacOSDevice extends DesktopDevice { @override String get name => 'macOS'; + @override + bool get supportsImpeller => true; + @override Future get targetPlatform async => TargetPlatform.darwin; @@ -54,9 +57,8 @@ class MacOSDevice extends DesktopDevice { Future get targetPlatformDisplayName async { if (_operatingSystemUtils.hostPlatform == HostPlatform.darwin_arm64) { return 'darwin-arm64'; - } else { - return 'darwin-x64'; } + return 'darwin-x64'; } @override diff --git a/packages/flutter_tools/test/general.shard/desktop_device_test.dart b/packages/flutter_tools/test/general.shard/desktop_device_test.dart index 8967bd00a5..57631ac8fe 100644 --- a/packages/flutter_tools/test/general.shard/desktop_device_test.dart +++ b/packages/flutter_tools/test/general.shard/desktop_device_test.dart @@ -300,6 +300,66 @@ void main() { ), ); }); + + testWithoutContext('Desktop devices that support impeller pass through the enable-impeller flag', () async { + final FakeProcessManager processManager = FakeProcessManager.list([ + const FakeCommand( + command: ['debug'], + exitCode: -1, + environment: { + 'FLUTTER_ENGINE_SWITCH_1': 'enable-dart-profiling=true', + 'FLUTTER_ENGINE_SWITCH_2': 'enable-impeller=true', + 'FLUTTER_ENGINE_SWITCH_3': 'enable-checked-mode=true', + 'FLUTTER_ENGINE_SWITCH_4': 'verify-entry-points=true', + 'FLUTTER_ENGINE_SWITCHES': '4' + } + ), + ]); + final FakeDesktopDevice device = setUpDesktopDevice( + processManager: processManager, + supportsImpeller: true, + ); + + final FakeApplicationPackage package = FakeApplicationPackage(); + await device.startApp( + package, + prebuiltApplication: true, + debuggingOptions: DebuggingOptions.enabled( + BuildInfo.debug, + enableImpeller: ImpellerStatus.enabled, + dartEntrypointArgs: [], + ), + ); + }); + + testWithoutContext('Desktop devices that do not support impeller ignore the enable-impeller flag', () async { + final FakeProcessManager processManager = FakeProcessManager.list([ + const FakeCommand( + command: ['debug'], + exitCode: -1, + environment: { + 'FLUTTER_ENGINE_SWITCH_1': 'enable-dart-profiling=true', + 'FLUTTER_ENGINE_SWITCH_2': 'enable-checked-mode=true', + 'FLUTTER_ENGINE_SWITCH_3': 'verify-entry-points=true', + 'FLUTTER_ENGINE_SWITCHES': '3' + } + ), + ]); + final FakeDesktopDevice device = setUpDesktopDevice( + processManager: processManager, + ); + + final FakeApplicationPackage package = FakeApplicationPackage(); + await device.startApp( + package, + prebuiltApplication: true, + debuggingOptions: DebuggingOptions.enabled( + BuildInfo.debug, + enableImpeller: ImpellerStatus.enabled, + dartEntrypointArgs: [], + ), + ); + }); } FakeDesktopDevice setUpDesktopDevice({ @@ -308,6 +368,7 @@ FakeDesktopDevice setUpDesktopDevice({ ProcessManager? processManager, OperatingSystemUtils? operatingSystemUtils, bool nullExecutablePathForDevice = false, + bool supportsImpeller = false, }) { return FakeDesktopDevice( fileSystem: fileSystem ?? MemoryFileSystem.test(), @@ -315,6 +376,7 @@ FakeDesktopDevice setUpDesktopDevice({ processManager: processManager ?? FakeProcessManager.any(), operatingSystemUtils: operatingSystemUtils ?? FakeOperatingSystemUtils(), nullExecutablePathForDevice: nullExecutablePathForDevice, + supportsImpeller: supportsImpeller, ); } @@ -326,6 +388,7 @@ class FakeDesktopDevice extends DesktopDevice { required FileSystem fileSystem, required OperatingSystemUtils operatingSystemUtils, this.nullExecutablePathForDevice = false, + this.supportsImpeller = false, }) : super( 'dummy', platformType: PlatformType.linux, @@ -344,6 +407,9 @@ class FakeDesktopDevice extends DesktopDevice { final bool nullExecutablePathForDevice; + @override + final bool supportsImpeller; + @override String get name => 'dummy';