mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Reuse a TimelineTask for the scheduler frame and animate events (#90168)
This commit is contained in:
parent
4889064ff5
commit
c2f452c0a8
@ -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 {
|
|||||||
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 {
|
|||||||
/// 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 {
|
|||||||
_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 {
|
|||||||
/// 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 {
|
|||||||
} 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);
|
||||||
|
Loading…
Reference in New Issue
Block a user