Bug 1441324 - Move the APZCTreeManager initialization for the GPU process to CompositorBridgeParent initialization. r?rhunt
This is important because the RecvInitialize method in CompositorBridgeParent
is run via a sync IPC message, and so we are guaranteed that when return to the
caller in the UI process, the APZCTreeManager will have been created. This
ensures that when we create the APZInputBridge actors (which will happen on a
different top-level protocol, but be triggered after the sync RecvInitialize
is complete) we know that the concrete APZCTreeManager is ready for use.
MozReview-Commit-ID: KYDyJNXxQJm
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CompositorBridgeParent.cpp
@@ -352,39 +352,44 @@ void
CompositorBridgeParent::InitSameProcess(widget::CompositorWidget* aWidget,
const uint64_t& aLayerTreeId)
{
MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(NS_IsMainThread());
mWidget = aWidget;
mRootLayerTreeID = aLayerTreeId;
- if (mOptions.UseAPZ()) {
- mApzcTreeManager = new APZCTreeManager(mRootLayerTreeID);
- mApzSampler = new APZSampler(mApzcTreeManager);
- }
Initialize();
}
mozilla::ipc::IPCResult
CompositorBridgeParent::RecvInitialize(const uint64_t& aRootLayerTreeId)
{
+ MOZ_ASSERT(XRE_IsGPUProcess());
+
mRootLayerTreeID = aRootLayerTreeId;
Initialize();
return IPC_OK();
}
void
CompositorBridgeParent::Initialize()
{
MOZ_ASSERT(CompositorThread(),
"The compositor thread must be Initialized before instanciating a CompositorBridgeParent.");
+ if (mOptions.UseAPZ()) {
+ MOZ_ASSERT(!mApzcTreeManager);
+ MOZ_ASSERT(!mApzSampler);
+ mApzcTreeManager = new APZCTreeManager(mRootLayerTreeID);
+ mApzSampler = new APZSampler(mApzcTreeManager);
+ }
+
mCompositorBridgeID = 0;
// FIXME: This holds on the the fact that right now the only thing that
// can destroy this instance is initialized on the compositor thread after
// this task has been processed.
MOZ_ASSERT(CompositorLoop());
CompositorLoop()->PostTask(NewRunnableFunction("AddCompositorRunnable",
&AddCompositor,
this, &mCompositorBridgeID));
@@ -1082,28 +1087,25 @@ CompositorBridgeParent::ForceComposeToTa
AutoRestore<bool> override(mOverrideComposeReadiness);
mOverrideComposeReadiness = true;
mCompositorScheduler->ForceComposeToTarget(aTarget, aRect);
}
PAPZCTreeManagerParent*
CompositorBridgeParent::AllocPAPZCTreeManagerParent(const uint64_t& aLayersId)
{
+ // This should only ever get called in the GPU process.
+ MOZ_ASSERT(XRE_IsGPUProcess());
// We should only ever get this if APZ is enabled in this compositor.
MOZ_ASSERT(mOptions.UseAPZ());
-
+ // The mApzcTreeManager should have been created via RecvInitialize()
+ MOZ_ASSERT(mApzcTreeManager);
// The main process should pass in 0 because we assume mRootLayerTreeID
MOZ_ASSERT(aLayersId == 0);
- // This message doubles as initialization
- MOZ_ASSERT(!mApzcTreeManager);
-
- mApzcTreeManager = new APZCTreeManager(mRootLayerTreeID);
- mApzSampler = new APZSampler(mApzcTreeManager);
-
MonitorAutoLock lock(*sIndirectLayerTreesLock);
CompositorBridgeParent::LayerTreeState& state = sIndirectLayerTrees[mRootLayerTreeID];
MOZ_ASSERT(state.mParent.get() == this);
MOZ_ASSERT(!state.mApzcTreeManagerParent);
state.mApzcTreeManagerParent = new APZCTreeManagerParent(mRootLayerTreeID, mApzcTreeManager);
return state.mApzcTreeManagerParent;
}