diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index d61d55c30032..ed99bb9c9341 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -440,6 +440,7 @@ APZCTreeManager::UpdateHitTestingTreeImpl(const ScrollNode& aRoot, } if (aLayerMetrics.Metrics().IsRootContent()) { + MutexAutoLock lock(mMapLock); mGeckoFixedLayerMargins = aLayerMetrics.Metrics().GetFixedLayerMargins(); } else { @@ -1894,7 +1895,7 @@ APZEventResult APZCTreeManager::ProcessTouchInput(MultiTouchInput& aInput) { } touchData.mScreenPoint = *untransformedScreenPoint; if (mFixedPosSidesForInputBlock != SideBits::eNone) { - RecursiveMutexAutoLock lock(mTreeLock); + MutexAutoLock lock(mMapLock); touchData.mScreenPoint -= RoundedToInt(AsyncCompositionManager::ComputeFixedMarginsOffset( mCompositorFixedLayerMargins, mFixedPosSidesForInputBlock, @@ -3195,6 +3196,7 @@ Maybe APZCTreeManager::ConvertToGecko( UntransformBy(transformScreenToGecko, aPoint); if (geckoPoint) { if (mFixedPosSidesForInputBlock != SideBits::eNone) { + MutexAutoLock mapLock(mMapLock); *geckoPoint -= RoundedToInt(AsyncCompositionManager::ComputeFixedMarginsOffset( mCompositorFixedLayerMargins, mFixedPosSidesForInputBlock, @@ -3330,11 +3332,15 @@ LayerToParentLayerMatrix4x4 APZCTreeManager::ComputeTransformForNode( }); } } else if (IsFixedToRootContent(aNode)) { - ParentLayerPoint translation = ViewAs( - AsyncCompositionManager::ComputeFixedMarginsOffset( - mCompositorFixedLayerMargins, aNode->GetFixedPosSides(), - mGeckoFixedLayerMargins), - PixelCastJustification::ScreenIsParentLayerForRoot); + ParentLayerPoint translation; + { + MutexAutoLock mapLock(mMapLock); + translation = ViewAs( + AsyncCompositionManager::ComputeFixedMarginsOffset( + mCompositorFixedLayerMargins, aNode->GetFixedPosSides(), + mGeckoFixedLayerMargins), + PixelCastJustification::ScreenIsParentLayerForRoot); + } return aNode->GetTransform() * CompleteAsyncTransform( AsyncTransformComponentMatrix::Translation(translation)); @@ -3445,7 +3451,7 @@ void APZCTreeManager::SendSubtreeTransformsToChromeMainThread( void APZCTreeManager::SetFixedLayerMargins(ScreenIntCoord aTop, ScreenIntCoord aBottom) { - RecursiveMutexAutoLock lock(mTreeLock); + MutexAutoLock lock(mMapLock); mCompositorFixedLayerMargins.top = aTop; mCompositorFixedLayerMargins.bottom = aBottom; } diff --git a/gfx/layers/apz/src/APZCTreeManager.h b/gfx/layers/apz/src/APZCTreeManager.h index b23c5e679d84..7844545f3044 100644 --- a/gfx/layers/apz/src/APZCTreeManager.h +++ b/gfx/layers/apz/src/APZCTreeManager.h @@ -895,13 +895,13 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge { ScreenPoint mCurrentMousePosition; /* Extra margins that should be applied to content that fixed wrt. the * RCD-RSF, to account for the dynamic toolbar. - * Acquire mTreeLock before accessing this. + * Acquire mMapLock before accessing this. */ ScreenMargin mCompositorFixedLayerMargins; /* Similar to above |mCompositorFixedLayerMargins|. But this value is the * margins on the main-thread at the last time position:fixed elements were * updated during the dynamic toolbar transitions. - * Acquire mTreeLock before accessing this. + * Acquire mMapLock before accessing this. */ ScreenMargin mGeckoFixedLayerMargins; /* For logging the APZC tree for debugging (enabled by the apz.printtree