diff --git a/widget/android/AndroidVsync.cpp b/widget/android/AndroidVsync.cpp index d0d88f8ccaaa..6aed5f1e539c 100644 --- a/widget/android/AndroidVsync.cpp +++ b/widget/android/AndroidVsync.cpp @@ -6,6 +6,7 @@ #include "AndroidVsync.h" +#include "AndroidBridge.h" #include "nsTArray.h" /** @@ -113,6 +114,8 @@ void AndroidVsync::Impl::UpdateObservingVsync() { // Always called on the Java UI thread. void AndroidVsync::NotifyVsync(int64_t aFrameTimeNanos) { + MOZ_ASSERT(AndroidBridge::IsJavaUiThread()); + // Convert aFrameTimeNanos to a TimeStamp. The value converts trivially to // the internal ticks representation of TimeStamp_posix; both use the // monotonic clock and are in nanoseconds. @@ -131,13 +134,13 @@ void AndroidVsync::NotifyVsync(int64_t aFrameTimeNanos) { } void AndroidVsync::OnMaybeUpdateRefreshRate() { - // Do not keep the lock held while calling OnVsync. + MOZ_ASSERT(NS_IsMainThread()); + + auto impl = mImpl.Lock(); + nsTArray observers; - { - auto impl = mImpl.Lock(); - observers.AppendElements(impl->mInputObservers); - observers.AppendElements(impl->mRenderObservers); - } + observers.AppendElements(impl->mRenderObservers); + for (Observer* observer : observers) { observer->OnMaybeUpdateRefreshRate(); }