Bug 896651 - Need to clean up resources for out-of-process layer trees when shutting down (r=mattwoodrow)
authorBill McCloskey <wmccloskey@mozilla.com>
Tue, 23 Jul 2013 14:53:22 -0700
changeset 152006 34c79a7de41f99de2a4eb0db9984a64363b758c2
parent 152005 8e63acfcabfb4159b1f830c47f26dfdf58710d17
child 152007 823a6f7499f84b5de7142d3b86e7bf7c9d715907
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs896651
milestone25.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 896651 - Need to clean up resources for out-of-process layer trees when shutting down (r=mattwoodrow)
gfx/layers/composite/ThebesLayerComposite.cpp
gfx/layers/ipc/CompositorParent.cpp
--- a/gfx/layers/composite/ThebesLayerComposite.cpp
+++ b/gfx/layers/composite/ThebesLayerComposite.cpp
@@ -146,16 +146,19 @@ ThebesLayerComposite::RenderLayer(const 
 CompositableHost*
 ThebesLayerComposite::GetCompositableHost() {
   return mBuffer.get();
 }
 
 void
 ThebesLayerComposite::CleanupResources()
 {
+  if (mBuffer)  {
+    mBuffer->Detach();
+  }
   mBuffer = nullptr;
 }
 
 gfxSize
 ThebesLayerComposite::GetEffectiveResolution()
 {
   // Work out render resolution by multiplying the resolution of our ancestors.
   // Only container layers can have frame metrics, so we start off with a
--- a/gfx/layers/ipc/CompositorParent.cpp
+++ b/gfx/layers/ipc/CompositorParent.cpp
@@ -28,16 +28,19 @@
 using namespace base;
 using namespace mozilla;
 using namespace mozilla::ipc;
 using namespace std;
 
 namespace mozilla {
 namespace layers {
 
+typedef map<uint64_t, CompositorParent::LayerTreeState> LayerTreeMap;
+static LayerTreeMap sIndirectLayerTrees;
+
 // FIXME/bug 774386: we're assuming that there's only one
 // CompositorParent, but that's not always true.  This assumption only
 // affects CrossProcessCompositorParent below.
 static Thread* sCompositorThread = nullptr;
 // manual reference count of the compositor thread.
 static int sCompositorThreadRefCount = 0;
 static MessageLoop* sMainLoop = nullptr;
 // When ContentParent::StartUp() is called, we use the Thread global.
@@ -188,16 +191,24 @@ CompositorParent::ForceIsFirstPaint()
 bool
 CompositorParent::RecvWillStop()
 {
   mPaused = true;
   RemoveCompositor(mCompositorID);
 
   // Ensure that the layer manager is destroyed before CompositorChild.
   if (mLayerManager) {
+    for (LayerTreeMap::iterator it = sIndirectLayerTrees.begin();
+         it != sIndirectLayerTrees.end(); it++)
+    {
+      LayerTreeState* lts = &it->second;
+      if (lts->mParent == this) {
+        mLayerManager->ClearCachedResources(lts->mRoot);
+      }
+    }
     mLayerManager->Destroy();
     mLayerManager = nullptr;
     mCompositionManager = nullptr;
   }
 
   return true;
 }
 
@@ -662,19 +673,16 @@ CompositorParent::SetTimeAndSampleAnimat
   }
   for (CompositorMap::iterator it = sCompositorMap->begin(); it != sCompositorMap->end(); ++it) {
     it->second->mIsTesting = aIsTesting;
     it->second->mTestTime = aTime;
     it->second->mCompositionManager->TransformShadowTree(aTime);
   }
 }
 
-typedef map<uint64_t, CompositorParent::LayerTreeState> LayerTreeMap;
-static LayerTreeMap sIndirectLayerTrees;
-
 bool
 CompositorParent::RecvNotifyChildCreated(const uint64_t& child)
 {
   NotifyChildCreated(child);
   return true;
 }
 
 void