Skip to content

Commit 5549eba

Browse files
Update web_benchmarks package to properly support wasm. (#6970)
This fixes the web_benchmarks package so it can compile and run apps with wasm. It also updates our CI steps to use a newer version of Chrome so that WasmGC works properly.
1 parent 50ad6ee commit 5549eba

File tree

8 files changed

+27
-31
lines changed

8 files changed

+27
-31
lines changed

.ci.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ platform_properties:
6565
device_type: none
6666
dependencies: >-
6767
[
68-
{"dependency": "chrome_and_driver", "version": "version:114.0"}
68+
{"dependency": "chrome_and_driver", "version": "version:125.0.6422.141"}
6969
]
7070
windows_arm64:
7171
properties:
@@ -327,7 +327,7 @@ targets:
327327
{"dependency": "clang", "version": "git_revision:5d5aba78dbbee75508f01bcaa69aedb2ab79065a"},
328328
{"dependency": "cmake", "version": "build_id:8787856497187628321"},
329329
{"dependency": "ninja", "version": "version:1.9.0"},
330-
{"dependency": "chrome_and_driver", "version": "version:114.0"}
330+
{"dependency": "chrome_and_driver", "version": "version:125.0.6422.141"}
331331
]
332332
channel: master
333333
env_variables: >-
@@ -350,7 +350,7 @@ targets:
350350
{"dependency": "clang", "version": "git_revision:5d5aba78dbbee75508f01bcaa69aedb2ab79065a"},
351351
{"dependency": "cmake", "version": "build_id:8787856497187628321"},
352352
{"dependency": "ninja", "version": "version:1.9.0"},
353-
{"dependency": "chrome_and_driver", "version": "version:114.0"}
353+
{"dependency": "chrome_and_driver", "version": "version:125.0.6422.141"}
354354
]
355355
channel: stable
356356
env_variables: >-
@@ -935,7 +935,7 @@ targets:
935935
# Install Chrome as a default handler for schemes for url_launcher.
936936
dependencies: >-
937937
[
938-
{"dependency": "chrome_and_driver", "version": "version:114.0"}
938+
{"dependency": "chrome_and_driver", "version": "version:125.0.6422.141"}
939939
]
940940
env_variables: >-
941941
{
@@ -953,7 +953,7 @@ targets:
953953
# Install Chrome as a default handler for schemes for url_launcher.
954954
dependencies: >-
955955
[
956-
{"dependency": "chrome_and_driver", "version": "version:114.0"}
956+
{"dependency": "chrome_and_driver", "version": "version:125.0.6422.141"}
957957
]
958958
env_variables: >-
959959
{

packages/web_benchmarks/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
## NEXT
1+
## 2.0.0
22

33
* Updates minimum supported SDK version to Flutter 3.16/Dart 3.2.
4+
* Adds support for running benchmarks with the wasm compilation target.
5+
* **Breaking change** `CompilationOptions` unnamed constructor has been replaced with
6+
two named constructors, `CompilationOptions.js` and `CompilationOptions.wasm` for
7+
JavaScript and WebAssembly compilation respectively.
48

59
## 1.2.2
610

packages/web_benchmarks/lib/server.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Future<BenchmarkResults> serveWebBenchmark({
5050
bool headless = true,
5151
bool treeShakeIcons = true,
5252
String initialPage = defaultInitialPage,
53-
CompilationOptions compilationOptions = const CompilationOptions(),
53+
CompilationOptions compilationOptions = const CompilationOptions.js(),
5454
}) async {
5555
// Reduce logging level. Otherwise, package:webkit_inspection_protocol is way too spammy.
5656
Logger.root.level = Level.INFO;

packages/web_benchmarks/lib/src/compilation_options.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@
77
/// This object holds metadata that is used to determine how the benchmark app
88
/// should be built.
99
class CompilationOptions {
10-
/// Creates a [CompilationOptions] object.
11-
const CompilationOptions({
10+
/// Creates a [CompilationOptions] object that compiles to JavaScript.
11+
const CompilationOptions.js({
1212
this.renderer = WebRenderer.canvaskit,
13-
this.useWasm = false,
14-
});
13+
}) : useWasm = false;
14+
15+
/// Creates a [CompilationOptions] object that compiles to WebAssembly.
16+
const CompilationOptions.wasm()
17+
: useWasm = true,
18+
renderer = WebRenderer.skwasm;
1519

1620
/// The renderer to use for the build.
1721
final WebRenderer renderer;

packages/web_benchmarks/lib/src/runner.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class BenchmarkServer {
5555
required this.chromeDebugPort,
5656
required this.headless,
5757
required this.treeShakeIcons,
58-
this.compilationOptions = const CompilationOptions(),
58+
this.compilationOptions = const CompilationOptions.js(),
5959
this.initialPage = defaultInitialPage,
6060
});
6161

@@ -119,10 +119,9 @@ class BenchmarkServer {
119119
'web',
120120
if (compilationOptions.useWasm) ...<String>[
121121
'--wasm',
122-
'--wasm-opt=debug',
123-
'--omit-type-checks',
124-
],
125-
'--web-renderer=${compilationOptions.renderer.name}',
122+
'--no-strip-wasm',
123+
] else
124+
'--web-renderer=${compilationOptions.renderer.name}',
126125
'--dart-define=FLUTTER_WEB_ENABLE_PROFILING=true',
127126
if (!treeShakeIcons) '--no-tree-shake-icons',
128127
'--profile',

packages/web_benchmarks/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: web_benchmarks
22
description: A benchmark harness for performance-testing Flutter apps in Chrome.
33
repository: https://github.com/flutter/packages/tree/main/packages/web_benchmarks
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+web_benchmarks%22
5-
version: 1.2.2
5+
version: 2.0.0
66

77
environment:
88
sdk: ^3.3.0

packages/web_benchmarks/testing/test_app/web/index.html

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@
2121
<link rel="manifest" href="manifest.json">
2222
</head>
2323
<body>
24-
<!-- This script installs service_worker.js to provide PWA functionality to
25-
application. For more information, see:
26-
https://developers.google.com/web/fundamentals/primers/service-workers -->
27-
<script>
28-
if ('serviceWorker' in navigator) {
29-
window.addEventListener('load', function () {
30-
navigator.serviceWorker.register('flutter_service_worker.js');
31-
});
32-
}
33-
</script>
34-
<script src="main.dart.js" type="application/javascript"></script>
24+
<script src="flutter_bootstrap.js" type="application/javascript" async></script>
3525
</body>
3626
</html>

packages/web_benchmarks/testing/web_benchmarks_test.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ Future<void> main() async {
3232
await _runBenchmarks(
3333
benchmarkNames: <String>['simple'],
3434
entryPoint: 'lib/benchmarks/runner_simple.dart',
35-
compilationOptions: const CompilationOptions(useWasm: true),
35+
compilationOptions: const CompilationOptions.wasm(),
3636
);
3737
},
38-
skip: true, // https://github.com/flutter/flutter/issues/142809
3938
timeout: Timeout.none,
4039
);
4140
}
@@ -44,7 +43,7 @@ Future<void> _runBenchmarks({
4443
required List<String> benchmarkNames,
4544
required String entryPoint,
4645
String initialPage = defaultInitialPage,
47-
CompilationOptions compilationOptions = const CompilationOptions(),
46+
CompilationOptions compilationOptions = const CompilationOptions.js(),
4847
}) async {
4948
final BenchmarkResults taskResult = await serveWebBenchmark(
5049
benchmarkAppDirectory: Directory('testing/test_app'),

0 commit comments

Comments
 (0)