Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update web_benchmarks package to properly support wasm. #6970

Merged
merged 7 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ platform_properties:
device_type: none
dependencies: >-
[
{"dependency": "chrome_and_driver", "version": "version:114.0"}
{"dependency": "chrome_and_driver", "version": "version:125.0.6422.141"}
]
windows_arm64:
properties:
Expand Down Expand Up @@ -327,7 +327,7 @@ targets:
{"dependency": "clang", "version": "git_revision:5d5aba78dbbee75508f01bcaa69aedb2ab79065a"},
{"dependency": "cmake", "version": "build_id:8787856497187628321"},
{"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
env_variables: >-
Expand All @@ -350,7 +350,7 @@ targets:
{"dependency": "clang", "version": "git_revision:5d5aba78dbbee75508f01bcaa69aedb2ab79065a"},
{"dependency": "cmake", "version": "build_id:8787856497187628321"},
{"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
env_variables: >-
Expand Down Expand Up @@ -935,7 +935,7 @@ targets:
# Install Chrome as a default handler for schemes for url_launcher.
dependencies: >-
[
{"dependency": "chrome_and_driver", "version": "version:114.0"}
{"dependency": "chrome_and_driver", "version": "version:125.0.6422.141"}
]
env_variables: >-
{
Expand All @@ -953,7 +953,7 @@ targets:
# Install Chrome as a default handler for schemes for url_launcher.
dependencies: >-
[
{"dependency": "chrome_and_driver", "version": "version:114.0"}
{"dependency": "chrome_and_driver", "version": "version:125.0.6422.141"}
]
env_variables: >-
{
Expand Down
3 changes: 2 additions & 1 deletion packages/web_benchmarks/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## NEXT
## 2.0.0

* Updates minimum supported SDK version to Flutter 3.16/Dart 3.2.
* Adds support for running benchmarks with the wasm compilation target.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

## 1.2.2

Expand Down
2 changes: 1 addition & 1 deletion packages/web_benchmarks/lib/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Future<BenchmarkResults> serveWebBenchmark({
bool headless = true,
bool treeShakeIcons = true,
String initialPage = defaultInitialPage,
CompilationOptions compilationOptions = const CompilationOptions(),
CompilationOptions compilationOptions = const CompilationOptions.js(),
}) async {
// Reduce logging level. Otherwise, package:webkit_inspection_protocol is way too spammy.
Logger.root.level = Level.INFO;
Expand Down
12 changes: 8 additions & 4 deletions packages/web_benchmarks/lib/src/compilation_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@
/// This object holds metadata that is used to determine how the benchmark app
/// should be built.
class CompilationOptions {
/// Creates a [CompilationOptions] object.
const CompilationOptions({
Copy link
Contributor

@stuartmorgan stuartmorgan Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing a constructor from a publicly exported class is a breaking change, and all of our packages follow semver. If you want to remove this, the package needs a major version bump.

/// Creates a [CompilationOptions] object that compiles to JavaScript.
const CompilationOptions.js({
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.
final WebRenderer renderer;
Expand Down
9 changes: 4 additions & 5 deletions packages/web_benchmarks/lib/src/runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class BenchmarkServer {
required this.chromeDebugPort,
required this.headless,
required this.treeShakeIcons,
this.compilationOptions = const CompilationOptions(),
this.compilationOptions = const CompilationOptions.js(),
this.initialPage = defaultInitialPage,
});

Expand Down Expand Up @@ -119,10 +119,9 @@ class BenchmarkServer {
'web',
if (compilationOptions.useWasm) ...<String>[
'--wasm',
'--wasm-opt=debug',
'--omit-type-checks',
],
'--web-renderer=${compilationOptions.renderer.name}',
'--no-strip-wasm',
] else
'--web-renderer=${compilationOptions.renderer.name}',
'--dart-define=FLUTTER_WEB_ENABLE_PROFILING=true',
if (!treeShakeIcons) '--no-tree-shake-icons',
'--profile',
Expand Down
2 changes: 1 addition & 1 deletion packages/web_benchmarks/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: web_benchmarks
description: A benchmark harness for performance-testing Flutter apps in Chrome.
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
version: 1.2.2
version: 2.0.0

environment:
sdk: ^3.3.0
Expand Down
12 changes: 1 addition & 11 deletions packages/web_benchmarks/testing/test_app/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,6 @@
<link rel="manifest" href="manifest.json">
</head>
<body>
<!-- This script installs service_worker.js to provide PWA functionality to
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>
<script src="flutter_bootstrap.js" type="application/javascript" async></script>
</body>
</html>
5 changes: 2 additions & 3 deletions packages/web_benchmarks/testing/web_benchmarks_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ Future<void> main() async {
await _runBenchmarks(
benchmarkNames: <String>['simple'],
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,
);
}
Expand All @@ -44,7 +43,7 @@ Future<void> _runBenchmarks({
required List<String> benchmarkNames,
required String entryPoint,
String initialPage = defaultInitialPage,
CompilationOptions compilationOptions = const CompilationOptions(),
CompilationOptions compilationOptions = const CompilationOptions.js(),
}) async {
final BenchmarkResults taskResult = await serveWebBenchmark(
benchmarkAppDirectory: Directory('testing/test_app'),
Expand Down