Skip to content

Commit daaba8a

Browse files
author
Harry Terkelsen
authored
Add --local-web-sdk in devicelab runner to make --ab testing work for web (flutter#123825)
This allows us to check for performance differences in local Web SDKs. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [Features we expect every widget to implement]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat
1 parent 54dbbd7 commit daaba8a

File tree

5 files changed

+38
-4
lines changed

5 files changed

+38
-4
lines changed

dev/devicelab/bin/run.dart

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ Future<void> main(List<String> rawArgs) async {
3838
/// Required for A/B test mode.
3939
final String? localEngine = args['local-engine'] as String?;
4040

41+
/// The build of the local Web SDK to use.
42+
///
43+
/// Required for A/B test mode.
44+
final String? localWebSdk = args['local-web-sdk'] as String?;
45+
4146
/// The path to the engine "src/" directory.
4247
final String? localEngineSrcPath = args['local-engine-src-path'] as String?;
4348

@@ -85,15 +90,16 @@ Future<void> main(List<String> rawArgs) async {
8590
stderr.writeln(argParser.usage);
8691
exit(1);
8792
}
88-
if (localEngine == null) {
89-
stderr.writeln('When running in A/B test mode --local-engine is required.\n');
93+
if (localEngine == null && localWebSdk == null) {
94+
stderr.writeln('When running in A/B test mode --local-engine or --local-web-sdk is required.\n');
9095
stderr.writeln(argParser.usage);
9196
exit(1);
9297
}
9398
await _runABTest(
9499
runsPerTest: runsPerTest,
95100
silent: silent,
96101
localEngine: localEngine,
102+
localWebSdk: localWebSdk,
97103
localEngineSrcPath: localEngineSrcPath,
98104
deviceId: deviceId,
99105
resultsFile: resultsFile,
@@ -118,15 +124,18 @@ Future<void> main(List<String> rawArgs) async {
118124
Future<void> _runABTest({
119125
required int runsPerTest,
120126
required bool silent,
121-
required String localEngine,
127+
required String? localEngine,
128+
required String? localWebSdk,
122129
required String? localEngineSrcPath,
123130
required String? deviceId,
124131
required String resultsFile,
125132
required String taskName,
126133
}) async {
127134
print('$taskName A/B test. Will run $runsPerTest times.');
128135

129-
final ABTest abTest = ABTest(localEngine, taskName);
136+
assert(localEngine != null || localWebSdk != null);
137+
138+
final ABTest abTest = ABTest((localEngine ?? localWebSdk)!, taskName);
130139
for (int i = 1; i <= runsPerTest; i++) {
131140
section('Run #$i');
132141

@@ -152,6 +161,7 @@ Future<void> _runABTest({
152161
taskName,
153162
silent: silent,
154163
localEngine: localEngine,
164+
localWebSdk: localWebSdk,
155165
localEngineSrcPath: localEngineSrcPath,
156166
deviceId: deviceId,
157167
);
@@ -282,6 +292,14 @@ ArgParser createArgParser(List<String> taskNames) {
282292
'This path is relative to --local-engine-src-path/out. This option\n'
283293
'is required when running an A/B test (see the --ab option).',
284294
)
295+
..addOption(
296+
'local-web-sdk',
297+
help: 'Name of a build output within the engine out directory, if you\n'
298+
'are building Flutter locally. Use this to select a specific\n'
299+
'version of the engine if you have built multiple engine targets.\n'
300+
'This path is relative to --local-engine-src-path/out. This option\n'
301+
'is required when running an A/B test (see the --ab option).',
302+
)
285303
..addFlag(
286304
'list',
287305
abbr: 'l',

dev/devicelab/lib/framework/runner.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ Future<TaskResult> runTask(
153153
bool terminateStrayDartProcesses = false,
154154
bool silent = false,
155155
String? localEngine,
156+
String? localWebSdk,
156157
String? localEngineSrcPath,
157158
String? deviceId,
158159
List<String>? taskArgs,
@@ -181,6 +182,7 @@ Future<TaskResult> runTask(
181182
'--enable-vm-service=0', // zero causes the system to choose a free port
182183
'--no-pause-isolates-on-exit',
183184
if (localEngine != null) '-DlocalEngine=$localEngine',
185+
if (localWebSdk != null) '-DlocalWebSdk=$localWebSdk',
184186
if (localEngineSrcPath != null) '-DlocalEngineSrcPath=$localEngineSrcPath',
185187
taskExecutable,
186188
...?taskArgs,

dev/devicelab/lib/framework/utils.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ String? get localEngineSrcPathFromEnv {
3535
return isDefined ? const String.fromEnvironment('localEngineSrcPath') : null;
3636
}
3737

38+
/// The local Web SDK to use for [flutter] and [evalFlutter], if any.
39+
///
40+
/// This is set as an environment variable when running the task, see runTask in runner.dart.
41+
String? get localWebSdkFromEnv {
42+
const bool isDefined = bool.hasEnvironment('localWebSdk');
43+
return isDefined ? const String.fromEnvironment('localWebSdk') : null;
44+
}
45+
3846
List<ProcessInfo> _runningProcesses = <ProcessInfo>[];
3947
ProcessManager _processManager = const LocalProcessManager();
4048

@@ -446,6 +454,7 @@ List<String> _flutterCommandArgs(String command, List<String> options) {
446454
};
447455
final String? localEngine = localEngineFromEnv;
448456
final String? localEngineSrcPath = localEngineSrcPathFromEnv;
457+
final String? localWebSdk = localWebSdkFromEnv;
449458
return <String>[
450459
command,
451460
if (deviceOperatingSystem == DeviceOperatingSystem.ios && supportedDeviceTimeoutCommands.contains(command))
@@ -460,6 +469,7 @@ List<String> _flutterCommandArgs(String command, List<String> options) {
460469
],
461470
if (localEngine != null) ...<String>['--local-engine', localEngine],
462471
if (localEngineSrcPath != null) ...<String>['--local-engine-src-path', localEngineSrcPath],
472+
if (localWebSdk != null) ...<String>['--local-web-sdk', localWebSdk],
463473
...options,
464474
];
465475
}

dev/devicelab/lib/tasks/perf_tests.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,6 +1192,7 @@ class WebCompileTest {
11921192
return inDirectory<Map<String, int>>(directory, () async {
11931193
final Map<String, int> metrics = <String, int>{};
11941194

1195+
await flutter('clean');
11951196
await flutter('packages', options: <String>['get']);
11961197
final Stopwatch? watch = measureBuildTime ? Stopwatch() : null;
11971198
watch?.start();
@@ -1200,6 +1201,7 @@ class WebCompileTest {
12001201
'-v',
12011202
'--release',
12021203
'--no-pub',
1204+
'--no-web-resources-cdn',
12031205
]);
12041206
watch?.stop();
12051207
final String buildDir = path.join(directory, 'build', 'web');

dev/devicelab/lib/tasks/web_benchmarks.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ Future<TaskResult> runWebBenchmark({ required bool useCanvasKit }) async {
2525
Logger.root.level = Level.INFO;
2626
final String macrobenchmarksDirectory = path.join(flutterDirectory.path, 'dev', 'benchmarks', 'macrobenchmarks');
2727
return inDirectory(macrobenchmarksDirectory, () async {
28+
await flutter('clean');
2829
await evalFlutter('build', options: <String>[
2930
'web',
3031
'--dart-define=FLUTTER_WEB_ENABLE_PROFILING=true',
3132
'--web-renderer=${useCanvasKit ? 'canvaskit' : 'html'}',
3233
'--profile',
34+
'--no-web-resources-cdn',
3335
'-t',
3436
'lib/web_benchmarks.dart',
3537
]);

0 commit comments

Comments
 (0)