Skip to content

Commit 2c1c1bd

Browse files
authored
[web_benchmarks] Fix benchmark stalling when only repainting views that are dirty (flutter#13089)
This is required in order to reland flutter/flutter#192128. Fixes flutter/flutter#193295. The code is little bit hairy because current stable does not have `RenderView.markNeedsCompositeFrame`. I will clean it up when that changes. ## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent 6fbd01a commit 2c1c1bd

4 files changed

Lines changed: 23 additions & 5 deletions

File tree

‎packages/web_benchmarks/CHANGELOG.md‎

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

3+
* Fix benchmarks stalling when only repainting views that are dirty.
34
* Updates minimum supported SDK version to Flutter 3.41/Dart 3.11.
45

56
## 4.1.2

‎packages/web_benchmarks/lib/src/recorder.dart‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,8 @@ class _RecordingWidgetsBinding extends BindingBase
831831
super.scheduleFrame();
832832
}
833833

834+
bool _callMarkNeedsCompositeFrame = true;
835+
834836
@override
835837
void handleDrawFrame() {
836838
// Don't keep on truckin' if there's an error or the benchmark has stopped.
@@ -840,6 +842,21 @@ class _RecordingWidgetsBinding extends BindingBase
840842
try {
841843
_recorder!.frameWillDraw();
842844
super.handleDrawFrame();
845+
// Flutter will not render views that don't need compositing,
846+
// but this recorder expect preroll/applyFrame for every frame,
847+
// even if the views don't change otherwise it stalls.
848+
// See https://github.com/flutter/flutter/issues/191251
849+
for (final RenderView renderView in renderViews) {
850+
// TODO(knopp): Remove this workaround once RenderView.markNeedsCompositeFrame
851+
// is available in stable.
852+
if (_callMarkNeedsCompositeFrame) {
853+
try {
854+
(renderView as dynamic).markNeedsCompositeFrame();
855+
} on NoSuchMethodError {
856+
_callMarkNeedsCompositeFrame = false;
857+
}
858+
}
859+
}
843860
_recorder!.frameDidDraw();
844861
} catch (error, stackTrace) {
845862
_haltBenchmarkWithError(error, stackTrace);

‎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: 4.1.2
5+
version: 4.1.3
66

77
environment:
88
sdk: ^3.11.0

‎packages/web_benchmarks/testing/test_app/benchmark/web_benchmarks_test.dart‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Future<void> main() async {
2323
],
2424
entryPoint: 'benchmark/test_infra/client/app_client.dart',
2525
);
26-
}, timeout: Timeout.none);
26+
}, timeout: const Timeout(Duration(minutes: 15)));
2727

2828
test('Can run a web benchmark with an alternate benchmarkPath', () async {
2929
final BenchmarkResults results = await _runBenchmarks(
@@ -43,7 +43,7 @@ Future<void> main() async {
4343
(BenchmarkScore score) => score.metric == 'expectedUrl',
4444
);
4545
expect(expectedUrlScore.value, 1);
46-
}, timeout: Timeout.none);
46+
}, timeout: const Timeout(Duration(minutes: 15)));
4747

4848
test('Can run a web benchmark with wasm', () async {
4949
final BenchmarkResults results = await _runBenchmarks(
@@ -61,7 +61,7 @@ Future<void> main() async {
6161
(BenchmarkScore score) => score.metric == 'isWasm',
6262
);
6363
expect(isWasmScore.value, 1);
64-
}, timeout: Timeout.none);
64+
}, timeout: const Timeout(Duration(minutes: 15)));
6565
}
6666

6767
Future<BenchmarkResults> _runBenchmarks({

0 commit comments

Comments
 (0)