From 69a16cbb01740e3b8b4559124b842b5877000b70 Mon Sep 17 00:00:00 2001 From: nathanrogersgoogle Date: Fri, 8 Feb 2019 15:14:06 -0800 Subject: [PATCH] Don't call OnAnimatorNotifyIdle if a frame is scheduled (flutter/engine#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|). --- engine/src/flutter/shell/common/animator.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/engine/src/flutter/shell/common/animator.cc b/engine/src/flutter/shell/common/animator.cc index 19aaad5394..9d31a0c2ea 100644 --- a/engine/src/flutter/shell/common/animator.cc +++ b/engine/src/flutter/shell/common/animator.cc @@ -124,10 +124,13 @@ void Animator::BeginFrame(fml::TimePoint frame_start_time, if (!self.get()) { return; } - // If our (this task's) task id is the same as the current one, then - // no further frames were produced, and it is safe (w.r.t. jank) to - // notify the engine we are idle. - if (notify_idle_task_id == self->notify_idle_task_id_) { + // If our (this task's) task id is the same as the current one + // (meaning there were no follow up frames to the |BeginFrame| call + // that posted this task) and no frame is currently scheduled, then + // assume that we are idle, and notify the engine of this. + if (notify_idle_task_id == self->notify_idle_task_id_ && + !self->frame_scheduled_) { + TRACE_EVENT0("flutter", "BeginFrame idle callback"); self->delegate_.OnAnimatorNotifyIdle(Dart_TimelineGetMicros() + 100000); }