Unverified Commit c2f452c0 authored by Jason Simmons's avatar Jason Simmons Committed by GitHub

Reuse a TimelineTask for the scheduler frame and animate events (#90168)

parent 4889064f
......@@ -55,7 +55,7 @@ void main() {
},
<String, dynamic>{
'name': 'listener',
'args': <String, dynamic>{'parentId': '0', 'isolateId': isolateId}
'args': <String, dynamic>{'isolateId': isolateId}
},
<String, dynamic>{
'name': 'ImageCache.clear',
......
......@@ -996,8 +996,7 @@ mixin SchedulerBinding on BindingBase {
handleDrawFrame();
}
TimelineTask? _frameTimelineTask;
TimelineTask? _animateTimelineTask;
final TimelineTask? _frameTimelineTask = kReleaseMode ? null : TimelineTask();
/// Called by the engine to prepare the framework to produce a new frame.
///
......@@ -1023,7 +1022,7 @@ mixin SchedulerBinding on BindingBase {
/// statements printed during a frame from those printed between frames (e.g.
/// in response to events or timers).
void handleBeginFrame(Duration? rawTimeStamp) {
_frameTimelineTask = TimelineTask()..start('Frame', arguments: timelineArgumentsIndicatingLandmarkEvent);
_frameTimelineTask?.start('Frame', arguments: timelineArgumentsIndicatingLandmarkEvent);
_firstRawTimeStampInEpoch ??= rawTimeStamp;
_currentFrameTimeStamp = _adjustForEpoch(rawTimeStamp ?? _lastRawTimeStamp);
if (rawTimeStamp != null)
......@@ -1050,7 +1049,7 @@ mixin SchedulerBinding on BindingBase {
_hasScheduledFrame = false;
try {
// TRANSIENT FRAME CALLBACKS
_animateTimelineTask = TimelineTask()..start('Animate', arguments: timelineArgumentsIndicatingLandmarkEvent);
_frameTimelineTask?.start('Animate', arguments: timelineArgumentsIndicatingLandmarkEvent);
_schedulerPhase = SchedulerPhase.transientCallbacks;
final Map<int, _FrameCallbackEntry> callbacks = _transientCallbacks;
_transientCallbacks = <int, _FrameCallbackEntry>{};
......@@ -1075,8 +1074,7 @@ mixin SchedulerBinding on BindingBase {
/// useful when working with frame callbacks.
void handleDrawFrame() {
assert(_schedulerPhase == SchedulerPhase.midFrameMicrotasks);
_animateTimelineTask?.finish(); // end the "Animate" phase
_animateTimelineTask = null;
_frameTimelineTask?.finish(); // end the "Animate" phase
try {
// PERSISTENT FRAME CALLBACKS
_schedulerPhase = SchedulerPhase.persistentCallbacks;
......@@ -1093,7 +1091,6 @@ mixin SchedulerBinding on BindingBase {
} finally {
_schedulerPhase = SchedulerPhase.idle;
_frameTimelineTask?.finish(); // end the Frame
_frameTimelineTask = null;
assert(() {
if (debugPrintEndFrameBanner)
debugPrint('▀' * _debugBanner!.length);
......
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