Bug 1523956 - Add a null check against mRefreshTimerVsyncDispatcher getting nulled concurrently. r=Gijs a=jcristau
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 13 Feb 2019 22:46:19 +0000
changeset 516028 b8a56742298773c4a9154d6930df5350421bdacd
parent 516027 37a1022be69b323c5ca65d28b41ab3616235db04
child 516029 14e74e8714b4b0f338489db449c8f6ea308b47e0
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, jcristau
bugs1523956
milestone66.0
Bug 1523956 - Add a null check against mRefreshTimerVsyncDispatcher getting nulled concurrently. r=Gijs a=jcristau Differential Revision: https://phabricator.services.mozilla.com/D19703
gfx/thebes/VsyncSource.cpp
--- a/gfx/thebes/VsyncSource.cpp
+++ b/gfx/thebes/VsyncSource.cpp
@@ -54,16 +54,24 @@ VsyncSource::Display::~Display() {
   mRefreshTimerVsyncDispatcher = nullptr;
   mCompositorVsyncDispatchers.Clear();
 }
 
 void VsyncSource::Display::NotifyVsync(TimeStamp aVsyncTimestamp) {
   // Called on the vsync thread
   MutexAutoLock lock(mDispatcherLock);
 
+  // mRefreshTimerVsyncDispatcher might be null here if MoveListenersToNewSource
+  // was called concurrently with this function and won the race to acquire
+  // mDispatcherLock. In this case the new VsyncSource that is replacing this
+  // one will handle notifications from now on, so we can abort.
+  if (!mRefreshTimerVsyncDispatcher) {
+    return;
+  }
+
   mVsyncId = mVsyncId.Next();
   VsyncEvent event(mVsyncId, aVsyncTimestamp);
 
   for (size_t i = 0; i < mCompositorVsyncDispatchers.Length(); i++) {
     mCompositorVsyncDispatchers[i]->NotifyVsync(event);
   }
 
   mRefreshTimerVsyncDispatcher->NotifyVsync(event);