Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save chinmaygarde/45a9becb8a591899ed9378771c1f7d65 to your computer and use it in GitHub Desktop.

Select an option

Save chinmaygarde/45a9becb8a591899ed9378771c1f7d65 to your computer and use it in GitHub Desktop.
diff --git a/shell/common/vsync_waiter.cc b/shell/common/vsync_waiter.cc
index b6b55df11..2a21d3fd9 100644
--- a/shell/common/vsync_waiter.cc
+++ b/shell/common/vsync_waiter.cc
@@ -28,9 +28,23 @@ VsyncWaiter::VsyncWaiter(blink::TaskRunners task_runners)
VsyncWaiter::~VsyncWaiter() = default;
+// Public method invoked by the animator.
void VsyncWaiter::AsyncWaitForVsync(Callback callback) {
+ if (!callback) {
+ return;
+ }
+
+ TRACE_EVENT0("flutter", "AsyncWaitForVsync");
+
{
std::lock_guard<std::mutex> lock(callback_mutex_);
+ if (callback_) {
+ // The animator may request a frame more than once within a frame
+ // interval. Multiple calls to request frame must result in a single
+ // callback per frame interval.
+ TRACE_EVENT_INSTANT0("flutter", "MultipleCallsToVsyncInFrameInterval");
+ return;
+ }
callback_ = std::move(callback);
}
AwaitVSync();
@@ -46,6 +60,10 @@ void VsyncWaiter::FireCallback(fml::TimePoint frame_start_time,
}
if (!callback) {
+ // This means that the vsync waiter implementation fired a callback for a
+ // request we did not make. This is a paranoid check but we still want to
+ // make sure we catch misbehaving vsync implementations.
+ TRACE_EVENT_INSTANT0("flutter", "MismatchedFrameCallback");
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment