From 3a8485e6e6beb9f37c52dd04f2ebe0ac4599a6b1 Mon Sep 17 00:00:00 2001 From: Narcis Beleuzu Date: Tue, 25 Sep 2018 13:33:17 +0300 Subject: [PATCH] Backed out 6 changesets (bug 1492930) for build bustages on ImageMemoryReporter.cpp. CLOSED TREE Backed out changeset 9d1ff0d0af47 (bug 1492930) Backed out changeset bdb1bf2d8062 (bug 1492930) Backed out changeset 2959314ecf7c (bug 1492930) Backed out changeset 587e01daa080 (bug 1492930) Backed out changeset 1a6b422c5a90 (bug 1492930) Backed out changeset a3b3f4cdc9fa (bug 1492930) --- gfx/2d/2D.h | 5 +- gfx/2d/SourceSurfaceRawData.cpp | 3 +- gfx/2d/SourceSurfaceRawData.h | 3 +- gfx/ipc/GPUParent.cpp | 4 - gfx/layers/SourceSurfaceSharedData.cpp | 7 +- gfx/layers/SourceSurfaceSharedData.h | 25 +-- gfx/layers/SourceSurfaceVolatileData.cpp | 3 +- gfx/layers/SourceSurfaceVolatileData.h | 3 +- gfx/layers/ipc/CompositorManagerParent.cpp | 9 - gfx/layers/ipc/CompositorManagerParent.h | 1 - gfx/layers/ipc/PCompositorManager.ipdl | 2 - gfx/layers/ipc/SharedSurfacesChild.cpp | 18 +- gfx/layers/ipc/SharedSurfacesChild.h | 11 -- gfx/layers/ipc/SharedSurfacesMemoryReport.h | 93 ---------- gfx/layers/ipc/SharedSurfacesParent.cpp | 62 +------ gfx/layers/ipc/SharedSurfacesParent.h | 9 +- gfx/layers/moz.build | 1 - gfx/thebes/gfxPlatform.cpp | 3 - gfx/thebes/gfxPrefs.h | 1 - image/AnimationSurfaceProvider.cpp | 14 +- image/AnimationSurfaceProvider.h | 4 +- image/FrameAnimator.cpp | 28 ++- image/ISurfaceProvider.h | 10 +- image/Image.h | 8 - image/ImageMemoryReporter.cpp | 187 -------------------- image/ImageMemoryReporter.h | 96 ---------- image/SurfaceCache.cpp | 29 ++- image/imgFrame.cpp | 20 +-- image/imgFrame.h | 19 +- image/imgLoader.cpp | 82 ++------- image/imgRequest.cpp | 1 - image/moz.build | 5 - modules/libpref/init/all.js | 3 - 33 files changed, 82 insertions(+), 687 deletions(-) delete mode 100644 gfx/layers/ipc/SharedSurfacesMemoryReport.h delete mode 100644 image/ImageMemoryReporter.cpp delete mode 100644 image/ImageMemoryReporter.h diff --git a/gfx/2d/2D.h b/gfx/2d/2D.h index e06b95d7025b..bef8317c5e53 100644 --- a/gfx/2d/2D.h +++ b/gfx/2d/2D.h @@ -420,7 +420,7 @@ public: void AddUserData(UserDataKey *key, void *userData, void (*destroy)(void*)) { mUserData.Add(key, userData, destroy); } - void *GetUserData(UserDataKey *key) const { + void *GetUserData(UserDataKey *key) { return mUserData.Get(key); } void RemoveUserData(UserDataKey *key) { @@ -587,8 +587,7 @@ public: virtual void AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf, size_t& aHeapSizeOut, size_t& aNonHeapSizeOut, - size_t& aExtHandlesOut, - uint64_t& aExtIdOut) const + size_t& aExtHandlesOut) const { } diff --git a/gfx/2d/SourceSurfaceRawData.cpp b/gfx/2d/SourceSurfaceRawData.cpp index 69562f46df4c..57d3b10a31d3 100644 --- a/gfx/2d/SourceSurfaceRawData.cpp +++ b/gfx/2d/SourceSurfaceRawData.cpp @@ -83,8 +83,7 @@ void SourceSurfaceAlignedRawData::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf, size_t& aHeapSizeOut, size_t& aNonHeapSizeOut, - size_t& aExtHandlesOut, - uint64_t& aExtIdOut) const + size_t& aExtHandlesOut) const { aHeapSizeOut += mArray.HeapSizeOfExcludingThis(aMallocSizeOf); } diff --git a/gfx/2d/SourceSurfaceRawData.h b/gfx/2d/SourceSurfaceRawData.h index 8561f973e9e1..92c660382eb8 100644 --- a/gfx/2d/SourceSurfaceRawData.h +++ b/gfx/2d/SourceSurfaceRawData.h @@ -131,8 +131,7 @@ public: void AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf, size_t& aHeapSizeOut, size_t& aNonHeapSizeOut, - size_t& aExtHandlesOut, - uint64_t& aExtIdOut) const override; + size_t& aExtHandlesOut) const override; virtual bool Map(MapType, MappedSurface *aMappedSurface) override { diff --git a/gfx/ipc/GPUParent.cpp b/gfx/ipc/GPUParent.cpp index 36fcff994208..e4b3bfc57ca1 100644 --- a/gfx/ipc/GPUParent.cpp +++ b/gfx/ipc/GPUParent.cpp @@ -22,7 +22,6 @@ #include "mozilla/dom/VideoDecoderManagerParent.h" #include "mozilla/gfx/2D.h" #include "mozilla/gfx/gfxVars.h" -#include "mozilla/image/ImageMemoryReporter.h" #include "mozilla/ipc/CrashReporterClient.h" #include "mozilla/ipc/ProcessChild.h" #include "mozilla/layers/APZInputBridgeParent.h" @@ -269,7 +268,6 @@ GPUParent::RecvInit(nsTArray&& prefs, // Make sure to do this *after* we update gfxVars above. if (gfxVars::UseWebRender()) { wr::RenderThread::Start(); - image::ImageMemoryReporter::InitForWebRender(); } VRManager::ManagerInit(); @@ -540,8 +538,6 @@ GPUParent::ActorDestroy(ActorDestroyReason aWhy) wr::RenderThread::ShutDown(); } - image::ImageMemoryReporter::ShutdownForWebRender(); - // Shut down the default GL context provider. gl::GLContextProvider::Shutdown(); diff --git a/gfx/layers/SourceSurfaceSharedData.cpp b/gfx/layers/SourceSurfaceSharedData.cpp index b3a70f05bae5..cd8304b785eb 100644 --- a/gfx/layers/SourceSurfaceSharedData.cpp +++ b/gfx/layers/SourceSurfaceSharedData.cpp @@ -97,8 +97,7 @@ void SourceSurfaceSharedData::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf, size_t& aHeapSizeOut, size_t& aNonHeapSizeOut, - size_t& aExtHandlesOut, - uint64_t& aExtIdOut) const + size_t& aExtHandlesOut) const { MutexAutoLock lock(mMutex); if (mBuf) { @@ -107,10 +106,6 @@ SourceSurfaceSharedData::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf, if (!mClosed) { ++aExtHandlesOut; } - Maybe extId = SharedSurfacesChild::GetExternalId(this); - if (extId) { - aExtIdOut = wr::AsUint64(extId.ref()); - } } uint8_t* diff --git a/gfx/layers/SourceSurfaceSharedData.h b/gfx/layers/SourceSurfaceSharedData.h index 0833e51d18ad..a1083837bb12 100644 --- a/gfx/layers/SourceSurfaceSharedData.h +++ b/gfx/layers/SourceSurfaceSharedData.h @@ -43,7 +43,6 @@ public: , mConsumers(0) , mFormat(SurfaceFormat::UNKNOWN) , mCreatorPid(0) - , mCreatorRef(true) { } bool Init(const IntSize& aSize, @@ -80,30 +79,12 @@ public: return ++mConsumers == 1; } - bool RemoveConsumer(bool aForCreator) + bool RemoveConsumer() { MOZ_ASSERT(mConsumers > 0); - if (aForCreator) { - if (!mCreatorRef) { - MOZ_ASSERT_UNREACHABLE("Already released creator reference!"); - return false; - } - mCreatorRef = false; - } return --mConsumers == 0; } - uint32_t GetConsumers() const - { - MOZ_ASSERT(mConsumers > 0); - return mConsumers; - } - - bool HasCreatorRef() const - { - return mCreatorRef; - } - private: size_t GetDataLength() const { @@ -121,7 +102,6 @@ private: RefPtr mBuf; SurfaceFormat mFormat; base::ProcessId mCreatorPid; - bool mCreatorRef; }; /** @@ -175,8 +155,7 @@ public: void AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf, size_t& aHeapSizeOut, size_t& aNonHeapSizeOut, - size_t& aExtHandlesOut, - uint64_t& aExtIdOut) const override; + size_t& aExtHandlesOut) const override; bool OnHeap() const override { diff --git a/gfx/layers/SourceSurfaceVolatileData.cpp b/gfx/layers/SourceSurfaceVolatileData.cpp index d058ae9dd7ef..20e1a2e01714 100644 --- a/gfx/layers/SourceSurfaceVolatileData.cpp +++ b/gfx/layers/SourceSurfaceVolatileData.cpp @@ -42,8 +42,7 @@ void SourceSurfaceVolatileData::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf, size_t& aHeapSizeOut, size_t& aNonHeapSizeOut, - size_t& aExtHandlesOut, - uint64_t& aExtIdOut) const + size_t& aExtHandlesOut) const { if (mVBuf) { aHeapSizeOut += mVBuf->HeapSizeOfExcludingThis(aMallocSizeOf); diff --git a/gfx/layers/SourceSurfaceVolatileData.h b/gfx/layers/SourceSurfaceVolatileData.h index aa7af53ad42c..64ac4cc282bc 100644 --- a/gfx/layers/SourceSurfaceVolatileData.h +++ b/gfx/layers/SourceSurfaceVolatileData.h @@ -53,8 +53,7 @@ public: void AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf, size_t& aHeapSizeOut, size_t& aNonHeapSizeOut, - size_t& aExtHandlesOut, - uint64_t& aExtIdOut) const override; + size_t& aExtHandlesOut) const override; bool OnHeap() const override { diff --git a/gfx/layers/ipc/CompositorManagerParent.cpp b/gfx/layers/ipc/CompositorManagerParent.cpp index bc93e6b47479..c7834cbceeb4 100644 --- a/gfx/layers/ipc/CompositorManagerParent.cpp +++ b/gfx/layers/ipc/CompositorManagerParent.cpp @@ -289,15 +289,6 @@ CompositorManagerParent::RecvRemoveSharedSurface(const wr::ExternalImageId& aId) return IPC_OK(); } -mozilla::ipc::IPCResult -CompositorManagerParent::RecvReportSharedSurfacesMemory(ReportSharedSurfacesMemoryResolver&& aResolver) -{ - SharedSurfacesMemoryReport report; - SharedSurfacesParent::AccumulateMemoryReport(OtherPid(), report); - aResolver(std::move(report)); - return IPC_OK(); -} - mozilla::ipc::IPCResult CompositorManagerParent::RecvNotifyMemoryPressure() { diff --git a/gfx/layers/ipc/CompositorManagerParent.h b/gfx/layers/ipc/CompositorManagerParent.h index 930440aee85b..2b7c7345d017 100644 --- a/gfx/layers/ipc/CompositorManagerParent.h +++ b/gfx/layers/ipc/CompositorManagerParent.h @@ -43,7 +43,6 @@ public: mozilla::ipc::IPCResult RecvAddSharedSurface(const wr::ExternalImageId& aId, const SurfaceDescriptorShared& aDesc) override; mozilla::ipc::IPCResult RecvRemoveSharedSurface(const wr::ExternalImageId& aId) override; - mozilla::ipc::IPCResult RecvReportSharedSurfacesMemory(ReportSharedSurfacesMemoryResolver&&) override; virtual mozilla::ipc::IPCResult RecvNotifyMemoryPressure() override; diff --git a/gfx/layers/ipc/PCompositorManager.ipdl b/gfx/layers/ipc/PCompositorManager.ipdl index 490906c839c0..16e56e2f5f7d 100644 --- a/gfx/layers/ipc/PCompositorManager.ipdl +++ b/gfx/layers/ipc/PCompositorManager.ipdl @@ -18,7 +18,6 @@ using mozilla::ipc::SharedMemoryBasic::Handle from "mozilla/ipc/SharedMemoryBasi using mozilla::layers::CompositorOptions from "mozilla/layers/CompositorOptions.h"; using mozilla::wr::ExternalImageId from "mozilla/webrender/WebRenderTypes.h"; using mozilla::wr::MemoryReport from "mozilla/webrender/WebRenderTypes.h"; -using mozilla::layers::SharedSurfacesMemoryReport from "mozilla/layers/SharedSurfacesMemoryReport.h"; namespace mozilla { namespace layers { @@ -77,7 +76,6 @@ parent: async AddSharedSurface(ExternalImageId aId, SurfaceDescriptorShared aDesc); async RemoveSharedSurface(ExternalImageId aId); - async ReportSharedSurfacesMemory() returns (SharedSurfacesMemoryReport aReport); async NotifyMemoryPressure(); diff --git a/gfx/layers/ipc/SharedSurfacesChild.cpp b/gfx/layers/ipc/SharedSurfacesChild.cpp index 26f4548711e8..78ab4aa2638c 100644 --- a/gfx/layers/ipc/SharedSurfacesChild.cpp +++ b/gfx/layers/ipc/SharedSurfacesChild.cpp @@ -19,8 +19,6 @@ namespace layers { using namespace mozilla::gfx; -/* static */ UserDataKey SharedSurfacesChild::sSharedKey; - class SharedSurfacesChild::ImageKeyData final { public: @@ -226,6 +224,7 @@ SharedSurfacesChild::ShareInternal(SourceSurfaceSharedData* aSurface, return NS_ERROR_NOT_INITIALIZED; } + static UserDataKey sSharedKey; SharedUserData* data = static_cast(aSurface->GetUserData(&sSharedKey)); if (!data) { @@ -456,20 +455,5 @@ SharedSurfacesChild::Unshare(const wr::ExternalImageId& aId, } } -/* static */ Maybe -SharedSurfacesChild::GetExternalId(const SourceSurfaceSharedData* aSurface) -{ - MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(aSurface); - - SharedUserData* data = - static_cast(aSurface->GetUserData(&sSharedKey)); - if (!data || !data->IsShared()) { - return Nothing(); - } - - return Some(data->Id()); -} - } // namespace layers } // namespace mozilla diff --git a/gfx/layers/ipc/SharedSurfacesChild.h b/gfx/layers/ipc/SharedSurfacesChild.h index df0892b008cf..1706505080e8 100644 --- a/gfx/layers/ipc/SharedSurfacesChild.h +++ b/gfx/layers/ipc/SharedSurfacesChild.h @@ -10,10 +10,8 @@ #include // for size_t #include // for uint32_t, uint64_t #include "mozilla/Attributes.h" // for override -#include "mozilla/Maybe.h" // for Maybe #include "mozilla/RefPtr.h" // for already_AddRefed #include "mozilla/StaticPtr.h" // for StaticRefPtr -#include "mozilla/gfx/UserData.h" // for UserDataKey #include "mozilla/webrender/WebRenderTypes.h" // for wr::ImageKey namespace mozilla { @@ -73,13 +71,6 @@ public: wr::IpcResourceUpdateQueue& aResources, wr::ImageKey& aKey); - /** - * Get the external ID, if any, bound to the shared surface. Used for memory - * reporting purposes. - */ - static Maybe - GetExternalId(const gfx::SourceSurfaceSharedData* aSurface); - private: SharedSurfacesChild() = delete; ~SharedSurfacesChild() = delete; @@ -92,8 +83,6 @@ private: static void Unshare(const wr::ExternalImageId& aId, nsTArray& aKeys); static void DestroySharedUserData(void* aClosure); - - static gfx::UserDataKey sSharedKey; }; } // namespace layers diff --git a/gfx/layers/ipc/SharedSurfacesMemoryReport.h b/gfx/layers/ipc/SharedSurfacesMemoryReport.h deleted file mode 100644 index b105a162e20f..000000000000 --- a/gfx/layers/ipc/SharedSurfacesMemoryReport.h +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* 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_GFX_SHAREDSURFACESMEMORYREPORT_H -#define MOZILLA_GFX_SHAREDSURFACESMEMORYREPORT_H - -#include // for uint32_t -#include -#include "ipc/IPCMessageUtils.h" -#include "mozilla/gfx/Point.h" // for IntSize - -namespace mozilla { -namespace layers { - -class SharedSurfacesMemoryReport final -{ -public: - class SurfaceEntry final { - public: - base::ProcessId mCreatorPid; - gfx::IntSize mSize; - int32_t mStride; - uint32_t mConsumers; - bool mCreatorRef; - }; - - std::unordered_map mSurfaces; -}; - -} // namespace layers -} // namespace mozilla - -namespace IPC { - -template<> -struct ParamTraits -{ - typedef mozilla::layers::SharedSurfacesMemoryReport paramType; - - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.mSurfaces); - } - - static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) - { - return ReadParam(aMsg, aIter, &aResult->mSurfaces); - } -}; - -template<> -struct ParamTraits - : public PlainOldDataSerializer -{ -}; - -template -struct ParamTraits> -{ - typedef std::unordered_map paramType; - - static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.size()); - for (auto i = aParam.begin(); i != aParam.end(); ++i) { - WriteParam(aMsg, i->first); - WriteParam(aMsg, i->second); - } - } - - static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) - { - size_t count; - if (!ReadParam(aMsg, aIter, &count)) { - return false; - } - for (; count > 0; --count) { - KeyType k; - DataType v; - if (!ReadParam(aMsg, aIter, &k) || - !ReadParam(aMsg, aIter, &v)) { - return false; - } - aResult->insert(std::make_pair(std::move(k), std::move(v))); - } - return true; - } -}; - -} // namespace IPC - -#endif diff --git a/gfx/layers/ipc/SharedSurfacesParent.cpp b/gfx/layers/ipc/SharedSurfacesParent.cpp index ed5f9e76c761..3c9c017165f7 100644 --- a/gfx/layers/ipc/SharedSurfacesParent.cpp +++ b/gfx/layers/ipc/SharedSurfacesParent.cpp @@ -6,8 +6,6 @@ #include "SharedSurfacesParent.h" #include "mozilla/DebugOnly.h" -#include "mozilla/gfx/GPUProcessManager.h" -#include "mozilla/layers/SharedSurfacesMemoryReport.h" #include "mozilla/layers/SourceSurfaceSharedData.h" #include "mozilla/layers/CompositorThread.h" #include "mozilla/webrender/RenderSharedSurfaceTextureHost.h" @@ -87,7 +85,7 @@ SharedSurfacesParent::Acquire(const wr::ExternalImageId& aId) } /* static */ bool -SharedSurfacesParent::Release(const wr::ExternalImageId& aId, bool aForCreator) +SharedSurfacesParent::Release(const wr::ExternalImageId& aId) { StaticMutexAutoLock lock(sMutex); if (!sInstance) { @@ -101,7 +99,7 @@ SharedSurfacesParent::Release(const wr::ExternalImageId& aId, bool aForCreator) return false; } - if (surface->RemoveConsumer(aForCreator)) { + if (surface->RemoveConsumer()) { wr::RenderThread::Get()->UnregisterExternalImage(id); sInstance->mSurfaces.Remove(id); } @@ -145,7 +143,7 @@ SharedSurfacesParent::RemoveSameProcess(const wr::ExternalImageId& aId) { MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(NS_IsMainThread()); - Release(aId, /* aForCreator */ true); + Release(aId); } /* static */ void @@ -160,9 +158,7 @@ SharedSurfacesParent::DestroyProcess(base::ProcessId aPid) // lot of surfaces still bound that require unmapping. for (auto i = sInstance->mSurfaces.Iter(); !i.Done(); i.Next()) { SourceSurfaceSharedDataWrapper* surface = i.Data(); - if (surface->GetCreatorPid() == aPid && - surface->HasCreatorRef() && - surface->RemoveConsumer(/* aForCreator */ true)) { + if (surface->GetCreatorPid() == aPid && surface->RemoveConsumer()) { wr::RenderThread::Get()->UnregisterExternalImage(i.Key()); i.Remove(); } @@ -204,57 +200,9 @@ SharedSurfacesParent::Add(const wr::ExternalImageId& aId, /* static */ void SharedSurfacesParent::Remove(const wr::ExternalImageId& aId) { - DebugOnly rv = Release(aId, /* aForCreator */ true); + DebugOnly rv = Release(aId); MOZ_ASSERT(rv); } -/* static */ void -SharedSurfacesParent::AccumulateMemoryReport(base::ProcessId aPid, - SharedSurfacesMemoryReport& aReport) -{ - StaticMutexAutoLock lock(sMutex); - if (!sInstance) { - return; - } - - for (auto i = sInstance->mSurfaces.ConstIter(); !i.Done(); i.Next()) { - SourceSurfaceSharedDataWrapper* surface = i.Data(); - if (surface->GetCreatorPid() == aPid) { - aReport.mSurfaces.insert(std::make_pair(i.Key(), - SharedSurfacesMemoryReport::SurfaceEntry { - aPid, surface->GetSize(), surface->Stride(), - surface->GetConsumers(), surface->HasCreatorRef() })); - } - } -} - -/* static */ bool -SharedSurfacesParent::AccumulateMemoryReport(SharedSurfacesMemoryReport& aReport) -{ - if (XRE_IsParentProcess()) { - GPUProcessManager* gpm = GPUProcessManager::Get(); - if (!gpm || gpm->GPUProcessPid() != -1) { - return false; - } - } else if (!XRE_IsGPUProcess()) { - return false; - } - - StaticMutexAutoLock lock(sMutex); - if (!sInstance) { - return true; - } - - for (auto i = sInstance->mSurfaces.ConstIter(); !i.Done(); i.Next()) { - SourceSurfaceSharedDataWrapper* surface = i.Data(); - aReport.mSurfaces.insert(std::make_pair(i.Key(), - SharedSurfacesMemoryReport::SurfaceEntry { - surface->GetCreatorPid(), surface->GetSize(), surface->Stride(), - surface->GetConsumers(), surface->HasCreatorRef() })); - } - - return true; -} - } // namespace layers } // namespace mozilla diff --git a/gfx/layers/ipc/SharedSurfacesParent.h b/gfx/layers/ipc/SharedSurfacesParent.h index d377f0f073a8..e03954307dfa 100644 --- a/gfx/layers/ipc/SharedSurfacesParent.h +++ b/gfx/layers/ipc/SharedSurfacesParent.h @@ -29,7 +29,6 @@ class SourceSurfaceSharedDataWrapper; namespace layers { class SharedSurfacesChild; -class SharedSurfacesMemoryReport; class SharedSurfacesParent final { @@ -45,8 +44,7 @@ public: static already_AddRefed Acquire(const wr::ExternalImageId& aId); - static bool Release(const wr::ExternalImageId& aId, - bool aForCreator = false); + static bool Release(const wr::ExternalImageId& aId); static void Add(const wr::ExternalImageId& aId, const SurfaceDescriptorShared& aDesc, @@ -56,11 +54,6 @@ public: static void DestroyProcess(base::ProcessId aPid); - static void AccumulateMemoryReport(base::ProcessId aPid, - SharedSurfacesMemoryReport& aReport); - - static bool AccumulateMemoryReport(SharedSurfacesMemoryReport& aReport); - ~SharedSurfacesParent(); private: diff --git a/gfx/layers/moz.build b/gfx/layers/moz.build index 678e94a47a75..2f07ce12e601 100755 --- a/gfx/layers/moz.build +++ b/gfx/layers/moz.build @@ -196,7 +196,6 @@ EXPORTS.mozilla.layers += [ 'ipc/SharedPlanarYCbCrImage.h', 'ipc/SharedRGBImage.h', 'ipc/SharedSurfacesChild.h', - 'ipc/SharedSurfacesMemoryReport.h', 'ipc/SharedSurfacesParent.h', 'ipc/SynchronousTask.h', 'ipc/TextureForwarder.h', diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 676157cb9b35..a2646101994e 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -4,7 +4,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/FontPropertyTypes.h" -#include "mozilla/image/ImageMemoryReporter.h" #include "mozilla/layers/CompositorManagerChild.h" #include "mozilla/layers/CompositorThread.h" #include "mozilla/layers/ImageBridgeChild.h" @@ -1145,7 +1144,6 @@ gfxPlatform::InitLayersIPC() if (XRE_IsParentProcess() || recordreplay::IsRecordingOrReplaying()) { if (!gfxConfig::IsEnabled(Feature::GPU_PROCESS) && gfxVars::UseWebRender()) { wr::RenderThread::Start(); - image::ImageMemoryReporter::InitForWebRender(); } layers::CompositorThreadHolder::Start(); @@ -1179,7 +1177,6 @@ gfxPlatform::ShutdownLayersIPC() // This has to happen after shutting down the child protocols. layers::CompositorThreadHolder::Shutdown(); gfx::VRListenerThreadHolder::Shutdown(); - image::ImageMemoryReporter::ShutdownForWebRender(); // There is a case that RenderThread exists when gfxVars::UseWebRender() is false. // This could happen when WebRender was fallbacked to compositor. if (wr::RenderThread::Get()) { diff --git a/gfx/thebes/gfxPrefs.h b/gfx/thebes/gfxPrefs.h index 22f16b11eaa6..bc3031d2f118 100644 --- a/gfx/thebes/gfxPrefs.h +++ b/gfx/thebes/gfxPrefs.h @@ -557,7 +557,6 @@ private: DECL_GFX_PREF(Live, "image.mem.discardable", ImageMemDiscardable, bool, false); DECL_GFX_PREF(Once, "image.mem.animated.discardable", ImageMemAnimatedDiscardable, bool, false); DECL_GFX_PREF(Live, "image.mem.animated.use_heap", ImageMemAnimatedUseHeap, bool, false); - DECL_GFX_PREF(Live, "image.mem.debug-reporting", ImageMemDebugReporting, bool, false); DECL_GFX_PREF(Live, "image.mem.shared", ImageMemShared, bool, true); DECL_GFX_PREF(Once, "image.mem.surfacecache.discard_factor", ImageMemSurfaceCacheDiscardFactor, uint32_t, 1); DECL_GFX_PREF(Once, "image.mem.surfacecache.max_size_kb", ImageMemSurfaceCacheMaxSizeKB, uint32_t, 100 * 1024); diff --git a/image/AnimationSurfaceProvider.cpp b/image/AnimationSurfaceProvider.cpp index 00fbc05398b6..697cc4292dc1 100644 --- a/image/AnimationSurfaceProvider.cpp +++ b/image/AnimationSurfaceProvider.cpp @@ -206,23 +206,19 @@ AnimationSurfaceProvider::LogicalSizeInBytes() const void AnimationSurfaceProvider::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf, - const AddSizeOfCb& aCallback) + size_t& aHeapSizeOut, + size_t& aNonHeapSizeOut, + size_t& aExtHandlesOut) { // Note that the surface cache lock is already held here, and then we acquire // mFramesMutex. For this method, this ordering is unavoidable, which means // that we must be careful to always use the same ordering elsewhere. MutexAutoLock lock(mFramesMutex); - size_t i = 0; for (const RawAccessFrameRef& frame : mFrames.Frames()) { - ++i; if (frame) { - frame->AddSizeOfExcludingThis(aMallocSizeOf, - [&](AddSizeOfCbData& aMetadata) { - aMetadata.index = i; - aCallback(aMetadata); - } - ); + frame->AddSizeOfExcludingThis(aMallocSizeOf, aHeapSizeOut, + aNonHeapSizeOut, aExtHandlesOut); } } } diff --git a/image/AnimationSurfaceProvider.h b/image/AnimationSurfaceProvider.h index 5f1c4c1d56bd..06ad89a9c11e 100644 --- a/image/AnimationSurfaceProvider.h +++ b/image/AnimationSurfaceProvider.h @@ -49,7 +49,9 @@ public: bool IsFullyDecoded() const override; size_t LogicalSizeInBytes() const override; void AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf, - const AddSizeOfCb& aCallback) override; + size_t& aHeapSizeOut, + size_t& aNonHeapSizeOut, + size_t& aExtHandlesOut) override; void Reset() override; void Advance(size_t aFrame) override; diff --git a/image/FrameAnimator.cpp b/image/FrameAnimator.cpp index 3cc7a75dc7ad..280e77f32dc8 100644 --- a/image/FrameAnimator.cpp +++ b/image/FrameAnimator.cpp @@ -561,24 +561,20 @@ DoCollectSizeOfCompositingSurfaces(const RawAccessFrameRef& aSurface, DefaultSurfaceFlags(), PlaybackType::eStatic); + // Create a counter for this surface. + SurfaceMemoryCounter counter(key, /* aIsLocked = */ true, + /* aCannotSubstitute */ false, + /* aIsFactor2 */ false, aType); + // Extract the surface's memory usage information. - aSurface->AddSizeOfExcludingThis(aMallocSizeOf, - [&](imgFrame::AddSizeOfCbData& aMetadata) { - // Create a counter for this surface. - SurfaceMemoryCounter counter(key, /* aIsLocked = */ true, - /* aCannotSubstitute */ false, - /* aIsFactor2 */ false, aType); + size_t heap = 0, nonHeap = 0, handles = 0; + aSurface->AddSizeOfExcludingThis(aMallocSizeOf, heap, nonHeap, handles); + counter.Values().SetDecodedHeap(heap); + counter.Values().SetDecodedNonHeap(nonHeap); + counter.Values().SetExternalHandles(handles); - // Record it. - counter.Values().SetDecodedHeap(aMetadata.heap); - counter.Values().SetDecodedNonHeap(aMetadata.nonHeap); - counter.Values().SetExternalHandles(aMetadata.handles); - counter.Values().SetFrameIndex(aMetadata.index); - counter.Values().SetExternalId(aMetadata.externalId); - - aCounters.AppendElement(counter); - } - ); + // Record it. + aCounters.AppendElement(counter); } void diff --git a/image/ISurfaceProvider.h b/image/ISurfaceProvider.h index 5150ab5fe2b1..f71572bf3e1e 100644 --- a/image/ISurfaceProvider.h +++ b/image/ISurfaceProvider.h @@ -65,21 +65,21 @@ public: /// important that it be constant over the lifetime of this object. virtual size_t LogicalSizeInBytes() const = 0; - typedef imgFrame::AddSizeOfCbData AddSizeOfCbData; - typedef imgFrame::AddSizeOfCb AddSizeOfCb; - /// @return the actual number of bytes of memory this ISurfaceProvider is /// using. May vary over the lifetime of the ISurfaceProvider. The default /// implementation is appropriate for static ISurfaceProviders. virtual void AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf, - const AddSizeOfCb& aCallback) + size_t& aHeapSizeOut, + size_t& aNonHeapSizeOut, + size_t& aExtHandlesOut) { DrawableFrameRef ref = DrawableRef(/* aFrame = */ 0); if (!ref) { return; } - ref->AddSizeOfExcludingThis(aMallocSizeOf, aCallback); + ref->AddSizeOfExcludingThis(aMallocSizeOf, aHeapSizeOut, + aNonHeapSizeOut, aExtHandlesOut); } virtual void Reset() { } diff --git a/image/Image.h b/image/Image.h index 56bcc9ca5181..d72bd67cd99a 100644 --- a/image/Image.h +++ b/image/Image.h @@ -36,8 +36,6 @@ struct MemoryCounter , mDecodedHeap(0) , mDecodedNonHeap(0) , mExternalHandles(0) - , mFrameIndex(0) - , mExternalId(0) { } void SetSource(size_t aCount) { mSource = aCount; } @@ -48,10 +46,6 @@ struct MemoryCounter size_t DecodedNonHeap() const { return mDecodedNonHeap; } void SetExternalHandles(size_t aCount) { mExternalHandles = aCount; } size_t ExternalHandles() const { return mExternalHandles; } - void SetFrameIndex(size_t aIndex) { mFrameIndex = aIndex; } - size_t FrameIndex() const { return mFrameIndex; } - void SetExternalId(uint64_t aId) { mExternalId = aId; } - uint64_t ExternalId() const { return mExternalId; } MemoryCounter& operator+=(const MemoryCounter& aOther) { @@ -67,8 +61,6 @@ private: size_t mDecodedHeap; size_t mDecodedNonHeap; size_t mExternalHandles; - size_t mFrameIndex; - uint64_t mExternalId; }; enum class SurfaceMemoryCounterType diff --git a/image/ImageMemoryReporter.cpp b/image/ImageMemoryReporter.cpp deleted file mode 100644 index e3d973f1755c..000000000000 --- a/image/ImageMemoryReporter.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* 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 "ImageMemoryReporter.h" -#include "Image.h" -#include "mozilla/layers/SharedSurfacesParent.h" -#include "nsIMemoryReporter.h" -#include "nsISupportsImpl.h" - -namespace mozilla { -namespace image { - -ImageMemoryReporter::WebRenderReporter* ImageMemoryReporter::sWrReporter; - -class ImageMemoryReporter::WebRenderReporter final : public nsIMemoryReporter -{ -public: - NS_DECL_ISUPPORTS - - WebRenderReporter() - { } - - NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, - nsISupports* aData, bool aAnonymize) override - { - layers::SharedSurfacesMemoryReport report; - layers::SharedSurfacesParent::AccumulateMemoryReport(report); - ReportSharedSurfaces(aHandleReport, aData, /* aIsForCompositor */ true, report); - return NS_OK; - } - -private: - virtual ~WebRenderReporter() - { } -}; - -NS_IMPL_ISUPPORTS(ImageMemoryReporter::WebRenderReporter, nsIMemoryReporter) - -/* static */ void -ImageMemoryReporter::InitForWebRender() -{ - MOZ_ASSERT(XRE_IsParentProcess() || XRE_IsGPUProcess()); - if (!sWrReporter) { - sWrReporter = new WebRenderReporter(); - RegisterStrongMemoryReporter(sWrReporter); - } -} - -/* static */ void -ImageMemoryReporter::ShutdownForWebRender() -{ - MOZ_ASSERT(XRE_IsParentProcess() || XRE_IsGPUProcess()); - if (sWrReporter) { - UnregisterStrongMemoryReporter(sWrReporter); - sWrReporter = nullptr; - } -} - -/* static */ void -ImageMemoryReporter::ReportSharedSurfaces(nsIHandleReportCallback* aHandleReport, - nsISupports* aData, - const layers::SharedSurfacesMemoryReport& aSharedSurfaces) -{ - ReportSharedSurfaces(aHandleReport, aData, - /* aIsForCompositor */ false, - aSharedSurfaces); -} - -/* static */ void -ImageMemoryReporter::ReportSharedSurfaces(nsIHandleReportCallback* aHandleReport, - nsISupports* aData, - bool aIsForCompositor, - const layers::SharedSurfacesMemoryReport& aSharedSurfaces) -{ - MOZ_ASSERT_IF(aIsForCompositor, XRE_IsParentProcess() || XRE_IsGPUProcess()); - MOZ_ASSERT_IF(!aIsForCompositor, - XRE_IsParentProcess() || XRE_IsContentProcess()); - - for (auto i = aSharedSurfaces.mSurfaces.begin(); - i != aSharedSurfaces.mSurfaces.end(); ++i) { - ReportSharedSurface(aHandleReport, aData, aIsForCompositor, i->first, i->second); - } -} - -/* static */ void -ImageMemoryReporter::ReportSharedSurface(nsIHandleReportCallback* aHandleReport, - nsISupports* aData, - bool aIsForCompositor, - uint64_t aExternalId, - const layers::SharedSurfacesMemoryReport::SurfaceEntry& aEntry) -{ - nsAutoCString path; - if (aIsForCompositor) { - path.AppendLiteral("gfx/webrender/images/mapped_from_owner/"); - } else { - path.AppendLiteral("gfx/webrender/images/owner_cache_missing/"); - } - - if (aIsForCompositor) { - path.AppendLiteral("pid="); - path.AppendInt(aEntry.mCreatorPid); - path.AppendLiteral("/"); - } - - if (gfxPrefs::ImageMemDebugReporting()) { - path.AppendPrintf("%016lx/", aExternalId); - } - - path.AppendLiteral("image("); - path.AppendInt(aEntry.mSize.width); - path.AppendLiteral("x"); - path.AppendInt(aEntry.mSize.height); - path.AppendLiteral(", compositor_ref:"); - path.AppendInt(aEntry.mConsumers); - path.AppendLiteral(", creator_ref:"); - path.AppendInt(aEntry.mCreatorRef); - path.AppendLiteral(")/decoded-nonheap"); - - size_t surfaceSize = - mozilla::ipc::SharedMemory::PageAlignedSize(aEntry.mSize.height * - aEntry.mStride); - - // If this memory has already been reported elsewhere (e.g. as part of our - // explicit section in the surface cache), we don't want report it again as - // KIND_NONHEAP and have it counted again. - bool sameProcess = aEntry.mCreatorPid == base::GetCurrentProcId(); - int32_t kind = aIsForCompositor && !sameProcess - ? nsIMemoryReporter::KIND_NONHEAP - : nsIMemoryReporter::KIND_OTHER; - - NS_NAMED_LITERAL_CSTRING(desc, "Decoded image data stored in shared memory."); - aHandleReport->Callback(EmptyCString(), path, kind, - nsIMemoryReporter::UNITS_BYTES, - surfaceSize, desc, aData); -} - -/* static */ void -ImageMemoryReporter::AppendSharedSurfacePrefix(nsACString& aPathPrefix, - const SurfaceMemoryCounter& aCounter, - layers::SharedSurfacesMemoryReport& aSharedSurfaces) -{ - uint64_t extId = aCounter.Values().ExternalId(); - if (extId) { - auto gpuEntry = aSharedSurfaces.mSurfaces.find(extId); - - if (gfxPrefs::ImageMemDebugReporting()) { - aPathPrefix.AppendPrintf(", external_id:%016lx", extId); - if (gpuEntry != aSharedSurfaces.mSurfaces.end()) { - aPathPrefix.AppendLiteral(", compositor_ref:"); - aPathPrefix.AppendInt(gpuEntry->second.mConsumers); - } else { - aPathPrefix.AppendLiteral(", compositor_ref:missing"); - } - } - - if (gpuEntry != aSharedSurfaces.mSurfaces.end()) { - MOZ_ASSERT(gpuEntry->second.mCreatorRef); - aSharedSurfaces.mSurfaces.erase(gpuEntry); - } - } -} - -/* static */ void -ImageMemoryReporter::TrimSharedSurfaces(const ImageMemoryCounter& aCounter, - layers::SharedSurfacesMemoryReport& aSharedSurfaces) -{ - if (aSharedSurfaces.mSurfaces.empty()) { - return; - } - - for (const SurfaceMemoryCounter& counter : aCounter.Surfaces()) { - uint64_t extId = counter.Values().ExternalId(); - if (extId) { - auto gpuEntry = aSharedSurfaces.mSurfaces.find(extId); - if (gpuEntry != aSharedSurfaces.mSurfaces.end()) { - MOZ_ASSERT(gpuEntry->second.mCreatorRef); - aSharedSurfaces.mSurfaces.erase(gpuEntry); - } - } - } -} - -} // image -} // mozilla diff --git a/image/ImageMemoryReporter.h b/image/ImageMemoryReporter.h deleted file mode 100644 index 3bfbb90ef765..000000000000 --- a/image/ImageMemoryReporter.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* 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_image_ImageMemoryReporter_h -#define mozilla_image_ImageMemoryReporter_h - -#include -#include "nsString.h" -#include "mozilla/layers/SharedSurfacesMemoryReport.h" - -class nsISupports; -class nsIHandleReportCallback; - -namespace mozilla { -namespace image { -struct ImageMemoryCounter; -struct SurfaceMemoryCounter; - -class ImageMemoryReporter final -{ -public: - /** - * Initializes image related memory reporting in the compositor process when - * using WebRender. - */ - static void InitForWebRender(); - - /** - * Tears down image related memory reporting in the compositor process when - * using WebRender. - */ - static void ShutdownForWebRender(); - - /** - * Report all remaining entries in the shared surface's memory report. This - * should be used by the content or main process to allow reporting any - * entries that is was unable to cross reference with the local surface cache. - * These are candidates for having been leaked. This should be used in - * conjunction with AppendSharedSurfacePrefix and/or TrimSharedSurfaces to - * produce the expected result. - */ - static void ReportSharedSurfaces(nsIHandleReportCallback* aHandleReport, - nsISupports* aData, - const layers::SharedSurfacesMemoryReport& aSharedSurfaces); - - /** - * Adjust the path prefix for a surface to include any additional metadata for - * the shared surface, if any. It will also remove any corresponding entries - * in the given memory report. - */ - static void AppendSharedSurfacePrefix(nsACString& aPathPrefix, - const SurfaceMemoryCounter& aCounter, - layers::SharedSurfacesMemoryReport& aSharedSurfaces); - - /** - * Remove all entries in the memory report for the given set of surfaces for - * an image. This is useful when we aren't reporting on a particular image - * because it isn't notable. - */ - static void TrimSharedSurfaces(const ImageMemoryCounter& aCounter, - layers::SharedSurfacesMemoryReport& aSharedSurfaces); - -private: - /** - * Report all remaining entries in the shared surface's memory report. - * - * aIsForCompositor controls how to intepret what remains in the report. If - * true, this should mirror exactly what is currently in - * SharedSurfacesParent's cache. This will report entries that are currently - * mapped into the compositor process. If false, then we are in a content or - * main process, and it should have removed entries that also exist in its - * local surface cache -- thus any remaining entries are those that are - * candidates for leaks. - */ - static void ReportSharedSurfaces(nsIHandleReportCallback* aHandleReport, - nsISupports* aData, - bool aIsForCompositor, - const layers::SharedSurfacesMemoryReport& aSharedSurfaces); - - static void ReportSharedSurface(nsIHandleReportCallback* aHandleReport, - nsISupports* aData, - bool aIsForCompositor, - uint64_t aExternalId, - const layers::SharedSurfacesMemoryReport::SurfaceEntry& aEntry); - - class WebRenderReporter; - static WebRenderReporter* sWrReporter; -}; - -} // image -} // mozilla - -#endif // mozilla_image_ImageMemoryReporter_h diff --git a/image/SurfaceCache.cpp b/image/SurfaceCache.cpp index f8ff42e1d84f..6b0f552f84ca 100644 --- a/image/SurfaceCache.cpp +++ b/image/SurfaceCache.cpp @@ -188,6 +188,11 @@ public: void Add(NotNull aCachedSurface, bool aIsFactor2) { + SurfaceMemoryCounter counter(aCachedSurface->GetSurfaceKey(), + aCachedSurface->IsLocked(), + aCachedSurface->CannotSubstitute(), + aIsFactor2); + if (aCachedSurface->IsPlaceholder()) { return; } @@ -196,22 +201,16 @@ public: // straightforward relationship to the size of the surface that // DrawableRef() returns if the surface is generated dynamically. (i.e., // for surfaces with PlaybackType::eAnimated.) - aCachedSurface->mProvider->AddSizeOfExcludingThis(mMallocSizeOf, - [&](ISurfaceProvider::AddSizeOfCbData& aMetadata) { - SurfaceMemoryCounter counter(aCachedSurface->GetSurfaceKey(), - aCachedSurface->IsLocked(), - aCachedSurface->CannotSubstitute(), - aIsFactor2); + size_t heap = 0; + size_t nonHeap = 0; + size_t handles = 0; + aCachedSurface->mProvider + ->AddSizeOfExcludingThis(mMallocSizeOf, heap, nonHeap, handles); + counter.Values().SetDecodedHeap(heap); + counter.Values().SetDecodedNonHeap(nonHeap); + counter.Values().SetExternalHandles(handles); - counter.Values().SetDecodedHeap(aMetadata.heap); - counter.Values().SetDecodedNonHeap(aMetadata.nonHeap); - counter.Values().SetExternalHandles(aMetadata.handles); - counter.Values().SetFrameIndex(aMetadata.index); - counter.Values().SetExternalId(aMetadata.externalId); - - mCounters.AppendElement(counter); - } - ); + mCounters.AppendElement(counter); } private: diff --git a/image/imgFrame.cpp b/image/imgFrame.cpp index 2b3286f78155..8cce3e2af54c 100644 --- a/image/imgFrame.cpp +++ b/image/imgFrame.cpp @@ -942,28 +942,26 @@ imgFrame::SetCompositingFailed(bool val) void imgFrame::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf, - const AddSizeOfCb& aCallback) const + size_t& aHeapSizeOut, + size_t& aNonHeapSizeOut, + size_t& aExtHandlesOut) const { MonitorAutoLock lock(mMonitor); - AddSizeOfCbData metadata; if (mPalettedImageData) { - metadata.heap += aMallocSizeOf(mPalettedImageData); + aHeapSizeOut += aMallocSizeOf(mPalettedImageData); } if (mLockedSurface) { - metadata.heap += aMallocSizeOf(mLockedSurface); + aHeapSizeOut += aMallocSizeOf(mLockedSurface); } if (mOptSurface) { - metadata.heap += aMallocSizeOf(mOptSurface); + aHeapSizeOut += aMallocSizeOf(mOptSurface); } if (mRawSurface) { - metadata.heap += aMallocSizeOf(mRawSurface); - mRawSurface->AddSizeOfExcludingThis(aMallocSizeOf, metadata.heap, - metadata.nonHeap, metadata.handles, - metadata.externalId); + aHeapSizeOut += aMallocSizeOf(mRawSurface); + mRawSurface->AddSizeOfExcludingThis(aMallocSizeOf, aHeapSizeOut, + aNonHeapSizeOut, aExtHandlesOut); } - - aCallback(metadata); } } // namespace image diff --git a/image/imgFrame.h b/image/imgFrame.h index 114f7af9c907..a5ea327872df 100644 --- a/image/imgFrame.h +++ b/image/imgFrame.h @@ -206,22 +206,9 @@ public: void FinalizeSurface(); already_AddRefed GetSourceSurface(); - struct AddSizeOfCbData { - AddSizeOfCbData() - : heap(0), nonHeap(0), handles(0), index(0), externalId(0) - { } - - size_t heap; - size_t nonHeap; - size_t handles; - size_t index; - uint64_t externalId; - }; - - typedef std::function AddSizeOfCb; - - void AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf, - const AddSizeOfCb& aCallback) const; + void AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf, size_t& aHeapSizeOut, + size_t& aNonHeapSizeOut, + size_t& aExtHandlesOut) const; private: // methods diff --git a/image/imgLoader.cpp b/image/imgLoader.cpp index f2d443bfc192..d675b2262d26 100644 --- a/image/imgLoader.cpp +++ b/image/imgLoader.cpp @@ -46,8 +46,6 @@ #include "nsReadableUtils.h" #include "mozilla/dom/ContentParent.h" #include "mozilla/dom/nsMixedContentBlocker.h" -#include "mozilla/image/ImageMemoryReporter.h" -#include "mozilla/layers/CompositorManagerChild.h" #include "nsIApplicationCache.h" #include "nsIApplicationCacheContainer.h" @@ -82,34 +80,6 @@ public: NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override - { - MOZ_ASSERT(NS_IsMainThread()); - - layers::CompositorManagerChild* manager = CompositorManagerChild::GetInstance(); - if (!manager || !gfxPrefs::ImageMemDebugReporting()) { - layers::SharedSurfacesMemoryReport sharedSurfaces; - FinishCollectReports(aHandleReport, aData, aAnonymize, sharedSurfaces); - return NS_OK; - } - - RefPtr self(this); - nsCOMPtr handleReport(aHandleReport); - nsCOMPtr data(aData); - manager->SendReportSharedSurfacesMemory( - [=](layers::SharedSurfacesMemoryReport aReport) { - self->FinishCollectReports(handleReport, data, aAnonymize, aReport); - }, - [=](mozilla::ipc::ResponseRejectReason aReason) { - layers::SharedSurfacesMemoryReport sharedSurfaces; - self->FinishCollectReports(handleReport, data, aAnonymize, sharedSurfaces); - } - ); - return NS_OK; - } - - void FinishCollectReports(nsIHandleReportCallback* aHandleReport, - nsISupports* aData, bool aAnonymize, - layers::SharedSurfacesMemoryReport& aSharedSurfaces) { nsTArray chrome; nsTArray content; @@ -138,25 +108,16 @@ public: // Note that we only need to anonymize content image URIs. - ReportCounterArray(aHandleReport, aData, chrome, "images/chrome", - /* aAnonymize */ false, aSharedSurfaces); + ReportCounterArray(aHandleReport, aData, chrome, "images/chrome"); ReportCounterArray(aHandleReport, aData, content, "images/content", - aAnonymize, aSharedSurfaces); + aAnonymize); // Uncached images may be content or chrome, so anonymize them. ReportCounterArray(aHandleReport, aData, uncached, "images/uncached", - aAnonymize, aSharedSurfaces); + aAnonymize); - // Report any shared surfaces that were not merged with the surface cache. - ImageMemoryReporter::ReportSharedSurfaces(aHandleReport, aData, - aSharedSurfaces); - - nsCOMPtr imgr = - do_GetService("@mozilla.org/memory-reporter-manager;1"); - if (imgr) { - imgr->EndReport(); - } + return NS_OK; } static int64_t ImagesContentUsedUncompressedDistinguishedAmount() @@ -245,8 +206,7 @@ private: nsISupports* aData, nsTArray& aCounterArray, const char* aPathPrefix, - bool aAnonymize, - layers::SharedSurfacesMemoryReport& aSharedSurfaces) + bool aAnonymize = false) { MemoryTotal summaryTotal; MemoryTotal nonNotableTotal; @@ -270,11 +230,9 @@ private: summaryTotal += counter; - if (counter.IsNotable() || gfxPrefs::ImageMemDebugReporting()) { - ReportImage(aHandleReport, aData, aPathPrefix, - counter, aSharedSurfaces); + if (counter.IsNotable()) { + ReportImage(aHandleReport, aData, aPathPrefix, counter); } else { - ImageMemoryReporter::TrimSharedSurfaces(counter, aSharedSurfaces); nonNotableTotal += counter; } } @@ -291,8 +249,7 @@ private: static void ReportImage(nsIHandleReportCallback* aHandleReport, nsISupports* aData, const char* aPathPrefix, - const ImageMemoryCounter& aCounter, - layers::SharedSurfacesMemoryReport& aSharedSurfaces) + const ImageMemoryCounter& aCounter) { nsAutoCString pathPrefix(NS_LITERAL_CSTRING("explicit/")); pathPrefix.Append(aPathPrefix); @@ -314,7 +271,7 @@ private: pathPrefix.AppendLiteral(")/"); - ReportSurfaces(aHandleReport, aData, pathPrefix, aCounter, aSharedSurfaces); + ReportSurfaces(aHandleReport, aData, pathPrefix, aCounter); ReportSourceValue(aHandleReport, aData, pathPrefix, aCounter.Values()); } @@ -322,8 +279,7 @@ private: static void ReportSurfaces(nsIHandleReportCallback* aHandleReport, nsISupports* aData, const nsACString& aPathPrefix, - const ImageMemoryCounter& aCounter, - layers::SharedSurfacesMemoryReport& aSharedSurfaces) + const ImageMemoryCounter& aCounter) { for (const SurfaceMemoryCounter& counter : aCounter.Surfaces()) { nsAutoCString surfacePathPrefix(aPathPrefix); @@ -344,23 +300,15 @@ private: surfacePathPrefix.AppendInt(counter.Key().Size().height); if (counter.Values().ExternalHandles() > 0) { - surfacePathPrefix.AppendLiteral(", handles:"); + surfacePathPrefix.AppendLiteral(", external:"); surfacePathPrefix.AppendInt(uint32_t(counter.Values().ExternalHandles())); } - ImageMemoryReporter::AppendSharedSurfacePrefix(surfacePathPrefix, counter, - aSharedSurfaces); - if (counter.Type() == SurfaceMemoryCounterType::NORMAL) { PlaybackType playback = counter.Key().Playback(); - if (playback == PlaybackType::eAnimated) { - if (gfxPrefs::ImageMemDebugReporting()) { - surfacePathPrefix.AppendPrintf(" (animation %4u)", - uint32_t(counter.Values().FrameIndex())); - } else { - surfacePathPrefix.AppendLiteral(" (animation)"); - } - } + surfacePathPrefix.Append(playback == PlaybackType::eAnimated + ? " (animation)" + : ""); if (counter.Key().Flags() != DefaultSurfaceFlags()) { surfacePathPrefix.AppendLiteral(", flags:"); @@ -1411,7 +1359,7 @@ void imgLoader::GlobalInit() sCacheMaxSize = cachesize > 0 ? cachesize : 0; sMemReporter = new imgMemoryReporter(); - RegisterStrongAsyncMemoryReporter(sMemReporter); + RegisterStrongMemoryReporter(sMemReporter); RegisterImagesContentUsedUncompressedDistinguishedAmount( imgMemoryReporter::ImagesContentUsedUncompressedDistinguishedAmount); diff --git a/image/imgRequest.cpp b/image/imgRequest.cpp index bb9ae1797f3a..51ee8ec23ae3 100644 --- a/image/imgRequest.cpp +++ b/image/imgRequest.cpp @@ -40,7 +40,6 @@ #include "nsProperties.h" #include "mozilla/IntegerPrintfMacros.h" -#include "mozilla/SizeOfState.h" #include "mozilla/Telemetry.h" using namespace mozilla; diff --git a/image/moz.build b/image/moz.build index 07f87a9504d4..352e8a266973 100644 --- a/image/moz.build +++ b/image/moz.build @@ -53,10 +53,6 @@ EXPORTS += [ 'SurfaceCacheUtils.h', ] -EXPORTS.mozilla.image += [ - 'ImageMemoryReporter.h', -] - UNIFIED_SOURCES += [ 'AnimationFrameBuffer.cpp', 'AnimationSurfaceProvider.cpp', @@ -72,7 +68,6 @@ UNIFIED_SOURCES += [ 'Image.cpp', 'ImageCacheKey.cpp', 'ImageFactory.cpp', - 'ImageMemoryReporter.cpp', 'ImageOps.cpp', 'ImageWrapper.cpp', 'imgFrame.cpp', diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 74fd6bb80599..f1f2af9a6587 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -4675,9 +4675,6 @@ pref("image.mem.animated.use_heap", true); pref("image.mem.animated.use_heap", false); #endif -// Enable extra information for debugging in the image memory reports. -pref("image.mem.debug-reporting", false); - // Decodes images into shared memory to allow direct use in separate // rendering processes. Only applicable with WebRender. pref("image.mem.shared", true);