Bug 1154231 - Part 1. Use LRU to manage remote layers. r=mattwoodrow
authorKan-Ru Chen <kanru@kanru.info>
Tue, 05 May 2015 14:32:47 +0800
changeset 266188 77655fe1aab56a3c4cc7a631aa8e3e1c2b6e866a
parent 266187 ca9c2b05d6595eab2bb8de8ccd8cda3861e33538
child 266189 b9d272c24804375749013dd7c5d54ecad8a3cc48
push id2231
push usermichael.l.comella@gmail.com
push dateFri, 22 May 2015 20:04:59 +0000
reviewersmattwoodrow
bugs1154231
milestone41.0a1
Bug 1154231 - Part 1. Use LRU to manage remote layers. r=mattwoodrow
b2g/app/b2g.js
dom/ipc/TabChild.cpp
dom/ipc/TabChild.h
gfx/layers/ipc/CompositorChild.cpp
gfx/layers/ipc/CompositorChild.h
gfx/layers/ipc/CompositorLRU.cpp
gfx/layers/ipc/CompositorLRU.h
gfx/layers/ipc/CompositorParent.cpp
gfx/layers/ipc/CompositorParent.h
gfx/layers/ipc/PCompositor.ipdl
gfx/layers/moz.build
layout/build/nsLayoutStatics.cpp
modules/libpref/init/all.js
widget/PuppetWidget.cpp
--- a/b2g/app/b2g.js
+++ b/b2g/app/b2g.js
@@ -1129,8 +1129,11 @@ pref("gfx.touch.resample", true);
 
 // Comma separated list of activity names that can only be provided by
 // the system app in dev mode.
 pref("dom.activities.developer_mode_only", "import-app");
 
 // mulet apparently loads firefox.js as well as b2g.js, so we have to explicitly
 // disable serviceworkers here to get them disabled in mulet.
 pref("dom.serviceWorkers.enabled", false);
+
+// Retain at most 10 processes' layers buffers
+pref("layers.compositor-lru-size", 10);
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -2982,27 +2982,33 @@ TabChild::NotifyPainted()
         mRemoteFrame->SendNotifyCompositorTransaction();
         mNotified = true;
     }
 }
 
 void
 TabChild::MakeVisible()
 {
-    if (mWidget) {
-        mWidget->Show(true);
-    }
+  CompositorChild* compositor = CompositorChild::Get();
+  compositor->SendNotifyVisible(mLayersId);
+
+  if (mWidget) {
+    mWidget->Show(true);
+  }
 }
 
 void
 TabChild::MakeHidden()
 {
-    if (mWidget) {
-        mWidget->Show(false);
-    }
+  CompositorChild* compositor = CompositorChild::Get();
+  compositor->SendNotifyHidden(mLayersId);
+
+  if (mWidget) {
+    mWidget->Show(false);
+  }
 }
 
 void
 TabChild::UpdateHitRegion(const nsRegion& aRegion)
 {
     mRemoteFrame->SendUpdateHitRegion(aRegion);
 }
 
@@ -3134,16 +3140,27 @@ TabChild::DidComposite(uint64_t aTransac
   MOZ_ASSERT(mWidget);
   MOZ_ASSERT(mWidget->GetLayerManager());
   MOZ_ASSERT(mWidget->GetLayerManager()->GetBackendType() == LayersBackend::LAYERS_CLIENT);
 
   ClientLayerManager *manager = static_cast<ClientLayerManager*>(mWidget->GetLayerManager());
   manager->DidComposite(aTransactionId);
 }
 
+void
+TabChild::ClearCachedResources()
+{
+  MOZ_ASSERT(mWidget);
+  MOZ_ASSERT(mWidget->GetLayerManager());
+  MOZ_ASSERT(mWidget->GetLayerManager()->GetBackendType() == LayersBackend::LAYERS_CLIENT);
+
+  ClientLayerManager *manager = static_cast<ClientLayerManager*>(mWidget->GetLayerManager());
+  manager->ClearCachedResources();
+}
+
 NS_IMETHODIMP
 TabChild::OnShowTooltip(int32_t aXCoords, int32_t aYCoords, const char16_t *aTipText)
 {
     nsString str(aTipText);
     SendShowTooltip(aXCoords, aYCoords, str);
     return NS_OK;
 }
 
