Bug 1280110 - Make sure compositor and layer resources are cleared when shutting down CompositorBridgeParent. r=sotaro

This commit is contained in:
Nicolas Silva 2016-06-21 17:31:21 +02:00
parent 900ff3581c
commit 878a16fd7f
2 changed files with 25 additions and 24 deletions

View File

@ -669,11 +669,16 @@ CompositorBridgeParent::ForceIsFirstPaint()
mCompositionManager->ForceIsFirstPaint();
}
bool
CompositorBridgeParent::RecvWillClose()
void
CompositorBridgeParent::StopAndClearResources()
{
CancelCurrentCompositeTask();
if (mForceCompositionTask) {
mForceCompositionTask->Cancel();
mForceCompositionTask = nullptr;
}
mPaused = true;
RemoveCompositor(mCompositorID);
// Ensure that the layer manager is destroyed before CompositorBridgeChild.
if (mLayerManager) {
@ -693,7 +698,12 @@ CompositorBridgeParent::RecvWillClose()
mCompositor->Destroy();
mCompositor = nullptr;
}
}
bool
CompositorBridgeParent::RecvWillClose()
{
StopAndClearResources();
return true;
}
@ -848,29 +858,10 @@ CompositorBridgeParent::UpdateVisibleRegion(const VisibilityCounter& aCounter,
void
CompositorBridgeParent::ActorDestroy(ActorDestroyReason why)
{
CancelCurrentCompositeTask();
if (mForceCompositionTask) {
mForceCompositionTask->Cancel();
mForceCompositionTask = nullptr;
}
mPaused = true;
StopAndClearResources();
RemoveCompositor(mCompositorID);
if (mLayerManager) {
mLayerManager->Destroy();
mLayerManager = nullptr;
}
{ // scope lock
MonitorAutoLock lock(*sIndirectLayerTreesLock);
sIndirectLayerTrees.erase(mRootLayerTreeID);
}
if (mCompositor) {
mCompositor->Destroy();
mCompositor = nullptr;
}
mCompositionManager = nullptr;
if (mApzcTreeManager) {
@ -880,6 +871,11 @@ CompositorBridgeParent::ActorDestroy(ActorDestroyReason why)
mCompositorScheduler->Destroy();
{ // scope lock
MonitorAutoLock lock(*sIndirectLayerTreesLock);
sIndirectLayerTrees.erase(mRootLayerTreeID);
}
// There are chances that the ref count reaches zero on the main thread shortly
// after this function returns while some ipdl code still needs to run on
// this thread.

View File

@ -474,6 +474,11 @@ public:
}
private:
/**
* Called during destruction in order to release resources as early as possible.
*/
void StopAndClearResources();
/**
* This returns a reference to the APZCTreeManager to which
* pan/zoom-related events can be sent.