Bug 1457246 - Don't hold the sIndirectLayerTreesLock while making synchronous calls to the RenderBackend thread. r=sotaro
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 26 Apr 2018 15:29:21 -0400
changeset 472030 d52b265b6b52a817374add2c4e927530dab571a6
parent 472029 20e6e6da280d51500e980084e17b83e768268b4c
child 472031 79bbfba09e528f51091c26a84454c0d865f5b466
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssotaro
bugs1457246
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1457246 - Don't hold the sIndirectLayerTreesLock while making synchronous calls to the RenderBackend thread. r=sotaro MozReview-Commit-ID: KzXZxCb2nA6
gfx/layers/ipc/CompositorBridgeParent.cpp
gfx/layers/ipc/CrossProcessCompositorBridgeParent.cpp
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CompositorBridgeParent.cpp
@@ -1827,19 +1827,21 @@ CompositorBridgeParent::AllocPWebRenderB
   api->SendTransaction(txn);
   RefPtr<CompositorAnimationStorage> animStorage = GetAnimationStorage();
   mWrBridge = new WebRenderBridgeParent(this, aPipelineId, mWidget, nullptr, Move(api), Move(asyncMgr), Move(animStorage));
   mWrBridge.get()->AddRef(); // IPDL reference
 
   *aIdNamespace = mWrBridge->GetIdNamespace();
   mCompositorScheduler = mWrBridge->CompositorScheduler();
   MOZ_ASSERT(mCompositorScheduler);
-  MonitorAutoLock lock(*sIndirectLayerTreesLock);
-  MOZ_ASSERT(sIndirectLayerTrees[mRootLayerTreeID].mWrBridge == nullptr);
-  sIndirectLayerTrees[mRootLayerTreeID].mWrBridge = mWrBridge;
+  { // scope lock
+    MonitorAutoLock lock(*sIndirectLayerTreesLock);
+    MOZ_ASSERT(sIndirectLayerTrees[mRootLayerTreeID].mWrBridge == nullptr);
+    sIndirectLayerTrees[mRootLayerTreeID].mWrBridge = mWrBridge;
+  }
   *aTextureFactoryIdentifier = mWrBridge->GetTextureFactoryIdentifier();
   return mWrBridge;
 }
 
 bool
 CompositorBridgeParent::DeallocPWebRenderBridgeParent(PWebRenderBridgeParent* aActor)
 {
 #ifndef MOZ_BUILD_WEBRENDER
--- a/gfx/layers/ipc/CrossProcessCompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CrossProcessCompositorBridgeParent.cpp
@@ -205,50 +205,57 @@ CrossProcessCompositorBridgeParent::Allo
 #endif
   LayersId layersId = wr::AsLayersId(aPipelineId);
   // Check to see if this child process has access to this layer tree.
   if (!LayerTreeOwnerTracker::Get()->IsMapped(layersId, OtherPid())) {
     NS_ERROR("Unexpected layers id in AllocPAPZCTreeManagerParent; dropping message...");
     return nullptr;
   }
 
-  MonitorAutoLock lock(*sIndirectLayerTreesLock);
-  MOZ_ASSERT(sIndirectLayerTrees.find(layersId) != sIndirectLayerTrees.end());
-  MOZ_ASSERT(sIndirectLayerTrees[layersId].mWrBridge == nullptr);
-  WebRenderBridgeParent* parent = nullptr;
-  WebRenderBridgeParent* root = nullptr;
-  CompositorBridgeParent* cbp = sIndirectLayerTrees[layersId].mParent;
-  if (cbp) {
-    root = sIndirectLayerTrees[cbp->RootLayerTreeId()].mWrBridge.get();
+  RefPtr<CompositorBridgeParent> cbp = nullptr;
+  RefPtr<WebRenderBridgeParent> root = nullptr;
+
+  { // scope lock
+    MonitorAutoLock lock(*sIndirectLayerTreesLock);
+    MOZ_ASSERT(sIndirectLayerTrees.find(layersId) != sIndirectLayerTrees.end());
+    MOZ_ASSERT(sIndirectLayerTrees[layersId].mWrBridge == nullptr);
+    cbp = sIndirectLayerTrees[layersId].mParent;
+    if (cbp) {
+      root = sIndirectLayerTrees[cbp->RootLayerTreeId()].mWrBridge;
+    }
   }
 
   RefPtr<wr::WebRenderAPI> api;
   if (root) {
     api = root->GetWebRenderAPI();
   }
 
   if (!root || !api) {
     // This could happen when this function is called after CompositorBridgeParent destruction.
     // This was observed during Tab move between different windows.
-    NS_WARNING(nsPrintfCString("Created child without a matching parent? root %p", root).get());
-    parent = WebRenderBridgeParent::CreateDestroyed(aPipelineId);
+    NS_WARNING(nsPrintfCString("Created child without a matching parent? root %p", root.get()).get());
+    WebRenderBridgeParent* parent = WebRenderBridgeParent::CreateDestroyed(aPipelineId);
     parent->AddRef(); // IPDL reference
     *aIdNamespace = parent->GetIdNamespace();
     *aTextureFactoryIdentifier = TextureFactoryIdentifier(LayersBackend::LAYERS_NONE);
     return parent;
   }
 
   api = api->Clone();
   RefPtr<AsyncImagePipelineManager> holder = root->AsyncImageManager();
   RefPtr<CompositorAnimationStorage> animStorage = cbp->GetAnimationStorage();
-  parent = new WebRenderBridgeParent(this, aPipelineId, nullptr, root->CompositorScheduler(), Move(api), Move(holder), Move(animStorage));
+  WebRenderBridgeParent* parent = new WebRenderBridgeParent(
+          this, aPipelineId, nullptr, root->CompositorScheduler(), Move(api), Move(holder), Move(animStorage));
   parent->AddRef(); // IPDL reference
 
-  sIndirectLayerTrees[layersId].mCrossProcessParent = this;
-  sIndirectLayerTrees[layersId].mWrBridge = parent;
+  { // scope lock
+    MonitorAutoLock lock(*sIndirectLayerTreesLock);
+    sIndirectLayerTrees[layersId].mCrossProcessParent = this;
+    sIndirectLayerTrees[layersId].mWrBridge = parent;
+  }
   *aTextureFactoryIdentifier = parent->GetTextureFactoryIdentifier();
   *aIdNamespace = parent->GetIdNamespace();
 
   return parent;
 }
 
 bool
 CrossProcessCompositorBridgeParent::DeallocPWebRenderBridgeParent(PWebRenderBridgeParent* aActor)