Unverified Commit 78a96b09 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter] use engine provided frame number (#82934)

parent 25fa2e6c
...@@ -202,12 +202,8 @@ mixin SchedulerBinding on BindingBase { ...@@ -202,12 +202,8 @@ mixin SchedulerBinding on BindingBase {
_instance = this; _instance = this;
if (!kReleaseMode) { if (!kReleaseMode) {
int frameNumber = 0;
addTimingsCallback((List<FrameTiming> timings) { addTimingsCallback((List<FrameTiming> timings) {
for (final FrameTiming frameTiming in timings) { timings.forEach(_profileFramePostEvent);
frameNumber += 1;
_profileFramePostEvent(frameNumber, frameTiming);
}
}); });
} }
} }
...@@ -1103,9 +1099,9 @@ mixin SchedulerBinding on BindingBase { ...@@ -1103,9 +1099,9 @@ mixin SchedulerBinding on BindingBase {
} }
} }
void _profileFramePostEvent(int frameNumber, FrameTiming frameTiming) { void _profileFramePostEvent(FrameTiming frameTiming) {
postEvent('Flutter.Frame', <String, dynamic>{ postEvent('Flutter.Frame', <String, dynamic>{
'number': frameNumber, 'number': frameTiming.frameNumber,
'startTime': frameTiming.timestampInMicroseconds(FramePhase.buildStart), 'startTime': frameTiming.timestampInMicroseconds(FramePhase.buildStart),
'elapsed': frameTiming.totalSpan.inMicroseconds, 'elapsed': frameTiming.totalSpan.inMicroseconds,
'build': frameTiming.buildDuration.inMicroseconds, 'build': frameTiming.buildDuration.inMicroseconds,
......
...@@ -143,13 +143,14 @@ void main() { ...@@ -143,13 +143,14 @@ void main() {
buildFinish: 15000, buildFinish: 15000,
rasterStart: 16000, rasterStart: 16000,
rasterFinish: 20000, rasterFinish: 20000,
frameNumber: 1991
)]); )]);
final List<Map<String, dynamic>> events = scheduler.getEventsDispatched('Flutter.Frame'); final List<Map<String, dynamic>> events = scheduler.getEventsDispatched('Flutter.Frame');
expect(events, hasLength(1)); expect(events, hasLength(1));
final Map<String, dynamic> event = events.first; final Map<String, dynamic> event = events.first;
expect(event['number'], isNonNegative); expect(event['number'], 1991);
expect(event['startTime'], 10000); expect(event['startTime'], 10000);
expect(event['elapsed'], 15000); expect(event['elapsed'], 15000);
expect(event['build'], 5000); expect(event['build'], 5000);
......
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