Bug 1282283 - Fix data race found by TSan. r?sewardj draft
authorKartikaya Gupta <kgupta@mozilla.com>
Sun, 26 Jun 2016 12:24:52 -0400
changeset 381373 7e6a77e6e7a821ede17d14e2ee9a5ee7ec8117ca
parent 381369 c2da34d96746288b5fee27bf6542a12c9f410988
child 523944 380b5cb1aedc5b4a6ce758719c55450b11763936
push id21456
push userkgupta@mozilla.com
push dateSun, 26 Jun 2016 16:25:30 +0000
reviewerssewardj
bugs1282283
milestone50.0a1
Bug 1282283 - Fix data race found by TSan. r?sewardj MozReview-Commit-ID: FQofrD4S5iO
gfx/layers/apz/src/APZCTreeManager.cpp
--- a/gfx/layers/apz/src/APZCTreeManager.cpp
+++ b/gfx/layers/apz/src/APZCTreeManager.cpp
@@ -687,18 +687,21 @@ APZCTreeManager::ReceiveInputEvent(Input
       }
 
       bool hitScrollbar = false;
       RefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(mouseInput.mOrigin,
             &hitResult, &hitScrollbar);
 
       // When the mouse is outside the window we still want to handle dragging
       // but we won't find an APZC. Fallback to root APZC then.
-      if (!apzc && mRootNode) {
-        apzc = mRootNode->GetApzc();
+      { // scope lock
+        MutexAutoLock lock(mTreeLock);
+        if (!apzc && mRootNode) {
+          apzc = mRootNode->GetApzc();
+        }
       }
 
       if (apzc) {
         bool targetConfirmed = (hitResult != HitNothing && hitResult != HitDispatchToContentRegion);
         if (gfxPrefs::APZDragEnabled() && hitScrollbar) {
           // If scrollbar dragging is enabled and we hit a scrollbar, wait
           // for the main-thread confirmation because it contains drag metrics
           // that we need.