--- a/dom/ipc/TabChild.h
+++ b/dom/ipc/TabChild.h
@@ -471,16 +471,17 @@ public:
       nsCOMPtr<nsITabChild> tc = do_GetInterface(aDocShell);
       return static_cast<TabChild*>(tc.get());
     }
 
     static TabChild* GetFrom(nsIPresShell* aPresShell);
     static TabChild* GetFrom(uint64_t aLayersId);
 
     void DidComposite(uint64_t aTransactionId);
+    void ClearCachedResources();
 
     static inline TabChild*
     GetFrom(nsIDOMWindow* aWindow)
     {
       nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aWindow);
       nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(webNav);
       return GetFrom(docShell);
     }
--- a/gfx/layers/ipc/CompositorChild.cpp
+++ b/gfx/layers/ipc/CompositorChild.cpp
@@ -367,16 +367,26 @@ CompositorChild::RecvOverfill(const uint
 
 void
 CompositorChild::AddOverfillObserver(ClientLayerManager* aLayerManager)
 {
   MOZ_ASSERT(aLayerManager);
   mOverfillObservers.AppendElement(aLayerManager);
 }
 
+bool
+CompositorChild::RecvClearCachedResources(const uint64_t& aId)
+{
+  dom::TabChild* child = dom::TabChild::GetFrom(aId);
+  if (child) {
+    child->ClearCachedResources();
+  }
+  return true;
+}
+
 void
 CompositorChild::ActorDestroy(ActorDestroyReason aWhy)
 {
   MOZ_ASSERT(!mCanSend);
   MOZ_ASSERT(sCompositor == this);
 
 #ifdef MOZ_B2G
   // Due to poor lifetime management of gralloc (and possibly shmems) we will
@@ -545,16 +555,36 @@ CompositorChild::SendResume()
   MOZ_ASSERT(mCanSend);
   if (!mCanSend) {
     return true;
   }
   return PCompositorChild::SendResume();
 }
 
 bool
+CompositorChild::SendNotifyHidden(const uint64_t& id)
+{
+  MOZ_ASSERT(mCanSend);
+  if (!mCanSend) {
+    return true;
+  }
+  return PCompositorChild::SendNotifyHidden(id);
+}
+
+bool
+CompositorChild::SendNotifyVisible(const uint64_t& id)
+{
+  MOZ_ASSERT(mCanSend);
+  if (!mCanSend) {
+    return true;
+  }
+  return PCompositorChild::SendNotifyVisible(id);
+}
+
+bool
 CompositorChild::SendNotifyChildCreated(const uint64_t& id)
 {
   MOZ_ASSERT(mCanSend);
   if (!mCanSend) {
     return true;
   }
   return PCompositorChild::SendNotifyChildCreated(id);
 }
--- a/gfx/layers/ipc/CompositorChild.h
+++ b/gfx/layers/ipc/CompositorChild.h
@@ -66,16 +66,19 @@ public:
 
   static CompositorChild* Get();
 
   static bool ChildProcessHasCompositor() { return sCompositor != nullptr; }
 
   void AddOverfillObserver(ClientLayerManager* aLayerManager);
 
   virtual bool
+  RecvClearCachedResources(const uint64_t& id) override;
+
+  virtual bool
   RecvDidComposite(const uint64_t& aId, const uint64_t& aTransactionId) override;
 
   virtual bool
   RecvInvalidateAll() override;
 
   virtual bool
   RecvOverfill(const uint32_t &aOverfill) override;
 
@@ -101,16 +104,18 @@ public:
   // are not virtual), they just overload them.
   // All of these Send* methods just add a sanity check (that it is not too late
   // send a message) and forward the call to the super-class's equivalent method.
   // This means that it is correct to call directly the super-class methods, but
   // you won't get the extra safety provided here.
   bool SendWillStop();
   bool SendPause();
   bool SendResume();
+  bool SendNotifyHidden(const uint64_t& id);
+  bool SendNotifyVisible(const uint64_t& id);
   bool SendNotifyChildCreated(const uint64_t& id);
   bool SendAdoptChild(const uint64_t& id);
   bool SendMakeSnapshot(const SurfaceDescriptor& inSnapshot, const gfx::IntRect& dirtyRect);
   bool SendFlushRendering();
   bool SendGetTileSize(int32_t* tileWidth, int32_t* tileHeight);
   bool SendStartFrameTimeRecording(const int32_t& bufferSize, uint32_t* startIndex);
   bool SendStopFrameTimeRecording(const uint32_t& startIndex, nsTArray<float>* intervals);
   bool SendNotifyRegionInvalidated(const nsIntRegion& region);
new file mode 100644
--- /dev/null
+++ b/gfx/layers/ipc/CompositorLRU.cpp
@@ -0,0 +1,101 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ * vim: sw=2 ts=8 et :
+ */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "CompositorLRU.h"
+
+#include "mozilla/ClearOnShutdown.h"
+#include "mozilla/DebugOnly.h"
+#include "mozilla/Preferences.h"
+#include "mozilla/unused.h"
+
+#include "CompositorParent.h"
+
+namespace mozilla {
+namespace layers {
+
+mozilla::StaticRefPtr<CompositorLRU> CompositorLRU::sSingleton;
+
+void
+CompositorLRU::Init()
+{
+  unused << GetSingleton();
+}
+
+CompositorLRU*
+CompositorLRU::GetSingleton()
+{
+  if (sSingleton) {
+    return sSingleton;
+  }
+  sSingleton = new CompositorLRU();
+  ClearOnShutdown(&sSingleton);
+
+  return sSingleton;
+}
+
+CompositorLRU::CompositorLRU()
+{
+  mLRUSize = Preferences::GetUint("layers.compositor-lru-size", uint32_t(0));
+}
+
+CompositorLRU::~CompositorLRU()
+{
+}
+
+void
+CompositorLRU::Add(PCompositorParent* aCompositor, const uint64_t& aId)
+{
+  auto index = mLRU.IndexOf(std::make_pair(aCompositor, aId));
+  if (index != nsTArray<CompositorLayerPair>::NoIndex) {
+    return;
+  }
+
+  if (mLRUSize == 0) {
+    unused << aCompositor->SendClearCachedResources(aId);
+    return;
+  }
+
+  if (mLRU.Length() == mLRUSize) {
+    CompositorLayerPair victim = mLRU.LastElement();
+    unused << victim.first->SendClearCachedResources(victim.second);
+    mLRU.RemoveElement(victim);
+  }
+  mLRU.InsertElementAt(0, std::make_pair(aCompositor, aId));
+}
+
+void
+CompositorLRU::Remove(PCompositorParent* aCompositor, const uint64_t& aId)
+{
+  if (mLRUSize == 0) {
+    return;
+  }
+
+  auto index = mLRU.IndexOf(std::make_pair(aCompositor, aId));
+
+  if (index == nsTArray<PCompositorParent*>::NoIndex) {
+    return;
+  }
+
+  mLRU.RemoveElementAt(index);
+}
+
+void
+CompositorLRU::Remove(PCompositorParent* aCompositor)
+{
+  if (mLRUSize == 0) {
+    return;
+  }
+
+  for (int32_t i = mLRU.Length() - 1; i >= 0; --i) {
+    if (mLRU[i].first == aCompositor) {
+      mLRU.RemoveElementAt(i);
+    }
+  }
+}
+
+} // namespace layers
+} // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/gfx/layers/ipc/CompositorLRU.h
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ * vim: sw=2 ts=8 et :
+ */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_CompositorLRU_h
+#define mozilla_CompositorLRU_h
+
+#include "mozilla/StaticPtr.h"
+
+#include "nsISupportsImpl.h"
+#include "nsTArray.h"
+
+#include <utility>
+
+namespace mozilla {
+namespace layers {
+
+class PCompositorParent;
+
+class CompositorLRU final
+{
+  typedef std::pair<PCompositorParent*, uint64_t> CompositorLayerPair;
+public:
+  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CompositorLRU)
+
+  static void Init();
+  static CompositorLRU* GetSingleton();
+
+  /**
+   * Adds the (PCompositorParent, LayerId) pair to the LRU pool. If
+   * the pool size grows over mLRUSize, the oldest PCompositorParent
+   * is evicted.
+   */
+  void Add(PCompositorParent* aCompositor, const uint64_t& id);
+
+  /**
+   * Remove the (PCompositorParent, LayersId) pair from the LRU pool.
+   */
+  void Remove(PCompositorParent* aCompositor, const uint64_t& id);
+
+  /**
+   * Remove all PCompositorParents from the LRU pool.
+   */
+  void Remove(PCompositorParent* aCompositor);
+
+private:
+  static StaticRefPtr<CompositorLRU> sSingleton;
+
+  CompositorLRU();
+  ~CompositorLRU();
+  uint32_t mLRUSize;
+  nsTArray<CompositorLayerPair> mLRU;
+};
+
+} // namespace layers
+} // namespace mozilla
+
+#endif // mozilla_CompositorLRU_h
--- a/gfx/layers/ipc/CompositorParent.cpp
+++ b/gfx/layers/ipc/CompositorParent.cpp
@@ -29,16 +29,17 @@
 #include "mozilla/gfx/Point.h"          // for IntSize
 #include "mozilla/gfx/Rect.h"          // for IntSize
 #include "mozilla/ipc/Transport.h"      // for Transport
 #include "mozilla/layers/APZCTreeManager.h"  // for APZCTreeManager
 #include "mozilla/layers/APZThreadUtils.h"  // for APZCTreeManager
 #include "mozilla/layers/AsyncCompositionManager.h"
 #include "mozilla/layers/BasicCompositor.h"  // for BasicCompositor
 #include "mozilla/layers/Compositor.h"  // for Compositor
