Skip to content

Commit 12d0b95

Browse files
Don't call OnAnimatorNotifyIdle if a frame is scheduled (flutter#7746)
If a frame is scheduled by the time the delayed animator notify idle task runs, then we should not call |NotifyIdle|. Also, add a trace event in the task, to make it more clear in traces when a notify idle call is coming from here (as opposed to |Animator::AwaitVSync|).
1 parent 5f3f3bd commit 12d0b95

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

shell/common/animator.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,13 @@ void Animator::BeginFrame(fml::TimePoint frame_start_time,
124124
if (!self.get()) {
125125
return;
126126
}
127-
// If our (this task's) task id is the same as the current one, then
128-
// no further frames were produced, and it is safe (w.r.t. jank) to
129-
// notify the engine we are idle.
130-
if (notify_idle_task_id == self->notify_idle_task_id_) {
127+
// If our (this task's) task id is the same as the current one
128+
// (meaning there were no follow up frames to the |BeginFrame| call
129+
// that posted this task) and no frame is currently scheduled, then
130+
// assume that we are idle, and notify the engine of this.
131+
if (notify_idle_task_id == self->notify_idle_task_id_ &&
132+
!self->frame_scheduled_) {
133+
TRACE_EVENT0("flutter", "BeginFrame idle callback");
131134
self->delegate_.OnAnimatorNotifyIdle(Dart_TimelineGetMicros() +
132135
100000);
133136
}

0 commit comments

Comments
 (0)