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.
This commit is contained in:
Jackson Gardner
2024-06-27 07:26:16 -07:00
committed by GitHub
parent 50ad6ee0da
commit 5549ebaaaa
8 changed files with 27 additions and 31 deletions

View File

@ -65,7 +65,7 @@ platform_properties:
device_type: none device_type: none
dependencies: >- dependencies: >-
[ [
{"dependency": "chrome_and_driver", "version": "version:114.0"} {"dependency": "chrome_and_driver", "version": "version:125.0.6422.141"}
] ]
windows_arm64: windows_arm64:
properties: properties:
@ -327,7 +327,7 @@ targets:
{"dependency": "clang", "version": "git_revision:5d5aba78dbbee75508f01bcaa69aedb2ab79065a"}, {"dependency": "clang", "version": "git_revision:5d5aba78dbbee75508f01bcaa69aedb2ab79065a"},
{"dependency": "cmake", "version": "build_id:8787856497187628321"}, {"dependency": "cmake", "version": "build_id:8787856497187628321"},
{"dependency": "ninja", "version": "version:1.9.0"}, {"dependency": "ninja", "version": "version:1.9.0"},
{"dependency": "chrome_and_driver", "version": "version:114.0"} {"dependency": "chrome_and_driver", "version": "version:125.0.6422.141"}
] ]
channel: master channel: master
env_variables: >- env_variables: >-
@ -350,7 +350,7 @@ targets:
{"dependency": "clang", "version": "git_revision:5d5aba78dbbee75508f01bcaa69aedb2ab79065a"}, {"dependency": "clang", "version": "git_revision:5d5aba78dbbee75508f01bcaa69aedb2ab79065a"},
{"dependency": "cmake", "version": "build_id:8787856497187628321"}, {"dependency": "cmake", "version": "build_id:8787856497187628321"},
{"dependency": "ninja", "version": "version:1.9.0"}, {"dependency": "ninja", "version": "version:1.9.0"},
{"dependency": "chrome_and_driver", "version": "version:114.0"} {"dependency": "chrome_and_driver", "version": "version:125.0.6422.141"}
] ]
channel: stable channel: stable
env_variables: >- env_variables: >-
@ -935,7 +935,7 @@ targets:
# Install Chrome as a default handler for schemes for url_launcher. # Install Chrome as a default handler for schemes for url_launcher.
dependencies: >- dependencies: >-
[ [
{"dependency": "chrome_and_driver", "version": "version:114.0"} {"dependency": "chrome_and_driver", "version": "version:125.0.6422.141"}
] ]
env_variables: >- env_variables: >-
{ {
@ -953,7 +953,7 @@ targets:
# Install Chrome as a default handler for schemes for url_launcher. # Install Chrome as a default handler for schemes for url_launcher.
dependencies: >- dependencies: >-
[ [
{"dependency": "chrome_and_driver", "version": "version:114.0"} {"dependency": "chrome_and_driver", "version": "version:125.0.6422.141"}
] ]
env_variables: >- env_variables: >-
{ {

View File

@ -1,6 +1,10 @@
## NEXT ## 2.0.0
* Updates minimum supported SDK version to Flutter 3.16/Dart 3.2. * Updates minimum supported SDK version to Flutter 3.16/Dart 3.2.
* Adds support for running benchmarks with the wasm compilation target.
* **Breaking change** `CompilationOptions` unnamed constructor has been replaced with
two named constructors, `CompilationOptions.js` and `CompilationOptions.wasm` for
JavaScript and WebAssembly compilation respectively.
## 1.2.2 ## 1.2.2

View File

@ -50,7 +50,7 @@ Future<BenchmarkResults> serveWebBenchmark({
bool headless = true, bool headless = true,
bool treeShakeIcons = true, bool treeShakeIcons = true,
String initialPage = defaultInitialPage, String initialPage = defaultInitialPage,
CompilationOptions compilationOptions = const CompilationOptions(), CompilationOptions compilationOptions = const CompilationOptions.js(),
}) async { }) async {
// Reduce logging level. Otherwise, package:webkit_inspection_protocol is way too spammy. // Reduce logging level. Otherwise, package:webkit_inspection_protocol is way too spammy.
Logger.root.level = Level.INFO; Logger.root.level = Level.INFO;

View File

@ -7,11 +7,15 @@
/// This object holds metadata that is used to determine how the benchmark app /// This object holds metadata that is used to determine how the benchmark app
/// should be built. /// should be built.
class CompilationOptions { class CompilationOptions {
/// Creates a [CompilationOptions] object. /// Creates a [CompilationOptions] object that compiles to JavaScript.
const CompilationOptions({ const CompilationOptions.js({
this.renderer = WebRenderer.canvaskit, this.renderer = WebRenderer.canvaskit,
this.useWasm = false, }) : useWasm = false;
});
/// Creates a [CompilationOptions] object that compiles to WebAssembly.
const CompilationOptions.wasm()
: useWasm = true,
renderer = WebRenderer.skwasm;
/// The renderer to use for the build. /// The renderer to use for the build.
final WebRenderer renderer; final WebRenderer renderer;

View File

@ -55,7 +55,7 @@ class BenchmarkServer {
required this.chromeDebugPort, required this.chromeDebugPort,
required this.headless, required this.headless,
required this.treeShakeIcons, required this.treeShakeIcons,
this.compilationOptions = const CompilationOptions(), this.compilationOptions = const CompilationOptions.js(),
this.initialPage = defaultInitialPage, this.initialPage = defaultInitialPage,
}); });
@ -119,10 +119,9 @@ class BenchmarkServer {
'web', 'web',
if (compilationOptions.useWasm) ...<String>[ if (compilationOptions.useWasm) ...<String>[
'--wasm', '--wasm',
'--wasm-opt=debug', '--no-strip-wasm',
'--omit-type-checks', ] else
], '--web-renderer=${compilationOptions.renderer.name}',
'--web-renderer=${compilationOptions.renderer.name}',
'--dart-define=FLUTTER_WEB_ENABLE_PROFILING=true', '--dart-define=FLUTTER_WEB_ENABLE_PROFILING=true',
if (!treeShakeIcons) '--no-tree-shake-icons', if (!treeShakeIcons) '--no-tree-shake-icons',
'--profile', '--profile',

View File

@ -2,7 +2,7 @@ name: web_benchmarks
description: A benchmark harness for performance-testing Flutter apps in Chrome. description: A benchmark harness for performance-testing Flutter apps in Chrome.
repository: https://github.com/flutter/packages/tree/main/packages/web_benchmarks repository: https://github.com/flutter/packages/tree/main/packages/web_benchmarks
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+web_benchmarks%22 issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+web_benchmarks%22
version: 1.2.2 version: 2.0.0
environment: environment:
sdk: ^3.3.0 sdk: ^3.3.0

View File

@ -21,16 +21,6 @@ found in the LICENSE file. -->
<link rel="manifest" href="manifest.json"> <link rel="manifest" href="manifest.json">
</head> </head>
<body> <body>
<!-- This script installs service_worker.js to provide PWA functionality to <script src="flutter_bootstrap.js" type="application/javascript" async></script>
application. For more information, see:
https://developers.google.com/web/fundamentals/primers/service-workers -->
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', function () {
navigator.serviceWorker.register('flutter_service_worker.js');
});
}
</script>
<script src="main.dart.js" type="application/javascript"></script>
</body> </body>
</html> </html>

View File

@ -32,10 +32,9 @@ Future<void> main() async {
await _runBenchmarks( await _runBenchmarks(
benchmarkNames: <String>['simple'], benchmarkNames: <String>['simple'],
entryPoint: 'lib/benchmarks/runner_simple.dart', entryPoint: 'lib/benchmarks/runner_simple.dart',
compilationOptions: const CompilationOptions(useWasm: true), compilationOptions: const CompilationOptions.wasm(),
); );
}, },
skip: true, // https://github.com/flutter/flutter/issues/142809
timeout: Timeout.none, timeout: Timeout.none,
); );
} }
@ -44,7 +43,7 @@ Future<void> _runBenchmarks({
required List<String> benchmarkNames, required List<String> benchmarkNames,
required String entryPoint, required String entryPoint,
String initialPage = defaultInitialPage, String initialPage = defaultInitialPage,
CompilationOptions compilationOptions = const CompilationOptions(), CompilationOptions compilationOptions = const CompilationOptions.js(),
}) async { }) async {
final BenchmarkResults taskResult = await serveWebBenchmark( final BenchmarkResults taskResult = await serveWebBenchmark(
benchmarkAppDirectory: Directory('testing/test_app'), benchmarkAppDirectory: Directory('testing/test_app'),