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