+#include "mozilla/layers/CompositorLRU.h"  // for CompositorLRU
 #include "mozilla/layers/CompositorOGL.h"  // for CompositorOGL
 #include "mozilla/layers/CompositorTypes.h"
 #include "mozilla/layers/LayerManagerComposite.h"
 #include "mozilla/layers/LayersTypes.h"
 #include "mozilla/layers/PLayerTransactionParent.h"
 #include "mozilla/layers/ShadowLayersManager.h" // for ShadowLayersManager
 #include "mozilla/mozalloc.h"           // for operator new, etc
 #include "mozilla/Telemetry.h"
@@ -1681,16 +1682,18 @@ public:
   virtual void ActorDestroy(ActorDestroyReason aWhy) override;
 
   // FIXME/bug 774388: work out what shutdown protocol we need.
   virtual bool RecvRequestOverfill() override { return true; }
   virtual bool RecvWillStop() override { return true; }
   virtual bool RecvStop() override { return true; }
   virtual bool RecvPause() override { return true; }
   virtual bool RecvResume() override { return true; }
+  virtual bool RecvNotifyHidden(const uint64_t& id) override;
+  virtual bool RecvNotifyVisible(const uint64_t& id) override;
   virtual bool RecvNotifyChildCreated(const uint64_t& child) override;
   virtual bool RecvAdoptChild(const uint64_t& child) override { return false; }
   virtual bool RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot,
                                 const gfx::IntRect& aRect) override
   { return true; }
   virtual bool RecvFlushRendering() override { return true; }
   virtual bool RecvNotifyRegionInvalidated(const nsIntRegion& aRegion) override { return true; }
   virtual bool RecvStartFrameTimeRecording(const int32_t& aBufferSize, uint32_t* aOutStartIndex) override { return true; }
