onReportTimings property Null safety
A callback that is invoked to report the FrameTiming of recently rasterized frames.
It's preferred to use SchedulerBinding.addTimingsCallback than to use onReportTimings directly because SchedulerBinding.addTimingsCallback allows multiple callbacks.
This can be used to see if the application has missed frames (through FrameTiming.buildDuration and FrameTiming.rasterDuration), or high latencies (through FrameTiming.totalSpan).
Unlike Timeline, the timing information here is available in the release mode (additional to the profile and the debug mode). Hence this can be used to monitor the application's performance in the wild.
The callback takes a list of FrameTiming because it may not be immediately triggered after each frame. Instead, Flutter tries to batch frames together and send all their timings at once to decrease the overhead (as this is available in the release mode). The list is sorted in ascending order of time (earliest frame first). The timing of any frame will be sent within about 1 second (100ms if in the profile/debug mode) even if there are no later frames to batch. The timing of the first frame will be sent immediately without batching.
If this is null, no additional work will be done. If this is not null, Flutter spends less than 0.1ms every 1 second to report the timings (measured on iPhone6S). The 0.1ms is about 0.6% of 16ms (frame budget for 60fps), or 0.01% CPU usage per second.
Implementation
@override
ui.TimingsCallback? get onReportTimings => _platformDispatcher.onReportTimings;
Implementation
@override
set onReportTimings(ui.TimingsCallback? callback) {
_platformDispatcher.onReportTimings = callback;
}