Remove CompositorLRU and associated code. (bug 1287362, r=mattwoodrow)
authorDavid Anderson <danderson@mozilla.com>
Tue, 19 Jul 2016 21:12:54 -0700
changeset 345798 ddbf5e3673c45af29d6a244054b86318dfaf750d
parent 345797 9b7f6c64fe0376b5e82ceb8cdb35552fe63f0982
child 345799 2f06a834332a2f4b2af8a6d4411248f787c7d391
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1287362
milestone50.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
Remove CompositorLRU and associated code. (bug 1287362, r=mattwoodrow)
dom/ipc/TabChild.cpp
gfx/layers/ipc/CompositorBridgeChild.cpp
gfx/layers/ipc/CompositorBridgeChild.h
gfx/layers/ipc/CompositorBridgeParent.cpp
gfx/layers/ipc/CompositorBridgeParent.h
gfx/layers/ipc/CompositorLRU.cpp
gfx/layers/ipc/CompositorLRU.h
gfx/layers/ipc/PCompositorBridge.ipdl
gfx/layers/moz.build
layout/build/nsLayoutStatics.cpp
modules/libpref/init/all.js
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -143,29 +143,16 @@ NS_IMPL_ISUPPORTS(ContentListener, nsIDO
 
 static const CSSSize kDefaultViewportSize(980, 480);
 
 static const char BEFORE_FIRST_PAINT[] = "before-first-paint";
 
 typedef nsDataHashtable<nsUint64HashKey, TabChild*> TabChildMap;
 static TabChildMap* sTabChildren;
 
-static bool
-UsingCompositorLRU()
-{
-  static bool sHavePrefs = false;
-  static uint32_t sCompositorLRUSize = 0;
-  if (!sHavePrefs) {
-    sHavePrefs = true;
-    Preferences::AddUintVarCache(&sCompositorLRUSize,
-                                 "layers.compositor-lru-size", 0);
-  }
-  return sCompositorLRUSize != 0;
-}
-
 TabChildBase::TabChildBase()
   : mTabChildGlobal(nullptr)
 {
   mozilla::HoldJSObjects(this);
 }
 
 TabChildBase::~TabChildBase()
 {
@@ -2867,38 +2854,29 @@ TabChild::NotifyPainted()
         mRemoteFrame->SendNotifyCompositorTransaction();
         mNotified = true;
     }
 }
 
 void
 TabChild::MakeVisible()
 {
-  CompositorBridgeChild* compositor = CompositorBridgeChild::Get();
-  if (UsingCompositorLRU()) {
-    compositor->SendNotifyVisible(mLayersId);
-  }
-
   if (mPuppetWidget) {
     mPuppetWidget->Show(true);
   }
 }
 
 void
 TabChild::MakeHidden()
 {
   CompositorBridgeChild* compositor = CompositorBridgeChild::Get();
-  if (UsingCompositorLRU()) {
-    compositor->SendNotifyHidden(mLayersId);
-  } else {
-    // Clear cached resources directly. This avoids one extra IPC
-    // round-trip from CompositorBridgeChild to CompositorBridgeParent when
-    // CompositorLRU is not used.
-    compositor->RecvClearCachedResources(mLayersId);
-  }
+
+  // Clear cached resources directly. This avoids one extra IPC
+  // round-trip from CompositorBridgeChild to CompositorBridgeParent.
+  compositor->RecvClearCachedResources(mLayersId);
 
   if (mPuppetWidget) {
     mPuppetWidget->Show(false);
   }
 }
 
 void
 TabChild::UpdateHitRegion(const nsRegion& aRegion)
--- a/gfx/layers/ipc/CompositorBridgeChild.cpp
+++ b/gfx/layers/ipc/CompositorBridgeChild.cpp
@@ -694,36 +694,16 @@ CompositorBridgeChild::SendResume()
   MOZ_ASSERT(mCanSend);
   if (!mCanSend) {
     return true;
   }
   return PCompositorBridgeChild::SendResume();
 }
 
 bool
-CompositorBridgeChild::SendNotifyHidden(const uint64_t& id)
-{
-  MOZ_ASSERT(mCanSend);
-  if (!mCanSend) {
-    return true;
-  }
-  return PCompositorBridgeChild::SendNotifyHidden(id);
-}
-
-bool
-CompositorBridgeChild::SendNotifyVisible(const uint64_t& id)
-{
-  MOZ_ASSERT(mCanSend);
-  if (!mCanSend) {
-    return true;
-  }
-  return PCompositorBridgeChild::SendNotifyVisible(id);
-}
-
-bool
 CompositorBridgeChild::SendNotifyChildCreated(const uint64_t& id)
 {
   MOZ_ASSERT(mCanSend);
   if (!mCanSend) {
     return true;
   }
   return PCompositorBridgeChild::SendNotifyChildCreated(id);
 }