@@ -1837,25 +1840,44 @@ CompositorParent::GetIndirectShadowTree(
   LayerTreeMap::iterator cit = sIndirectLayerTrees.find(aId);
   if (sIndirectLayerTrees.end() == cit) {
     return nullptr;
   }
   return &cit->second;
 }
 
 bool
+CrossProcessCompositorParent::RecvNotifyHidden(const uint64_t& id)
+{
+  nsRefPtr<CompositorLRU> lru = CompositorLRU::GetSingleton();
+  lru->Add(this, id);
+  return true;
+}
+
+bool
+CrossProcessCompositorParent::RecvNotifyVisible(const uint64_t& id)
+{
+  nsRefPtr<CompositorLRU> lru = CompositorLRU::GetSingleton();
+  lru->Remove(this, id);
+  return true;
+}
+
+bool
 CrossProcessCompositorParent::RecvRequestNotifyAfterRemotePaint()
 {
   mNotifyAfterRemotePaint = true;
   return true;
 }
 
 void
 CrossProcessCompositorParent::ActorDestroy(ActorDestroyReason aWhy)
 {
+  nsRefPtr<CompositorLRU> lru = CompositorLRU::GetSingleton();
+  lru->Remove(this);
+
   MessageLoop::current()->PostTask(
     FROM_HERE,
     NewRunnableMethod(this, &CrossProcessCompositorParent::DeferredDestroy));
 }
 
 PLayerTransactionParent*
 CrossProcessCompositorParent::AllocPLayerTransactionParent(const nsTArray<LayersBackend>&,
                                                            const uint64_t& aId,
--- a/gfx/layers/ipc/CompositorParent.h
+++ b/gfx/layers/ipc/CompositorParent.h
@@ -229,16 +229,18 @@ public:
                 base::ProcessHandle aPeerProcess,
                 mozilla::ipc::ProtocolCloneContext* aCtx) override;
 
   virtual bool RecvRequestOverfill() override;
   virtual bool RecvWillStop() override;
   virtual bool RecvStop() override;
   virtual bool RecvPause() override;
   virtual bool RecvResume() override;
