Skip to content

Commit 208a418

Browse files
authored
flutter drive --enable-software-rendering --skia-deterministic-rendering (#105161)
1 parent ff110fb commit 208a418

File tree

3 files changed

+55
-15
lines changed

3 files changed

+55
-15
lines changed

packages/flutter_tools/lib/src/commands/run.dart

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,19 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
133133
'this comma separated list of allowed prefixes.',
134134
valueHelp: 'skia.gpu,skia.shaders',
135135
)
136+
..addFlag('enable-software-rendering',
137+
negatable: false,
138+
help: 'Enable rendering using the Skia software backend. '
139+
'This is useful when testing Flutter on emulators. By default, '
140+
'Flutter will attempt to either use OpenGL or Vulkan and fall back '
141+
'to software when neither is available.',
142+
)
143+
..addFlag('skia-deterministic-rendering',
144+
negatable: false,
145+
help: 'When combined with "--enable-software-rendering", this should provide completely '
146+
'deterministic (i.e. reproducible) Skia rendering. This is useful for testing purposes '
147+
'(e.g. when comparing screenshots).',
148+
)
136149
..addMultiOption('dart-entrypoint-args',
137150
abbr: 'a',
138151
help: 'Pass a list of arguments to the Dart entrypoint at application '
@@ -184,6 +197,8 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
184197
String get traceAllowlist => stringArgDeprecated('trace-allowlist');
185198

186199
/// Create a debugging options instance for the current `run` or `drive` invocation.
200+
@visibleForTesting
201+
@protected
187202
Future<DebuggingOptions> createDebuggingOptions(bool webMode) async {
188203
final BuildInfo buildInfo = await getBuildInfo();
189204
final int browserDebugPort = featureFlags.isWebEnabled && argResults.wasParsed('web-browser-debug-port')
@@ -268,19 +283,6 @@ class RunCommand extends RunCommandBase {
268283
addMultidexOption();
269284
addIgnoreDeprecationOption();
270285
argParser
271-
..addFlag('enable-software-rendering',
272-
negatable: false,
273-
help: 'Enable rendering using the Skia software backend. '
274-
'This is useful when testing Flutter on emulators. By default, '
275-
'Flutter will attempt to either use OpenGL or Vulkan and fall back '
276-
'to software when neither is available.',
277-
)
278-
..addFlag('skia-deterministic-rendering',
279-
negatable: false,
280-
help: 'When combined with "--enable-software-rendering", this should provide completely '
281-
'deterministic (i.e. reproducible) Skia rendering. This is useful for testing purposes '
282-
'(e.g. when comparing screenshots).',
283-
)
284286
..addFlag('await-first-frame-when-tracing',
285287
defaultsTo: true,
286288
help: 'Whether to wait for the first frame when tracing startup ("--trace-startup"), '

packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,20 +208,38 @@ void main() {
208208
Pub: () => FakePub(),
209209
});
210210

211-
testUsingContext('--enable-impeller flag propagates to debugging options', () async {
211+
testUsingContext('flags propagate to debugging options', () async {
212212
final DriveCommand command = DriveCommand(fileSystem: fileSystem, logger: logger, platform: platform);
213213
fileSystem.file('lib/main.dart').createSync(recursive: true);
214214
fileSystem.file('test_driver/main_test.dart').createSync(recursive: true);
215215
fileSystem.file('pubspec.yaml').createSync();
216216

217217
await expectLater(() => createTestCommandRunner(command).run(<String>[
218218
'drive',
219+
'--start-paused',
220+
'--disable-service-auth-codes',
221+
'--trace-skia',
222+
'--trace-systrace',
223+
'--verbose-system-logs',
224+
'--null-assertions',
225+
'--native-null-assertions',
219226
'--enable-impeller',
227+
'--enable-software-rendering',
228+
'--skia-deterministic-rendering',
220229
]), throwsToolExit());
221230

222231
final DebuggingOptions options = await command.createDebuggingOptions(false);
223232

233+
expect(options.startPaused, true);
234+
expect(options.disableServiceAuthCodes, true);
235+
expect(options.traceSkia, true);
236+
expect(options.traceSystrace, true);
237+
expect(options.verboseSystemLogs, true);
238+
expect(options.nullAssertions, true);
239+
expect(options.nativeNullAssertions, true);
224240
expect(options.enableImpeller, true);
241+
expect(options.enableSoftwareRendering, true);
242+
expect(options.skiaDeterministicRendering, true);
225243
}, overrides: <Type, Generator>{
226244
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
227245
FileSystem: () => MemoryFileSystem.test(),

packages/flutter_tools/test/commands.shard/hermetic/run_test.dart

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,16 +721,36 @@ void main() {
721721
ProcessManager: () => FakeProcessManager.any(),
722722
});
723723

724-
testUsingContext('--enable-impeller flag propagates to debugging options', () async {
724+
testUsingContext('flags propagate to debugging options', () async {
725725
final RunCommand command = RunCommand();
726726
await expectLater(() => createTestCommandRunner(command).run(<String>[
727727
'run',
728+
'--start-paused',
729+
'--disable-service-auth-codes',
730+
'--use-test-fonts',
731+
'--trace-skia',
732+
'--trace-systrace',
733+
'--verbose-system-logs',
734+
'--null-assertions',
735+
'--native-null-assertions',
728736
'--enable-impeller',
737+
'--enable-software-rendering',
738+
'--skia-deterministic-rendering',
729739
]), throwsToolExit());
730740

731741
final DebuggingOptions options = await command.createDebuggingOptions(false);
732742

743+
expect(options.startPaused, true);
744+
expect(options.disableServiceAuthCodes, true);
745+
expect(options.useTestFonts, true);
746+
expect(options.traceSkia, true);
747+
expect(options.traceSystrace, true);
748+
expect(options.verboseSystemLogs, true);
749+
expect(options.nullAssertions, true);
750+
expect(options.nativeNullAssertions, true);
733751
expect(options.enableImpeller, true);
752+
expect(options.enableSoftwareRendering, true);
753+
expect(options.skiaDeterministicRendering, true);
734754
}, overrides: <Type, Generator>{
735755
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
736756
FileSystem: () => MemoryFileSystem.test(),

0 commit comments

Comments
 (0)