--- a/gfx/layers/ipc/CompositorBridgeChild.h
+++ b/gfx/layers/ipc/CompositorBridgeChild.h
@@ -144,18 +144,16 @@ 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 SendWillClose();
   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);
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CompositorBridgeParent.cpp
@@ -31,17 +31,16 @@
 #include "mozilla/gfx/Rect.h"          // for IntSize
 #include "VRManager.h"                  // for VRManager
 #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/CompositorThread.h"
 #include "mozilla/layers/CompositorTypes.h"
 #include "mozilla/layers/FrameUniformityData.h"
 #include "mozilla/layers/ImageBridgeParent.h"
 #include "mozilla/layers/LayerManagerComposite.h"
 #include "mozilla/layers/LayersTypes.h"
 #include "mozilla/layers/PLayerTransactionParent.h"
@@ -1987,18 +1986,16 @@ public:
   virtual void ActorDestroy(ActorDestroyReason aWhy) override;
 
   // FIXME/bug 774388: work out what shutdown protocol we need.
   virtual bool RecvInitialize(const uint64_t& aRootLayerTreeId) override { return false; }
   virtual bool RecvRequestOverfill() override { return true; }
   virtual bool RecvWillClose() 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 RecvForcePresent() override { return true; }
   virtual bool RecvNotifyRegionInvalidated(const nsIntRegion& aRegion) override { return true; }
@@ -2392,44 +2389,25 @@ CompositorBridgeParent::SendAsyncMessage
 
 bool
 CompositorBridgeParent::IsSameProcess() const
 {
   return OtherPid() == base::GetCurrentProcId();
 }
 
 bool
