Bug 1457246 - Don't hold the sIndirectLayerTreesLock while making synchronous calls to the RenderBackend thread. r?sotaro
MozReview-Commit-ID: KzXZxCb2nA6
--- 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)