+  virtual bool RecvNotifyHidden(const uint64_t& id) override { return true; }
+  virtual bool RecvNotifyVisible(const uint64_t& id) override { return true; }
   virtual bool RecvNotifyChildCreated(const uint64_t& child) override;
   virtual bool RecvAdoptChild(const uint64_t& child) override;
   virtual bool RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot,
                                 const gfx::IntRect& aRect) override;
   virtual bool RecvFlushRendering() override;
 
   virtual bool RecvGetTileSize(int32_t* aWidth, int32_t* aHeight) override;
 
--- a/gfx/layers/ipc/PCompositor.ipdl
+++ b/gfx/layers/ipc/PCompositor.ipdl
@@ -65,31 +65,45 @@ child:
                                    PluginWindowData[] aPlugins);
 
   /**
    * Sets the list of currently visible plugin windows based on a
    * list of plugin window ids.
    */
   async UpdatePluginVisibility(uintptr_t[] aVisibleIdList);
 
+  /**
+   * Drop any buffers that might be retained on the child compositor
+   * side.
+   */
+  async ClearCachedResources(uint64_t id);
+
 parent:
   // Child sends the parent a request for fill ratio numbers.
   async RequestOverfill();
 
   // The child is about to be destroyed, so perform any necessary cleanup.
   sync WillStop();
 
   // Clean up in preparation for own destruction.
   sync Stop();
 
   // Pause/resume the compositor. These are intended to be used on mobile, when
   // the compositor needs to pause/resume in lockstep with the application.
   sync Pause();
   sync Resume();
 
+  // The child layer tree is hidden. id is the layers id of the child
+  // layer tree.
+  async NotifyHidden(uint64_t id);
+
+  // The child layer tree is visible. id is the layers id of the child
+  // layer tree.
+  async NotifyVisible(uint64_t id);
+
   async NotifyChildCreated(uint64_t id);
   async AdoptChild(uint64_t id);
 
   // Make a snapshot of the content that would have been drawn to our
   // render target at the time this message is received.  If the size
   // or format of |inSnapshot| doesn't match our render target,
   // results are undefined.
   //
