Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions packages/web_benchmarks/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.0+3

* Migrates from SingletonFlutterWindow to PlatformDispatcher API.

## 0.1.0+2

* Updates code to fix strict-cast violations.
Expand Down
13 changes: 7 additions & 6 deletions packages/web_benchmarks/lib/src/recorder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ abstract class SceneBuilderRecorder extends Recorder {
final Completer<Profile> profileCompleter = Completer<Profile>();
_profile = Profile(name: name);

window.onBeginFrame = (_) {
PlatformDispatcher.instance.onBeginFrame = (_) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This API was introduced almost three years ago (flutter/engine#20496) and has been on the stable channel for a long time. Migrating to it directly will not scarify backwards compatibility to any of the versions we care about.

try {
startMeasureFrame(profile);
onBeginFrame();
Expand All @@ -247,22 +247,23 @@ abstract class SceneBuilderRecorder extends Recorder {
rethrow;
}
};
window.onDrawFrame = () {
PlatformDispatcher.instance.onDrawFrame = () {
try {
_profile.record('drawFrameDuration', () {
final SceneBuilder sceneBuilder = SceneBuilder();
onDrawFrame(sceneBuilder);
_profile.record('sceneBuildDuration', () {
final Scene scene = sceneBuilder.build();
_profile.record('windowRenderDuration', () {
window.render(scene);
// TODO(goderbauer): Migrate to PlatformDispatcher.implicitView once v3.9.0 is the oldest supported Flutter version.
window.render(scene); // ignore: deprecated_member_use
Copy link
Member Author

Choose a reason for hiding this comment

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

The replacement API for this particular call was only introduced recently, so we cannot migrate to it yet to remain backwards compatible with older versions. Ignoring the deprecation warning for the upcoming deprecation in flutter/engine#39302.

}, reported: false);
}, reported: false);
}, reported: true);
endMeasureFrame();

if (shouldContinue()) {
window.scheduleFrame();
PlatformDispatcher.instance.scheduleFrame();
} else {
profileCompleter.complete(_profile);
}
Expand All @@ -271,7 +272,7 @@ abstract class SceneBuilderRecorder extends Recorder {
rethrow;
}
};
window.scheduleFrame();
PlatformDispatcher.instance.scheduleFrame();
return profileCompleter.future;
}
}
Expand Down Expand Up @@ -391,7 +392,7 @@ abstract class WidgetRecorder extends Recorder implements FrameRecorder {
reported: true);

if (shouldContinue()) {
window.scheduleFrame();
PlatformDispatcher.instance.scheduleFrame();
} else {
for (final VoidCallback fn in _didStopCallbacks) {
fn();
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: 0.1.0+2
version: 0.1.0+3

environment:
sdk: '>=2.17.0 <3.0.0'
Expand Down