-CrossProcessCompositorBridgeParent::RecvNotifyHidden(const uint64_t& id)
-{
-  RefPtr<CompositorLRU> lru = CompositorLRU::GetSingleton();
-  lru->Add(this, id);
-  return true;
-}
-
-bool
-CrossProcessCompositorBridgeParent::RecvNotifyVisible(const uint64_t& id)
-{
-  RefPtr<CompositorLRU> lru = CompositorLRU::GetSingleton();
-  lru->Remove(this, id);
-  return true;
-}
-
-bool
 CrossProcessCompositorBridgeParent::RecvRequestNotifyAfterRemotePaint()
 {
   mNotifyAfterRemotePaint = true;
   return true;
 }
 
 void
 CrossProcessCompositorBridgeParent::ActorDestroy(ActorDestroyReason aWhy)
 {
-  RefPtr<CompositorLRU> lru = CompositorLRU::GetSingleton();
-  lru->Remove(this);
-
   // We must keep this object alive untill the code handling message
   // reception is finished on this thread.
   MessageLoop::current()->PostTask(NewRunnableMethod(this, &CrossProcessCompositorBridgeParent::DeferredDestroy));
 }
 
 PLayerTransactionParent*
 CrossProcessCompositorBridgeParent::AllocPLayerTransactionParent(
   const nsTArray<LayersBackend>&,
--- a/gfx/layers/ipc/CompositorBridgeParent.h
+++ b/gfx/layers/ipc/CompositorBridgeParent.h
@@ -229,18 +229,16 @@ public:
   bool Bind(Endpoint<PCompositorBridgeParent>&& aEndpoint);
 
   virtual bool RecvInitialize(const uint64_t& aRootLayerTreeId) override;
   virtual bool RecvGetFrameUniformity(FrameUniformityData* aOutData) override;
   virtual bool RecvRequestOverfill() override;
   virtual bool RecvWillClose() 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 RecvForcePresent() override;
 
   virtual bool RecvAcknowledgeCompositorUpdate(const uint64_t& aLayersId) override {
deleted file mode 100644
--- a/gfx/layers/ipc/CompositorLRU.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/* -*- 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 "CompositorBridgeParent.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(PCompositorBridgeParent* 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(PCompositorBridgeParent* aCompositor, const uint64_t& aId)
-{
-  if (mLRUSize == 0) {
-    return;
-  }
-
-  auto index = mLRU.IndexOf(std::make_pair(aCompositor, aId));
-
-  if (index == nsTArray<PCompositorBridgeParent*>::NoIndex) {
-    return;
-  }
-
-  mLRU.RemoveElementAt(index);
-}
-
-void
-CompositorLRU::Remove(PCompositorBridgeParent* 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
deleted file mode 100644
--- a/gfx/layers/ipc/CompositorLRU.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* -*- 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 PCompositorBridgeParent;
-
-class CompositorLRU final
-{
-  typedef std::pair<PCompositorBridgeParent*, uint64_t> CompositorLayerPair;
-public:
-  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CompositorLRU)
-
-  static void Init();
-  static CompositorLRU* GetSingleton();
-
-  /**
-   * Adds the (PCompositorBridgeParent, LayerId) pair to the LRU pool. If
-   * the pool size grows over mLRUSize, the oldest PCompositorBridgeParent
-   * is evicted.
-   */
-  void Add(PCompositorBridgeParent* aCompositor, const uint64_t& id);
-
-  /**
-   * Remove the (PCompositorBridgeParent, LayersId) pair from the LRU pool.
-   */
-  void Remove(PCompositorBridgeParent* aCompositor, const uint64_t& id);
-
-  /**
-   * Remove all PCompositorBridgeParents from the LRU pool.
-   */
-  void Remove(PCompositorBridgeParent* 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/PCompositorBridge.ipdl
+++ b/gfx/layers/ipc/PCompositorBridge.ipdl
@@ -137,24 +137,16 @@ parent:
   // The child is about to be destroyed, so perform any necessary cleanup.
   sync WillClose();
 
   // 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
@@ -153,17 +153,16 @@ EXPORTS.mozilla.layers += [
     'Effects.h',
     'ImageDataSerializer.h',
     'ipc/APZChild.h',
     'ipc/AsyncTransactionTracker.h',
     'ipc/CompositableForwarder.h',
     'ipc/CompositableTransactionParent.h',
     'ipc/CompositorBridgeChild.h',
     'ipc/CompositorBridgeParent.h',
-    'ipc/CompositorLRU.h',
     'ipc/CompositorThread.h',
     'ipc/FenceUtils.h',
     'ipc/GonkNativeHandle.h',
     'ipc/GonkNativeHandleUtils.h',
     'ipc/ImageBridgeChild.h',
     'ipc/ImageBridgeParent.h',
     'ipc/ImageContainerParent.h',
     'ipc/ISurfaceAllocator.h',
@@ -341,17 +340,16 @@ UNIFIED_SOURCES += [
     'ImageDataSerializer.cpp',
     'ImageLayers.cpp',
     'ipc/APZChild.cpp',
     'ipc/AsyncTransactionTracker.cpp',
     'ipc/CompositableTransactionParent.cpp',
     'ipc/CompositorBench.cpp',
     'ipc/CompositorBridgeChild.cpp',
     'ipc/CompositorBridgeParent.cpp',
-    'ipc/CompositorLRU.cpp',
     'ipc/CompositorThread.cpp',
     'ipc/FenceUtils.cpp',
     'ipc/ImageBridgeChild.cpp',
     'ipc/ImageBridgeParent.cpp',
     'ipc/ImageContainerParent.cpp',
     'ipc/ISurfaceAllocator.cpp',
     'ipc/LayerAnimationUtils.cpp',
     'ipc/LayerTransactionChild.cpp',
--- a/layout/build/nsLayoutStatics.cpp
+++ b/layout/build/nsLayoutStatics.cpp
@@ -120,17 +120,16 @@ using namespace mozilla::system;
 #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 "MediaPrefs.h"
-#include "mozilla/layers/CompositorLRU.h"
 #include "mozilla/dom/devicestorage/DeviceStorageStatics.h"
 #include "mozilla/ServoBindings.h"
 #include "mozilla/StaticPresData.h"
 #include "mozilla/dom/WebIDLGlobalNameHash.h"
 
 #ifdef MOZ_B2G_BT
 #include "mozilla/dom/BluetoothUUID.h"
 #endif
@@ -305,18 +304,16 @@ nsLayoutStatics::Initialize()
   nsStyleContext::Initialize();
   mozilla::LayerAnimationInfo::Initialize();
 #endif
 
   MediaDecoder::InitStatics();
 
   PromiseDebugging::Init();
 
-  layers::CompositorLRU::Init();
-
   mozilla::dom::devicestorage::DeviceStorageStatics::Initialize();
 
   mozilla::dom::WebCryptoThreadPool::Initialize();
 
 #ifdef MOZ_STYLO
   Servo_Initialize();
 #endif
 
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -4594,19 +4594,16 @@ pref("layers.shared-buffer-provider.enab
 
 // 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);
 
 // Timeout for outbound network geolocation provider XHR
 pref("geo.wifi.xhr.timeout", 60000);
 
 // Enable/Disable the orientation API for content
 pref("device.sensors.enabled", true);