--- a/gfx/layers/moz.build
+++ b/gfx/layers/moz.build
@@ -134,16 +134,17 @@ EXPORTS.mozilla.layers += [
     'D3D11ShareHandleImage.h',
     'D3D9SurfaceImage.h',
     'Effects.h',
     'ImageDataSerializer.h',
     'ipc/AsyncTransactionTracker.h',
     'ipc/CompositableForwarder.h',
     'ipc/CompositableTransactionParent.h',
     'ipc/CompositorChild.h',
+    'ipc/CompositorLRU.h',
     'ipc/CompositorParent.h',
     'ipc/FenceUtils.h',
     'ipc/ImageBridgeChild.h',
     'ipc/ImageBridgeParent.h',
     'ipc/ISurfaceAllocator.h',
     'ipc/LayerTransactionChild.h',
     'ipc/LayerTransactionParent.h',
     'ipc/ShadowLayers.h',
@@ -286,16 +287,17 @@ UNIFIED_SOURCES += [
     'Effects.cpp',
     'GLImages.cpp',
     'ImageDataSerializer.cpp',
     'ImageLayers.cpp',
     'ipc/AsyncTransactionTracker.cpp',
     'ipc/CompositableTransactionParent.cpp',
     'ipc/CompositorBench.cpp',
     'ipc/CompositorChild.cpp',
+    'ipc/CompositorLRU.cpp',
     'ipc/CompositorParent.cpp',
     'ipc/FenceUtils.cpp',
     'ipc/ImageBridgeChild.cpp',
     'ipc/ImageBridgeParent.cpp',
     'ipc/ISurfaceAllocator.cpp',
     'ipc/LayerTransactionChild.cpp',
     'ipc/LayerTransactionParent.cpp',
     'ipc/ShadowLayerChild.cpp',
--- a/layout/build/nsLayoutStatics.cpp
+++ b/layout/build/nsLayoutStatics.cpp
@@ -134,16 +134,17 @@ using namespace mozilla::system;
 #include "mozilla/dom/time/DateCacheCleaner.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/IMEStateManager.h"
 #include "nsDocument.h"
 #include "mozilla/dom/HTMLVideoElement.h"
 #include "CameraPreferences.h"
 #include "TouchManager.h"
 #include "MediaDecoder.h"
+#include "mozilla/layers/CompositorLRU.h"
 
 using namespace mozilla;
 using namespace mozilla::net;
 using namespace mozilla::dom;
 using namespace mozilla::dom::ipc;
 
 nsrefcnt nsLayoutStatics::sLayoutStaticRefcnt = 0;
 
@@ -315,16 +316,18 @@ nsLayoutStatics::Initialize()
   nsStyleContext::Initialize();
   mozilla::css::CommonAnimationManager::Initialize();
 #endif
 
   MediaDecoder::InitStatics();
 
   PromiseDebugging::Init();
 
+  layers::CompositorLRU::Init();
+
   return NS_OK;
 }
 
 void
 nsLayoutStatics::Shutdown()
 {
   // Don't need to shutdown nsWindowMemoryReporter, that will be done by the
   // memory reporter manager.
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -4150,16 +4150,19 @@ pref("layers.d3d11.disable-warp", false)
 
 // Force all possible layers to be always active layers
 pref("layers.force-active", false);
 
 // Never use gralloc surfaces, even when they're available on this
 // platform and are the optimal surface type.
 pref("layers.gralloc.disable", false);
 
+// Don't use compositor-lru on this platform
+pref("layers.compositor-lru-size", 0);
+
 // Enable/Disable the geolocation API for content
 pref("geo.enabled", true);
 
 // Enable/Disable the orientation API for content
 pref("device.sensors.enabled", true);
 
 // Enable/Disable the device storage API for content
 pref("device.storage.enabled", false);
--- a/widget/PuppetWidget.cpp
+++ b/widget/PuppetWidget.cpp
@@ -172,20 +172,16 @@ PuppetWidget::Show(bool aState)
 
   bool wasVisible = mVisible;
   mVisible = aState;
 
   if (mChild) {
     mChild->mVisible = aState;
   }
 
-  if (!mVisible && mLayerManager) {
-    mLayerManager->ClearCachedResources();
-  }
-
   if (!wasVisible && mVisible) {
     Resize(mBounds.width, mBounds.height, false);
     Invalidate(mBounds);
   }
 
   return NS_OK;
 }