From a5df436c2e3c40a9221571aafe8d911da990d8be Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Fri, 15 May 2015 20:29:15 -0700 Subject: [PATCH] Backed out 2 changesets (bug 1154231) for M-oth crashes CLOSED TREE Backed out changeset 5e8145eff457 (bug 1154231) Backed out changeset 951fb8ed6f25 (bug 1154231) --- b2g/app/b2g.js | 3 - dom/ipc/TabChild.cpp | 29 ++------ dom/ipc/TabChild.h | 1 - gfx/layers/ipc/CompositorChild.cpp | 30 --------- gfx/layers/ipc/CompositorChild.h | 5 -- gfx/layers/ipc/CompositorLRU.cpp | 101 ---------------------------- gfx/layers/ipc/CompositorLRU.h | 61 ----------------- gfx/layers/ipc/CompositorParent.cpp | 22 ------ gfx/layers/ipc/CompositorParent.h | 2 - gfx/layers/ipc/PCompositor.ipdl | 14 ---- gfx/layers/moz.build | 2 - layout/build/nsLayoutStatics.cpp | 3 - modules/libpref/init/all.js | 3 - widget/PuppetWidget.cpp | 41 ++--------- widget/PuppetWidget.h | 13 ---- 15 files changed, 10 insertions(+), 320 deletions(-) delete mode 100644 gfx/layers/ipc/CompositorLRU.cpp delete mode 100644 gfx/layers/ipc/CompositorLRU.h diff --git a/b2g/app/b2g.js b/b2g/app/b2g.js index 0e4c39a9e5c6..6d874c6f1677 100644 --- a/b2g/app/b2g.js +++ b/b2g/app/b2g.js @@ -1140,6 +1140,3 @@ 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); diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 977fc58db8c9..cc80fa7c2f47 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -2985,23 +2985,17 @@ TabChild::NotifyPainted() void TabChild::MakeVisible() { - CompositorChild* compositor = CompositorChild::Get(); - compositor->SendNotifyVisible(mLayersId); - - if (mWidget) { - mWidget->Show(true); - } + if (mWidget) { + mWidget->Show(true); + } } void TabChild::MakeHidden() { - CompositorChild* compositor = CompositorChild::Get(); - compositor->SendNotifyHidden(mLayersId); - - if (mWidget) { - mWidget->Show(false); - } + if (mWidget) { + mWidget->Show(false); + } } void @@ -3143,17 +3137,6 @@ TabChild::DidComposite(uint64_t aTransactionId) 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(mWidget->GetLayerManager()); - manager->ClearCachedResources(); -} - NS_IMETHODIMP TabChild::OnShowTooltip(int32_t aXCoords, int32_t aYCoords, const char16_t *aTipText) { diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index b2c02a8114ed..93901877fd64 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -474,7 +474,6 @@ public: static TabChild* GetFrom(uint64_t aLayersId); void DidComposite(uint64_t aTransactionId); - void ClearCachedResources(); static inline TabChild* GetFrom(nsIDOMWindow* aWindow) diff --git a/gfx/layers/ipc/CompositorChild.cpp b/gfx/layers/ipc/CompositorChild.cpp index 8d6dc049e948..02609081c00c 100644 --- a/gfx/layers/ipc/CompositorChild.cpp +++ b/gfx/layers/ipc/CompositorChild.cpp @@ -372,16 +372,6 @@ CompositorChild::AddOverfillObserver(ClientLayerManager* 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) { @@ -559,26 +549,6 @@ CompositorChild::SendResume() 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) { diff --git a/gfx/layers/ipc/CompositorChild.h b/gfx/layers/ipc/CompositorChild.h index 77a24279fe11..c5d595646739 100644 --- a/gfx/layers/ipc/CompositorChild.h +++ b/gfx/layers/ipc/CompositorChild.h @@ -70,9 +70,6 @@ public: void AddOverfillObserver(ClientLayerManager* aLayerManager); - virtual bool - RecvClearCachedResources(const uint64_t& id) override; - virtual bool RecvDidComposite(const uint64_t& aId, const uint64_t& aTransactionId) override; @@ -109,8 +106,6 @@ public: 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); diff --git a/gfx/layers/ipc/CompositorLRU.cpp b/gfx/layers/ipc/CompositorLRU.cpp deleted file mode 100644 index ac934a992e3f..000000000000 --- 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 "CompositorParent.h" - -namespace mozilla { -namespace layers { - -mozilla::StaticRefPtr 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::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::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 diff --git a/gfx/layers/ipc/CompositorLRU.h b/gfx/layers/ipc/CompositorLRU.h deleted file mode 100644 index adb294cf8af7..000000000000 --- 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 - -namespace mozilla { -namespace layers { - -class PCompositorParent; - -class CompositorLRU final -{ - typedef std::pair 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 sSingleton; - - CompositorLRU(); - ~CompositorLRU(); - uint32_t mLRUSize; - nsTArray mLRU; -}; - -} // namespace layers -} // namespace mozilla - -#endif // mozilla_CompositorLRU_h diff --git a/gfx/layers/ipc/CompositorParent.cpp b/gfx/layers/ipc/CompositorParent.cpp index 787bd0f9cbea..03b269eb6184 100644 --- a/gfx/layers/ipc/CompositorParent.cpp +++ b/gfx/layers/ipc/CompositorParent.cpp @@ -34,7 +34,6 @@ #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" @@ -1687,8 +1686,6 @@ public: 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, @@ -1844,22 +1841,6 @@ CompositorParent::GetIndirectShadowTree(uint64_t aId) return &cit->second; } -bool -CrossProcessCompositorParent::RecvNotifyHidden(const uint64_t& id) -{ - nsRefPtr lru = CompositorLRU::GetSingleton(); - lru->Add(this, id); - return true; -} - -bool -CrossProcessCompositorParent::RecvNotifyVisible(const uint64_t& id) -{ - nsRefPtr lru = CompositorLRU::GetSingleton(); - lru->Remove(this, id); - return true; -} - bool CrossProcessCompositorParent::RecvRequestNotifyAfterRemotePaint() { @@ -1870,9 +1851,6 @@ CrossProcessCompositorParent::RecvRequestNotifyAfterRemotePaint() void CrossProcessCompositorParent::ActorDestroy(ActorDestroyReason aWhy) { - nsRefPtr lru = CompositorLRU::GetSingleton(); - lru->Remove(this); - MessageLoop::current()->PostTask( FROM_HERE, NewRunnableMethod(this, &CrossProcessCompositorParent::DeferredDestroy)); diff --git a/gfx/layers/ipc/CompositorParent.h b/gfx/layers/ipc/CompositorParent.h index bedf15d0554c..3bce283277a3 100644 --- a/gfx/layers/ipc/CompositorParent.h +++ b/gfx/layers/ipc/CompositorParent.h @@ -234,8 +234,6 @@ public: 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, diff --git a/gfx/layers/ipc/PCompositor.ipdl b/gfx/layers/ipc/PCompositor.ipdl index 17f73317f157..ba3620506bec 100644 --- a/gfx/layers/ipc/PCompositor.ipdl +++ b/gfx/layers/ipc/PCompositor.ipdl @@ -70,12 +70,6 @@ child: */ 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(); @@ -91,14 +85,6 @@ parent: 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); diff --git a/gfx/layers/moz.build b/gfx/layers/moz.build index e2c41155d69f..22c38f4ba399 100644 --- a/gfx/layers/moz.build +++ b/gfx/layers/moz.build @@ -139,7 +139,6 @@ EXPORTS.mozilla.layers += [ 'ipc/CompositableForwarder.h', 'ipc/CompositableTransactionParent.h', 'ipc/CompositorChild.h', - 'ipc/CompositorLRU.h', 'ipc/CompositorParent.h', 'ipc/FenceUtils.h', 'ipc/ImageBridgeChild.h', @@ -295,7 +294,6 @@ UNIFIED_SOURCES += [ 'ipc/CompositableTransactionParent.cpp', 'ipc/CompositorBench.cpp', 'ipc/CompositorChild.cpp', - 'ipc/CompositorLRU.cpp', 'ipc/CompositorParent.cpp', 'ipc/ImageBridgeChild.cpp', 'ipc/ImageBridgeParent.cpp', diff --git a/layout/build/nsLayoutStatics.cpp b/layout/build/nsLayoutStatics.cpp index 039b72ce5b27..f78543a00633 100644 --- a/layout/build/nsLayoutStatics.cpp +++ b/layout/build/nsLayoutStatics.cpp @@ -139,7 +139,6 @@ using namespace mozilla::system; #include "CameraPreferences.h" #include "TouchManager.h" #include "MediaDecoder.h" -#include "mozilla/layers/CompositorLRU.h" using namespace mozilla; using namespace mozilla::net; @@ -321,8 +320,6 @@ nsLayoutStatics::Initialize() PromiseDebugging::Init(); - layers::CompositorLRU::Init(); - return NS_OK; } diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index d5e95e3eb0c3..3f2d373b3b62 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -4148,9 +4148,6 @@ pref("layers.force-active", false); // 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); diff --git a/widget/PuppetWidget.cpp b/widget/PuppetWidget.cpp index 875c5963c8d7..20ed9e345254 100644 --- a/widget/PuppetWidget.cpp +++ b/widget/PuppetWidget.cpp @@ -118,11 +118,6 @@ PuppetWidget::Create(nsIWidget *aParent, else { Resize(mBounds.x, mBounds.y, mBounds.width, mBounds.height, false); } - nsCOMPtr obs = mozilla::services::GetObserverService(); - if (obs) { - mMemoryPressureObserver = new MemoryPressureObserver(this); - obs->AddObserver(mMemoryPressureObserver, "memory-pressure", false); - } return NS_OK; } @@ -158,9 +153,6 @@ PuppetWidget::Destroy() Base::OnDestroy(); Base::Destroy(); mPaintTask.Revoke(); - if (mMemoryPressureObserver) { - mMemoryPressureObserver->Remove(); - } mChild = nullptr; if (mLayerManager) { mLayerManager->Destroy(); @@ -183,6 +175,10 @@ PuppetWidget::Show(bool aState) mChild->mVisible = aState; } + if (!mVisible && mLayerManager) { + mLayerManager->ClearCachedResources(); + } + if (!wasVisible && mVisible) { Resize(mBounds.width, mBounds.height, false); Invalidate(mBounds); @@ -1034,35 +1030,6 @@ PuppetWidget::PaintTask::Run() return NS_OK; } -NS_IMPL_ISUPPORTS(PuppetWidget::MemoryPressureObserver, nsIObserver) - -NS_IMETHODIMP -PuppetWidget::MemoryPressureObserver::Observe(nsISupports* aSubject, - const char* aTopic, - const char16_t* aData) -{ - if (!mWidget) { - return NS_OK; - } - - if (strcmp("memory-pressure", aTopic) == 0) { - if (!mWidget->mVisible && mWidget->mLayerManager) { - mWidget->mLayerManager->ClearCachedResources(); - } - } - return NS_OK; -} - -void -PuppetWidget::MemoryPressureObserver::Remove() -{ - nsCOMPtr obs = mozilla::services::GetObserverService(); - if (obs) { - obs->RemoveObserver(this, "memory-pressure"); - } - mWidget = nullptr; -} - bool PuppetWidget::NeedsPaint() { diff --git a/widget/PuppetWidget.h b/widget/PuppetWidget.h index d6ddc8149735..6ddcaceacfd2 100644 --- a/widget/PuppetWidget.h +++ b/widget/PuppetWidget.h @@ -280,18 +280,6 @@ private: PuppetWidget* mWidget; }; - class MemoryPressureObserver : public nsIObserver { - public: - NS_DECL_ISUPPORTS - NS_DECL_NSIOBSERVER - explicit MemoryPressureObserver(PuppetWidget* aWidget) : mWidget(aWidget) {} - void Remove(); - private: - virtual ~MemoryPressureObserver() {} - PuppetWidget* mWidget; - }; - friend class MemoryPressureObserver; - // TabChild normally holds a strong reference to this PuppetWidget // or its root ancestor, but each PuppetWidget also needs a // reference back to TabChild (e.g. to delegate nsIWidget IME calls @@ -304,7 +292,6 @@ private: nsRefPtr mChild; nsIntRegion mDirtyRegion; nsRevocableEventPtr mPaintTask; - nsRefPtr mMemoryPressureObserver; // XXX/cjones: keeping this around until we teach LayerManager to do // retained-content-only transactions mozilla::RefPtr mDrawTarget;