Skip to content

Expose FrameTiming with multiple listeners instead of a simple callback #39277

@liyuqian

Description

@liyuqian

Previously, developers have to override onReportTimings to listen for FrameTiming.
That can potentially break older onReportTimings listeners if they forget to call
the old listener in their new callback.

Now, we'll provide the ability of adding multiple callbacks similar to that of addPostFrameCallback.

For history, we previously tried a BroadcastStream approach and abandoned it: #39778

We propose to add a broadcast stream of FrameTiming, and deprecate onReportTimings (https://github.com/flutter/> engine/pull/11041).

Then, we'll remove onReportTimings entirely after a few weeks of transition time.

This change would make it safer and more convenient to listen for FrameTiming.

To migrate your code, simply add your previous callback to frameTimings.listen instead of directly assign it to > onReportTimings, and change the input parameter from a list to a single FrameTiming. See the following snippet > for an example:

WidgetsBinding.instance.window.onReportTimings = (List<FrameTiming> timings) {

==>

WidgetsBinding.instance.window.frameTimings.listen((FrameTiming frameTiming) {

See also #38861 where we remove our own usage of onReportTimings. Once it's > merged, TestWindow.onReportTimings will be a dummy method that no longer provides FrameTimings.

Metadata

Metadata

Assignees

Labels

c: performanceRelates to speed or footprint issues (see "perf:" labels)

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions