Unverified Commit 484f3f26 authored by Yuqian Li's avatar Yuqian Li Committed by GitHub

Add FrameTiming delay to watchPerformance (#64780)

parent 7fdd9218
...@@ -28,10 +28,19 @@ Future<void> watchPerformance( ...@@ -28,10 +28,19 @@ Future<void> watchPerformance(
} }
return true; return true;
}()); }());
// The engine could batch FrameTimings and send them only once per second.
// Delay for a sufficient time so either old FrameTimings are flushed and not
// interfering our measurements here, or new FrameTimings are all reported.
Future<void> delayForFrameTimings() =>
Future<void>.delayed(const Duration(seconds: 2));
await delayForFrameTimings(); // flush old FrameTimings
final List<FrameTiming> frameTimings = <FrameTiming>[]; final List<FrameTiming> frameTimings = <FrameTiming>[];
final TimingsCallback watcher = frameTimings.addAll; final TimingsCallback watcher = frameTimings.addAll;
binding.addTimingsCallback(watcher); binding.addTimingsCallback(watcher);
await action(); await action();
await delayForFrameTimings(); // make sure all FrameTimings are reported
binding.removeTimingsCallback(watcher); binding.removeTimingsCallback(watcher);
final FrameTimingSummarizer frameTimes = FrameTimingSummarizer(frameTimings); final FrameTimingSummarizer frameTimes = FrameTimingSummarizer(frameTimings);
binding.reportData = <String, dynamic>{reportKey: frameTimes.summary}; binding.reportData = <String, dynamic>{reportKey: frameTimes.summary};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment