Un-nest sceneBuildDuration and windowRenderDuration in web SceneBuilderRecorder (#193260)
Splits out the
`dev/benchmarks/macrobenchmarks/lib/src/web/recorder.dart` fix from
https://github.com/flutter/flutter/pull/193135 per review discussion
(https://github.com/flutter/flutter/pull/193135#discussion_r3075077068).
Previously, `SceneBuilderRecorder.onDrawFrame` nested
`_profile!.recordAsync('windowRenderDuration', ...)` inside synchronous
`_profile!.record('sceneBuildDuration', ...)` without awaiting
`recordAsync`, which both triggered `unawaited_futures` and caused
`sceneBuildDuration` to include the synchronous portion of
`windowRenderDuration`. This PR un-nests the two recordings and makes
`onDrawFrame` `async` so `sceneBuildDuration` only measures
`sceneBuilder.build()` and `windowRenderDuration` is properly awaited.diff --git a/dev/benchmarks/macrobenchmarks/lib/src/web/recorder.dart b/dev/benchmarks/macrobenchmarks/lib/src/web/recorder.dart
index 7b59500..32c33f4 100644
--- a/dev/benchmarks/macrobenchmarks/lib/src/web/recorder.dart
+++ b/dev/benchmarks/macrobenchmarks/lib/src/web/recorder.dart
@@ -269,17 +269,18 @@
rethrow;
}
};
- PlatformDispatcher.instance.onDrawFrame = () {
+ PlatformDispatcher.instance.onDrawFrame = () async {
try {
- _profile!.recordAsync('drawFrameDuration', () async {
+ await _profile!.recordAsync('drawFrameDuration', () async {
final sceneBuilder = SceneBuilder();
onDrawFrame(sceneBuilder);
- _profile!.recordAsync('sceneBuildDuration', () async {
- final Scene scene = sceneBuilder.build();
- _profile!.recordAsync('windowRenderDuration', () async {
- // On the web, render is asynchronous.
- await (PlatformDispatcher.instance as dynamic).render(scene);
- }, reported: false);
+ late final Scene scene;
+ _profile!.record('sceneBuildDuration', () {
+ scene = sceneBuilder.build();
+ }, reported: false);
+ await _profile!.recordAsync('windowRenderDuration', () async {
+ // On the web, render is asynchronous.
+ await (PlatformDispatcher.instance as dynamic).render(scene);
}, reported: false);
}, reported: true);
endMeasureFrame();