Backed out 6 changesets (bug 1492930) for build bustages on ImageMemoryReporter.cpp. CLOSED TREE
authorNarcis Beleuzu <nbeleuzu@mozilla.com>
Tue, 25 Sep 2018 13:33:17 +0300
changeset 438157 597019fb23d9362690d9c51cbe35ff5bd6d509b6
parent 438156 9d1ff0d0af47c062842fdb82e2b1cc5453b3d7ca
child 438158 26719c685fd34be70dc98012b393525036e83335
push id34711
push useraciure@mozilla.com
push dateTue, 25 Sep 2018 21:49:34 +0000
treeherdermozilla-central@2e3e89c9c68c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1492930
milestone64.0a1
backs out9d1ff0d0af47c062842fdb82e2b1cc5453b3d7ca
bdb1bf2d8062dc54fceaa06c9a032ea6c12489e4
2959314ecf7caaf5def4a05e280c732c5365027b
587e01daa080af33c43fe71edf307e02c5a97eb2
1a6b422c5a9002dc161e7811bccd6630ccd76d85
a3b3f4cdc9fad949abda893b2e1933e078aa569e
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
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
gfx/2d/SourceSurfaceRawData.cpp
gfx/2d/SourceSurfaceRawData.h
gfx/ipc/GPUParent.cpp
gfx/layers/SourceSurfaceSharedData.cpp
gfx/layers/SourceSurfaceSharedData.h
gfx/layers/SourceSurfaceVolatileData.cpp
gfx/layers/SourceSurfaceVolatileData.h
gfx/layers/ipc/CompositorManagerParent.cpp
gfx/layers/ipc/CompositorManagerParent.h
gfx/layers/ipc/PCompositorManager.ipdl
gfx/layers/ipc/SharedSurfacesChild.cpp
gfx/layers/ipc/SharedSurfacesChild.h
gfx/layers/ipc/SharedSurfacesMemoryReport.h
gfx/layers/ipc/SharedSurfacesParent.cpp
gfx/layers/ipc/SharedSurfacesParent.h
gfx/layers/moz.build
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxPrefs.h
image/AnimationSurfaceProvider.cpp
image/AnimationSurfaceProvider.h
image/FrameAnimator.cpp
image/ISurfaceProvider.h
image/Image.h
image/ImageMemoryReporter.cpp
image/ImageMemoryReporter.h
image/SurfaceCache.cpp
image/imgFrame.cpp
image/imgFrame.h
image/imgLoader.cpp
image/imgRequest.cpp
image/moz.build
modules/libpref/init/all.js
--- a/gfx/2d/2D.h
+++ b/gfx/2d/2D.h
@@ -415,17 +415,17 @@ public:
    */
   virtual void *GetNativeSurface(NativeSurfaceType aType) {
     return nullptr;
   }
 
   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) {
     mUserData.RemoveAndDestroy(key);
   }
 
 protected:
   friend class DrawTargetCaptureImpl;
@@ -582,18 +582,17 @@ public:
   virtual already_AddRefed<DataSourceSurface> GetDataSurface() override;
 
   /**
    * Add the size of the underlying data buffer to the aggregate.
    */
   virtual void AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
                                       size_t& aHeapSizeOut,
                                       size_t& aNonHeapSizeOut,
-                                      size_t& aExtHandlesOut,
-                                      uint64_t& aExtIdOut) const
+                                      size_t& aExtHandlesOut) const
   {
   }
 
   /**
    * Returns whether or not the data was allocated on the heap. This should
    * be used to determine if the memory needs to be cleared to 0.
    */
   virtual bool OnHeap() const
--- a/gfx/2d/SourceSurfaceRawData.cpp
+++ b/gfx/2d/SourceSurfaceRawData.cpp
@@ -78,16 +78,15 @@ SourceSurfaceAlignedRawData::Init(const 
 
   return mArray != nullptr;
 }
 
 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);
 }
 
 } // namespace gfx
 } // namespace mozilla
--- a/gfx/2d/SourceSurfaceRawData.h
+++ b/gfx/2d/SourceSurfaceRawData.h
@@ -126,18 +126,17 @@ public:
 
   virtual SurfaceType GetType() const override { return SurfaceType::DATA; }
   virtual IntSize GetSize() const override { return mSize; }
   virtual SurfaceFormat GetFormat() const override { return mFormat; }
 
   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
   {
     aMappedSurface->mData = GetData();
     aMappedSurface->mStride = Stride();
     bool success = !!aMappedSurface->mData;
     if (success) {
       mMapCount++;
--- a/gfx/ipc/GPUParent.cpp
+++ b/gfx/ipc/GPUParent.cpp
@@ -17,17 +17,16 @@
 #include "mozilla/Assertions.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/dom/MemoryReportRequest.h"
 #include "mozilla/dom/VideoDecoderManagerChild.h"
 #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"
 #include "mozilla/layers/APZThreadUtils.h"
 #include "mozilla/layers/APZUtils.h"    // for apz::InitializeGlobalState
 #include "mozilla/layers/CompositorBridgeParent.h"
 #include "mozilla/layers/CompositorManagerParent.h"
 #include "mozilla/layers/CompositorThread.h"
@@ -264,17 +263,16 @@ GPUParent::RecvInit(nsTArray<GfxPrefSett
     MOZ_ASSERT(library);
     Factory::SetFTLibrary(library);
   }
 #endif
 
   // Make sure to do this *after* we update gfxVars above.
   if (gfxVars::UseWebRender()) {
     wr::RenderThread::Start();
-    image::ImageMemoryReporter::InitForWebRender();
   }
 
   VRManager::ManagerInit();
   // Send a message to the UI process that we're done.
   GPUDeviceData data;
   RecvGetDeviceStatus(&data);
   Unused << SendInitComplete(data);
 
@@ -535,18 +533,16 @@ GPUParent::ActorDestroy(ActorDestroyReas
   CompositorThreadHolder::Shutdown();
   VRListenerThreadHolder::Shutdown();
   // 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()) {
     wr::RenderThread::ShutDown();
   }
 
-  image::ImageMemoryReporter::ShutdownForWebRender();
-
   // Shut down the default GL context provider.
   gl::GLContextProvider::Shutdown();
 
 #if defined(XP_WIN)
   // The above shutdown calls operate on the available context providers on
   // most platforms.  Windows is a "special snowflake", though, and has three
   // context providers available, so we have to shut all of them down.
   // We should only support the default GL provider on Windows; then, this
--- a/gfx/layers/SourceSurfaceSharedData.cpp
+++ b/gfx/layers/SourceSurfaceSharedData.cpp
@@ -92,30 +92,25 @@ SourceSurfaceSharedData::GuaranteePersis
 {
   // Shared memory is not unmapped until we release SourceSurfaceSharedData.
 }
 
 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) {
     aNonHeapSizeOut += GetAlignedDataLength();
   }
   if (!mClosed) {
     ++aExtHandlesOut;
   }
-  Maybe<wr::ExternalImageId> extId = SharedSurfacesChild::GetExternalId(this);
-  if (extId) {
-    aExtIdOut = wr::AsUint64(extId.ref());
-  }
 }
 
 uint8_t*
 SourceSurfaceSharedData::GetDataInternal() const
 {
   mMutex.AssertCurrentThreadOwns();
 
   // If we have an old buffer lingering, it is because we get reallocated to
--- a/gfx/layers/SourceSurfaceSharedData.h
+++ b/gfx/layers/SourceSurfaceSharedData.h
@@ -38,17 +38,16 @@ class SourceSurfaceSharedDataWrapper fin
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SourceSurfaceSharedDataWrapper, override)
 
   SourceSurfaceSharedDataWrapper()
     : mStride(0)
     , mConsumers(0)
     , mFormat(SurfaceFormat::UNKNOWN)
     , mCreatorPid(0)
-    , mCreatorRef(true)
   { }
 
   bool Init(const IntSize& aSize,
             int32_t aStride,
             SurfaceFormat aFormat,
             const SharedMemoryBasic::Handle& aHandle,
             base::ProcessId aCreatorPid);
 
@@ -75,40 +74,22 @@ public:
     return false;
   }
 
   bool AddConsumer()
   {
     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
   {
     return static_cast<size_t>(mStride) * mSize.height;
   }
 
   size_t GetAlignedDataLength() const
   {
@@ -116,17 +97,16 @@ private:
   }
 
   int32_t mStride;
   uint32_t mConsumers;
   IntSize mSize;
   RefPtr<SharedMemoryBasic> mBuf;
   SurfaceFormat mFormat;
   base::ProcessId mCreatorPid;
-  bool mCreatorRef;
 };
 
 /**
  * This class is used to wrap shared (as in process) data buffers used by a
  * source surface.
  */
 class SourceSurfaceSharedData final : public DataSourceSurface
 {
@@ -170,18 +150,17 @@ public:
   IntSize GetSize() const override { return mSize; }
   SurfaceFormat GetFormat() const override { return mFormat; }
 
   void GuaranteePersistance() override;
 
   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
   {
     return false;
   }
 
   /**
    * Although Map (and Moz2D in general) isn't normally threadsafe,
--- a/gfx/layers/SourceSurfaceVolatileData.cpp
+++ b/gfx/layers/SourceSurfaceVolatileData.cpp
@@ -37,18 +37,17 @@ SourceSurfaceVolatileData::GuaranteePers
 {
   MOZ_ASSERT_UNREACHABLE("Should use SourceSurfaceRawData wrapper!");
 }
 
 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);
     aNonHeapSizeOut += mVBuf->NonHeapSizeOfExcludingThis();
 #ifdef ANDROID
     if (!mVBuf->OnHeap()) {
       // Volatile buffers keep a file handle open on Android.
       ++aExtHandlesOut;
--- a/gfx/layers/SourceSurfaceVolatileData.h
+++ b/gfx/layers/SourceSurfaceVolatileData.h
@@ -48,18 +48,17 @@ public:
   IntSize GetSize() const override { return mSize; }
   SurfaceFormat GetFormat() const override { return mFormat; }
 
   void GuaranteePersistance() override;
 
   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
   {
     return mVBuf->OnHeap();
   }
 
   // Althought Map (and Moz2D in general) isn't normally threadsafe,
   // we want to allow it for SourceSurfaceVolatileData since it should
--- a/gfx/layers/ipc/CompositorManagerParent.cpp
+++ b/gfx/layers/ipc/CompositorManagerParent.cpp
@@ -285,25 +285,16 @@ CompositorManagerParent::RecvAddSharedSu
 mozilla::ipc::IPCResult
 CompositorManagerParent::RecvRemoveSharedSurface(const wr::ExternalImageId& aId)
 {
   SharedSurfacesParent::Remove(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()
 {
   nsTArray<PCompositorBridgeParent*> compositorBridges;
   ManagedPCompositorBridgeParent(compositorBridges);
   for (auto bridge : compositorBridges) {
     static_cast<CompositorBridgeParentBase*>(bridge)->NotifyMemoryPressure();
   }
   return IPC_OK();
--- a/gfx/layers/ipc/CompositorManagerParent.h
+++ b/gfx/layers/ipc/CompositorManagerParent.h
@@ -38,17 +38,16 @@ public:
   CreateSameProcessWidgetCompositorBridge(CSSToLayoutDeviceScale aScale,
                                           const CompositorOptions& aOptions,
                                           bool aUseExternalSurfaceSize,
                                           const gfx::IntSize& aSurfaceSize);
 
   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;
 
   virtual mozilla::ipc::IPCResult RecvReportMemory(ReportMemoryResolver&&) override;
 
   void BindComplete();
   void ActorDestroy(ActorDestroyReason aReason) override;
 
--- a/gfx/layers/ipc/PCompositorManager.ipdl
+++ b/gfx/layers/ipc/PCompositorManager.ipdl
@@ -13,17 +13,16 @@ include "mozilla/layers/WebRenderMessage
 using struct mozilla::void_t from "ipc/IPCMessageUtils.h";
 using mozilla::TimeDuration from "mozilla/TimeStamp.h";
 using mozilla::CSSToLayoutDeviceScale from "Units.h";
 using mozilla::gfx::IntSize from "mozilla/gfx/2D.h";
 using mozilla::ipc::SharedMemoryBasic::Handle from "mozilla/ipc/SharedMemoryBasic.h";
 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 {
 
 struct WidgetCompositorOptions {
   CSSToLayoutDeviceScale scale;
   TimeDuration vsyncRate;
   CompositorOptions options;
@@ -72,17 +71,16 @@ parent:
    * - A "same process widget" PCompositorBridge is requested by the combined
    *   GPU/UI process for each "top level browser window" as above.
    * See gfx/layers/ipc/PCompositorBridge.ipdl for more details.
    */
   async PCompositorBridge(CompositorBridgeOptions options);
 
   async AddSharedSurface(ExternalImageId aId, SurfaceDescriptorShared aDesc);
   async RemoveSharedSurface(ExternalImageId aId);
-  async ReportSharedSurfacesMemory() returns (SharedSurfacesMemoryReport aReport);
 
   async NotifyMemoryPressure();
 
   async ReportMemory() returns (MemoryReport aReport);
 };
 
 } // layers
 } // mozilla
--- a/gfx/layers/ipc/SharedSurfacesChild.cpp
+++ b/gfx/layers/ipc/SharedSurfacesChild.cpp
@@ -14,18 +14,16 @@
 #include "mozilla/layers/WebRenderLayerManager.h"
 #include "mozilla/SystemGroup.h"        // for SystemGroup
 
 namespace mozilla {
 namespace layers {
 
 using namespace mozilla::gfx;
 
-/* static */ UserDataKey SharedSurfacesChild::sSharedKey;
-
 class SharedSurfacesChild::ImageKeyData final
 {
 public:
   ImageKeyData(WebRenderLayerManager* aManager,
                const wr::ImageKey& aImageKey)
     : mManager(aManager)
     , mImageKey(aImageKey)
   { }
@@ -221,16 +219,17 @@ SharedSurfacesChild::ShareInternal(Sourc
     // We cannot try to share the surface, most likely because the GPU process
     // crashed. Ideally, we would retry when it is ready, but the handles may be
     // a scarce resource, which can cause much more serious problems if we run
     // out. Better to copy into a fresh buffer later.
     aSurface->FinishedSharing();
     return NS_ERROR_NOT_INITIALIZED;
   }
 
+  static UserDataKey sSharedKey;
   SharedUserData* data =
     static_cast<SharedUserData*>(aSurface->GetUserData(&sSharedKey));
   if (!data) {
     data = new SharedUserData(manager->GetNextExternalImageId());
     aSurface->AddUserData(&sSharedKey, data, DestroySharedUserData);
   } else if (!manager->OwnsExternalImageId(data->Id())) {
     // If the id isn't owned by us, that means the bridge was reinitialized, due
     // to the GPU process crashing. All previous mappings have been released.
@@ -451,25 +450,10 @@ SharedSurfacesChild::Unshare(const wr::E
     // Only attempt to release current mappings in the GPU process. It is
     // possible we had a surface that was previously shared, the GPU process
     // crashed / was restarted, and then we freed the surface. In that case
     // we know the mapping has already been freed.
     manager->SendRemoveSharedSurface(aId);
   }
 }
 
-/* static */ Maybe<wr::ExternalImageId>
-SharedSurfacesChild::GetExternalId(const SourceSurfaceSharedData* aSurface)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  MOZ_ASSERT(aSurface);
-
-  SharedUserData* data =
-    static_cast<SharedUserData*>(aSurface->GetUserData(&sSharedKey));
-  if (!data || !data->IsShared()) {
-    return Nothing();
-  }
-
-  return Some(data->Id());
-}
-
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/ipc/SharedSurfacesChild.h
+++ b/gfx/layers/ipc/SharedSurfacesChild.h
@@ -5,20 +5,18 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MOZILLA_GFX_SHAREDSURFACESCHILD_H
 #define MOZILLA_GFX_SHAREDSURFACESCHILD_H
 
 #include <stddef.h>                     // for size_t
 #include <stdint.h>                     // 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 {
 namespace gfx {
 class SourceSurfaceSharedData;
 } // namespace gfx
 
 namespace wr {
@@ -68,35 +66,26 @@ public:
    * used to share the image data for this particular container, it will return
    * NS_ERROR_NOT_IMPLEMENTED. This must be called from the main thread.
    */
   static nsresult Share(ImageContainer* aContainer,
                         WebRenderLayerManager* aManager,
                         wr::IpcResourceUpdateQueue& aResources,
                         wr::ImageKey& aKey);
 
-  /**
-   * Get the external ID, if any, bound to the shared surface. Used for memory
-   * reporting purposes.
-   */
-  static Maybe<wr::ExternalImageId>
-  GetExternalId(const gfx::SourceSurfaceSharedData* aSurface);
-
 private:
   SharedSurfacesChild() = delete;
   ~SharedSurfacesChild() = delete;
 
   class ImageKeyData;
   class SharedUserData;
 
   static nsresult ShareInternal(gfx::SourceSurfaceSharedData* aSurface,
                                 SharedUserData** aUserData);
 
   static void Unshare(const wr::ExternalImageId& aId, nsTArray<ImageKeyData>& aKeys);
   static void DestroySharedUserData(void* aClosure);
-
-  static gfx::UserDataKey sSharedKey;
 };
 
 } // namespace layers
 } // namespace mozilla
 
 #endif
deleted file mode 100644
--- 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 <cstdint>                      // for uint32_t
-#include <unordered_map>
-#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<uint64_t, SurfaceEntry> mSurfaces;
-};
-
-} // namespace layers
-} // namespace mozilla
-
-namespace IPC {
-
-template<>
-struct ParamTraits<mozilla::layers::SharedSurfacesMemoryReport>
-{
-  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<mozilla::layers::SharedSurfacesMemoryReport::SurfaceEntry>
-  : public PlainOldDataSerializer<mozilla::layers::SharedSurfacesMemoryReport::SurfaceEntry>
-{
-};
-
-template<class KeyType, class DataType>
-struct ParamTraits<std::unordered_map<KeyType, DataType>>
-{
-  typedef std::unordered_map<KeyType, DataType> 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
--- a/gfx/layers/ipc/SharedSurfacesParent.cpp
+++ b/gfx/layers/ipc/SharedSurfacesParent.cpp
@@ -1,18 +1,16 @@
 /* -*- 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 "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"
 #include "mozilla/webrender/RenderThread.h"
 
 namespace mozilla {
 namespace layers {
 
@@ -82,31 +80,31 @@ SharedSurfacesParent::Acquire(const wr::
   if (surface) {
     DebugOnly<bool> rv = surface->AddConsumer();
     MOZ_ASSERT(!rv);
   }
   return surface.forget();
 }
 
 /* static */ bool
-SharedSurfacesParent::Release(const wr::ExternalImageId& aId, bool aForCreator)
+SharedSurfacesParent::Release(const wr::ExternalImageId& aId)
 {
   StaticMutexAutoLock lock(sMutex);
   if (!sInstance) {
     return false;
   }
 
   uint64_t id = wr::AsUint64(aId);
   RefPtr<SourceSurfaceSharedDataWrapper> surface;
   sInstance->mSurfaces.Get(wr::AsUint64(aId), getter_AddRefs(surface));
   if (!surface) {
     return false;
   }
 
-  if (surface->RemoveConsumer(aForCreator)) {
+  if (surface->RemoveConsumer()) {
     wr::RenderThread::Get()->UnregisterExternalImage(id);
     sInstance->mSurfaces.Remove(id);
   }
 
   return true;
 }
 
 /* static */ void
@@ -140,34 +138,32 @@ SharedSurfacesParent::AddSameProcess(con
   sInstance->mSurfaces.Put(id, surface);
 }
 
 /* static */ void
 SharedSurfacesParent::RemoveSameProcess(const wr::ExternalImageId& aId)
 {
   MOZ_ASSERT(XRE_IsParentProcess());
   MOZ_ASSERT(NS_IsMainThread());
-  Release(aId, /* aForCreator */ true);
+  Release(aId);
 }
 
 /* static */ void
 SharedSurfacesParent::DestroyProcess(base::ProcessId aPid)
 {
   StaticMutexAutoLock lock(sMutex);
   if (!sInstance) {
     return;
   }
 
   // Note that the destruction of a parent may not be cheap if it still has a
   // 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();
     }
   }
 }
 
 /* static */ void
 SharedSurfacesParent::Add(const wr::ExternalImageId& aId,
@@ -199,62 +195,14 @@ SharedSurfacesParent::Add(const wr::Exte
 
   surface->AddConsumer();
   sInstance->mSurfaces.Put(id, surface.forget());
 }
 
 /* static */ void
 SharedSurfacesParent::Remove(const wr::ExternalImageId& aId)
 {
-  DebugOnly<bool> rv = Release(aId, /* aForCreator */ true);
+  DebugOnly<bool> 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
--- a/gfx/layers/ipc/SharedSurfacesParent.h
+++ b/gfx/layers/ipc/SharedSurfacesParent.h
@@ -24,48 +24,41 @@ namespace gfx {
 class DataSourceSurface;
 class SourceSurfaceSharedData;
 class SourceSurfaceSharedDataWrapper;
 } // namespace gfx
 
 namespace layers {
 
 class SharedSurfacesChild;
-class SharedSurfacesMemoryReport;
 
 class SharedSurfacesParent final
 {
 public:
   static void Initialize();
   static void Shutdown();
 
   // Get without increasing the consumer count.
   static already_AddRefed<gfx::DataSourceSurface>
   Get(const wr::ExternalImageId& aId);
 
   // Get but also increase the consumer count. Must call Release after finished.
   static already_AddRefed<gfx::DataSourceSurface>
   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,
                   base::ProcessId aPid);
 
   static void Remove(const wr::ExternalImageId& aId);
 
   static void DestroyProcess(base::ProcessId aPid);
 
-  static void AccumulateMemoryReport(base::ProcessId aPid,
-                                     SharedSurfacesMemoryReport& aReport);
-
-  static bool AccumulateMemoryReport(SharedSurfacesMemoryReport& aReport);
-
   ~SharedSurfacesParent();
 
 private:
   friend class SharedSurfacesChild;
 
   SharedSurfacesParent();
 
   static void AddSameProcess(const wr::ExternalImageId& aId,
--- a/gfx/layers/moz.build
+++ b/gfx/layers/moz.build
@@ -191,17 +191,16 @@ EXPORTS.mozilla.layers += [
     'ipc/LayerTransactionParent.h',
     'ipc/LayerTreeOwnerTracker.h',
     'ipc/RefCountedShmem.h',
     'ipc/RemoteContentController.h',
     'ipc/ShadowLayers.h',
     'ipc/SharedPlanarYCbCrImage.h',
     'ipc/SharedRGBImage.h',
     'ipc/SharedSurfacesChild.h',
-    'ipc/SharedSurfacesMemoryReport.h',
     'ipc/SharedSurfacesParent.h',
     'ipc/SynchronousTask.h',
     'ipc/TextureForwarder.h',
     'ipc/UiCompositorControllerChild.h',
     'ipc/UiCompositorControllerMessageTypes.h',
     'ipc/UiCompositorControllerParent.h',
     'ipc/VideoBridgeChild.h',
     'ipc/VideoBridgeParent.h',
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -1,15 +1,14 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * 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 "mozilla/FontPropertyTypes.h"
-#include "mozilla/image/ImageMemoryReporter.h"
 #include "mozilla/layers/CompositorManagerChild.h"
 #include "mozilla/layers/CompositorThread.h"
 #include "mozilla/layers/ImageBridgeChild.h"
 #include "mozilla/layers/ISurfaceAllocator.h"     // for GfxMemoryImageReporter
 #include "mozilla/webrender/RenderThread.h"
 #include "mozilla/webrender/WebRenderAPI.h"
 #include "mozilla/webrender/webrender_ffi.h"
 #include "mozilla/layers/PaintThread.h"
@@ -1140,17 +1139,16 @@ gfxPlatform::InitLayersIPC()
     if (gfxVars::UseOMTP() && !recordreplay::IsRecordingOrReplaying()) {
       layers::PaintThread::Start();
     }
   }
 
   if (XRE_IsParentProcess() || recordreplay::IsRecordingOrReplaying()) {
     if (!gfxConfig::IsEnabled(Feature::GPU_PROCESS) && gfxVars::UseWebRender()) {
       wr::RenderThread::Start();
-      image::ImageMemoryReporter::InitForWebRender();
     }
 
     layers::CompositorThreadHolder::Start();
     gfx::VRListenerThreadHolder::Start();
   }
 }
 
 /* static */ void
@@ -1174,17 +1172,16 @@ gfxPlatform::ShutdownLayersIPC()
         }
     } else if (XRE_IsParentProcess()) {
         gfx::VRManagerChild::ShutDown();
         layers::CompositorManagerChild::Shutdown();
         layers::ImageBridgeChild::ShutDown();
         // 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()) {
           wr::RenderThread::ShutDown();
 
           Preferences::UnregisterCallback(WebRenderDebugPrefChangeCallback, WR_DEBUG_PREF);
         }
 
--- a/gfx/thebes/gfxPrefs.h
+++ b/gfx/thebes/gfxPrefs.h
@@ -552,17 +552,16 @@ private:
   DECL_GFX_PREF(Live, "image.decode-immediately.enabled",      ImageDecodeImmediatelyEnabled, bool, false);
   DECL_GFX_PREF(Live, "image.downscale-during-decode.enabled", ImageDownscaleDuringDecodeEnabled, bool, true);
   DECL_GFX_PREF(Live, "image.infer-src-animation.threshold-ms", ImageInferSrcAnimationThresholdMS, uint32_t, 2000);
   DECL_GFX_PREF(Live, "image.layout_network_priority",         ImageLayoutNetworkPriority, bool, true);
   DECL_GFX_PREF(Once, "image.mem.decode_bytes_at_a_time",      ImageMemDecodeBytesAtATime, uint32_t, 200000);
   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);
   DECL_GFX_PREF(Once, "image.mem.surfacecache.min_expiration_ms", ImageMemSurfaceCacheMinExpirationMS, uint32_t, 60*1000);
   DECL_GFX_PREF(Once, "image.mem.surfacecache.size_factor",    ImageMemSurfaceCacheSizeFactor, uint32_t, 64);
   DECL_GFX_PREF(Live, "image.mem.volatile.min_threshold_kb",   ImageMemVolatileMinThresholdKB, int32_t, -1);
   DECL_GFX_PREF(Once, "image.multithreaded_decoding.limit",    ImageMTDecodingLimit, int32_t, -1);
   DECL_GFX_PREF(Once, "image.multithreaded_decoding.idle_timeout", ImageMTDecodingIdleTimeout, int32_t, -1);
--- a/image/AnimationSurfaceProvider.cpp
+++ b/image/AnimationSurfaceProvider.cpp
@@ -201,33 +201,29 @@ AnimationSurfaceProvider::LogicalSizeInB
   // animation has, so we really can't do better here. This will become correct
   // once bug 1289954 is complete.
   IntSize size = GetSurfaceKey().Size();
   return 3 * size.width * size.height * sizeof(uint32_t);
 }
 
 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);
     }
   }
 }
 
 void
 AnimationSurfaceProvider::Run()
 {
   MutexAutoLock lock(mDecodingMutex);
--- a/image/AnimationSurfaceProvider.h
+++ b/image/AnimationSurfaceProvider.h
@@ -44,17 +44,19 @@ public:
   // We use the ISurfaceProvider constructor of DrawableSurface to indicate that
   // our surfaces are computed lazily.
   DrawableSurface Surface() override { return DrawableSurface(WrapNotNull(this)); }
 
   bool IsFinished() const override;
   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;
 
 protected:
   DrawableFrameRef DrawableRef(size_t aFrame) override;
   RawAccessFrameRef RawAccessRef(size_t aFrame) override;
 
   // Animation frames are always locked. This is because we only want to release
--- a/image/FrameAnimator.cpp
+++ b/image/FrameAnimator.cpp
@@ -556,34 +556,30 @@ DoCollectSizeOfCompositingSurfaces(const
                                    nsTArray<SurfaceMemoryCounter>& aCounters,
                                    MallocSizeOf aMallocSizeOf)
 {
   // Concoct a SurfaceKey for this surface.
   SurfaceKey key = RasterSurfaceKey(aSurface->GetImageSize(),
                                     DefaultSurfaceFlags(),
                                     PlaybackType::eStatic);
 
-  // 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);
+  // Create a counter for this surface.
+  SurfaceMemoryCounter counter(key, /* aIsLocked = */ true,
+                               /* aCannotSubstitute */ false,
+                               /* aIsFactor2 */ false, aType);
 
-      // 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);
+  // Extract the surface's memory usage information.
+  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);
 
-      aCounters.AppendElement(counter);
-    }
-  );
+  // Record it.
+  aCounters.AppendElement(counter);
 }
 
 void
 FrameAnimator::CollectSizeOfCompositingSurfaces(
     nsTArray<SurfaceMemoryCounter>& aCounters,
     MallocSizeOf aMallocSizeOf) const
 {
   if (mCompositingFrame) {
--- a/image/ISurfaceProvider.h
+++ b/image/ISurfaceProvider.h
@@ -60,31 +60,31 @@ public:
   virtual bool IsFullyDecoded() const { return IsFinished(); }
 
   /// @return the number of bytes of memory this ISurfaceProvider is expected to
   /// require. Optimizations may result in lower real memory usage. Trivial
   /// overhead is ignored. Because this value is used in bookkeeping, it's
   /// 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() { }
   virtual void Advance(size_t aFrame) { }
 
   /// @return the availability state of this ISurfaceProvider, which indicates
   /// whether DrawableRef() could successfully return a surface. Should only be
   /// called from SurfaceCache code as it relies on SurfaceCache for
--- a/image/Image.h
+++ b/image/Image.h
@@ -31,49 +31,41 @@ class Image;
 
 struct MemoryCounter
 {
   MemoryCounter()
     : mSource(0)
     , mDecodedHeap(0)
     , mDecodedNonHeap(0)
     , mExternalHandles(0)
-    , mFrameIndex(0)
-    , mExternalId(0)
   { }
 
   void SetSource(size_t aCount) { mSource = aCount; }
   size_t Source() const { return mSource; }
   void SetDecodedHeap(size_t aCount) { mDecodedHeap = aCount; }
   size_t DecodedHeap() const { return mDecodedHeap; }
   void SetDecodedNonHeap(size_t aCount) { mDecodedNonHeap = aCount; }
   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)
   {
     mSource += aOther.mSource;
     mDecodedHeap += aOther.mDecodedHeap;
     mDecodedNonHeap += aOther.mDecodedNonHeap;
     mExternalHandles += aOther.mExternalHandles;
     return *this;
   }
 
 private:
   size_t mSource;
   size_t mDecodedHeap;
   size_t mDecodedNonHeap;
   size_t mExternalHandles;
-  size_t mFrameIndex;
-  uint64_t mExternalId;
 };
 
 enum class SurfaceMemoryCounterType
 {
   NORMAL,
   COMPOSITING,
   COMPOSITING_PREV
 };
deleted file mode 100644
--- 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
deleted file mode 100644
--- 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 <cstdint>
-#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
--- a/image/SurfaceCache.cpp
+++ b/image/SurfaceCache.cpp
@@ -183,40 +183,39 @@ public:
     SurfaceMemoryReport(nsTArray<SurfaceMemoryCounter>& aCounters,
                         MallocSizeOf                    aMallocSizeOf)
       : mCounters(aCounters)
       , mMallocSizeOf(aMallocSizeOf)
     { }
 
     void Add(NotNull<CachedSurface*> aCachedSurface, bool aIsFactor2)
     {
+      SurfaceMemoryCounter counter(aCachedSurface->GetSurfaceKey(),
+                                   aCachedSurface->IsLocked(),
+                                   aCachedSurface->CannotSubstitute(),
+                                   aIsFactor2);
+
       if (aCachedSurface->IsPlaceholder()) {
         return;
       }
 
       // Record the memory used by the ISurfaceProvider. This may not have a
       // 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:
     nsTArray<SurfaceMemoryCounter>& mCounters;
     MallocSizeOf                    mMallocSizeOf;
   };
 
 private:
--- a/image/imgFrame.cpp
+++ b/image/imgFrame.cpp
@@ -937,34 +937,32 @@ void
 imgFrame::SetCompositingFailed(bool val)
 {
   MOZ_ASSERT(NS_IsMainThread());
   mCompositingFailed = 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
 } // namespace mozilla
--- a/image/imgFrame.h
+++ b/image/imgFrame.h
@@ -201,32 +201,19 @@ public:
   bool GetCompositingFailed() const;
   void SetCompositingFailed(bool val);
 
   void SetOptimizable();
 
   void FinalizeSurface();
   already_AddRefed<SourceSurface> 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<void(AddSizeOfCbData& aMetadata)> 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
 
   ~imgFrame();
 
   /**
    * Used when the caller desires raw access to the underlying frame buffer.
    * If the locking succeeds, the data pointer to the start of the buffer is
--- a/image/imgLoader.cpp
+++ b/image/imgLoader.cpp
@@ -41,18 +41,16 @@
 #include "nsIAsyncVerifyRedirectCallback.h"
 #include "nsIFileURL.h"
 #include "nsIFile.h"
 #include "nsCRT.h"
 #include "nsINetworkPredictor.h"
 #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"
 
 #include "nsIMemoryReporter.h"
 #include "DecoderFactory.h"
 #include "Image.h"
 #include "gfxPrefs.h"
@@ -78,44 +76,16 @@ class imgMemoryReporter final : public n
   ~imgMemoryReporter() = default;
 
 public:
   NS_DECL_ISUPPORTS
 
   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<imgMemoryReporter> self(this);
-    nsCOMPtr<nsIHandleReportCallback> handleReport(aHandleReport);
-    nsCOMPtr<nsISupports> 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<ImageMemoryCounter> chrome;
     nsTArray<ImageMemoryCounter> content;
     nsTArray<ImageMemoryCounter> uncached;
 
     for (uint32_t i = 0; i < mKnownLoaders.Length(); i++) {
       for (auto iter = mKnownLoaders[i]->mChromeCache.Iter(); !iter.Done(); iter.Next()) {
         imgCacheEntry* entry = iter.UserData();
         RefPtr<imgRequest> req = entry->GetRequest();
@@ -133,35 +103,26 @@ public:
         nsPtrHashKey<imgRequest>* entry = iter.Get();
         RefPtr<imgRequest> req = entry->GetKey();
         RecordCounterForRequest(req, &uncached, req->HasConsumers());
       }
     }
 
     // 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);
-
-    // Report any shared surfaces that were not merged with the surface cache.
-    ImageMemoryReporter::ReportSharedSurfaces(aHandleReport, aData,
-                                              aSharedSurfaces);
-
-    nsCOMPtr<nsIMemoryReporterManager> imgr =
-      do_GetService("@mozilla.org/memory-reporter-manager;1");
-    if (imgr) {
-      imgr->EndReport();
-    }
+                       aAnonymize);
+
+    return NS_OK;
   }
 
   static int64_t ImagesContentUsedUncompressedDistinguishedAmount()
   {
     size_t n = 0;
     for (uint32_t i = 0; i < imgLoader::sMemReporter->mKnownLoaders.Length();
          i++) {
       for (auto iter = imgLoader::sMemReporter->mKnownLoaders[i]->mCache.Iter();
@@ -240,18 +201,17 @@ private:
     MemoryCounter mUnusedVectorCounter;
   };
 
   // Reports all images of a single kind, e.g. all used chrome images.
   void ReportCounterArray(nsIHandleReportCallback* aHandleReport,
                           nsISupports* aData,
                           nsTArray<ImageMemoryCounter>& aCounterArray,
                           const char* aPathPrefix,
-                          bool aAnonymize,
-                          layers::SharedSurfacesMemoryReport& aSharedSurfaces)
+                          bool aAnonymize = false)
   {
     MemoryTotal summaryTotal;
     MemoryTotal nonNotableTotal;
 
     // Report notable images, and compute total and non-notable aggregate sizes.
     for (uint32_t i = 0; i < aCounterArray.Length(); i++) {
       ImageMemoryCounter& counter = aCounterArray[i];
 
@@ -265,39 +225,36 @@ private:
           counter.URI().Truncate(max);
           counter.URI().AppendLiteral(" (truncated)");
         }
         counter.URI().ReplaceChar('/', '\\');
       }
 
       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;
       }
     }
 
     // Report non-notable images in aggregate.
     ReportTotal(aHandleReport, aData, /* aExplicit = */ true,
                 aPathPrefix, "<non-notable images>/", nonNotableTotal);
 
     // Report a summary in aggregate, outside of the explicit tree.
     ReportTotal(aHandleReport, aData, /* aExplicit = */ false,
                 aPathPrefix, "", summaryTotal);
   }
 
   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);
     pathPrefix.Append(aCounter.Type() == imgIContainer::TYPE_RASTER
                         ? "/raster/"
                         : "/vector/");
     pathPrefix.Append(aCounter.IsUsed() ? "used/" : "unused/");
     pathPrefix.AppendLiteral("image(");
@@ -309,26 +266,25 @@ private:
     if (aCounter.URI().IsEmpty()) {
       pathPrefix.AppendLiteral("<unknown URI>");
     } else {
       pathPrefix.Append(aCounter.URI());
     }
 
     pathPrefix.AppendLiteral(")/");
 
-    ReportSurfaces(aHandleReport, aData, pathPrefix, aCounter, aSharedSurfaces);
+    ReportSurfaces(aHandleReport, aData, pathPrefix, aCounter);
 
     ReportSourceValue(aHandleReport, aData, pathPrefix, aCounter.Values());
   }
 
   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);
       if (counter.IsLocked()) {
         surfacePathPrefix.AppendLiteral("locked/");
       } else {
         surfacePathPrefix.AppendLiteral("unlocked/");
       }
@@ -339,33 +295,25 @@ private:
         surfacePathPrefix.AppendLiteral("cannot_substitute/");
       }
       surfacePathPrefix.AppendLiteral("surface(");
       surfacePathPrefix.AppendInt(counter.Key().Size().width);
       surfacePathPrefix.AppendLiteral("x");
       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:");
           surfacePathPrefix.AppendInt(uint32_t(counter.Key().Flags()),
                                       /* aRadix = */ 16);
         }
 
         if (counter.Key().SVGContext()) {
@@ -1406,17 +1354,17 @@ imgLoader::GetCacheQueue(const ImageCach
 
 void imgLoader::GlobalInit()
 {
   sCacheTimeWeight = gfxPrefs::ImageCacheTimeWeight() / 1000.0;
   int32_t cachesize = gfxPrefs::ImageCacheSize();
   sCacheMaxSize = cachesize > 0 ? cachesize : 0;
 
   sMemReporter = new imgMemoryReporter();
-  RegisterStrongAsyncMemoryReporter(sMemReporter);
+  RegisterStrongMemoryReporter(sMemReporter);
   RegisterImagesContentUsedUncompressedDistinguishedAmount(
     imgMemoryReporter::ImagesContentUsedUncompressedDistinguishedAmount);
 
   Telemetry::ScalarSet(Telemetry::ScalarID::IMAGES_WEBP_PROBE_OBSERVED, false);
   Telemetry::ScalarSet(Telemetry::ScalarID::IMAGES_WEBP_CONTENT_OBSERVED, false);
 }
 
 void imgLoader::ShutdownMemoryReporter()
--- a/image/imgRequest.cpp
+++ b/image/imgRequest.cpp
@@ -35,17 +35,16 @@
 #include "plstr.h" // PL_strcasestr(...)
 #include "prtime.h" // for PR_Now
 #include "nsNetUtil.h"
 #include "nsIProtocolHandler.h"
 #include "imgIRequest.h"
 #include "nsProperties.h"
 
 #include "mozilla/IntegerPrintfMacros.h"
-#include "mozilla/SizeOfState.h"
 #include "mozilla/Telemetry.h"
 
 using namespace mozilla;
 using namespace mozilla::image;
 
 #define LOG_TEST(level) (MOZ_LOG_TEST(gImgLog, (level)))
 
 NS_IMPL_ISUPPORTS(imgRequest,
--- a/image/moz.build
+++ b/image/moz.build
@@ -48,36 +48,31 @@ EXPORTS += [
     'imgLoader.h',
     'imgRequest.h',
     'imgRequestProxy.h',
     'IProgressObserver.h',
     'Orientation.h',
     'SurfaceCacheUtils.h',
 ]
 
-EXPORTS.mozilla.image += [
-    'ImageMemoryReporter.h',
-]
-
 UNIFIED_SOURCES += [
     'AnimationFrameBuffer.cpp',
     'AnimationSurfaceProvider.cpp',
     'ClippedImage.cpp',
     'DecodedSurfaceProvider.cpp',
     'DecodePool.cpp',
     'Decoder.cpp',
     'DecoderFactory.cpp',
     'DynamicImage.cpp',
     'FrameAnimator.cpp',
     'FrozenImage.cpp',
     'IDecodingTask.cpp',
     'Image.cpp',
     'ImageCacheKey.cpp',
     'ImageFactory.cpp',
-    'ImageMemoryReporter.cpp',
     'ImageOps.cpp',
     'ImageWrapper.cpp',
     'imgFrame.cpp',
     'imgLoader.cpp',
     'imgRequest.cpp',
     'imgRequestProxy.cpp',
     'imgTools.cpp',
     'MultipartImage.cpp',
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -4670,19 +4670,16 @@ pref("image.mem.animated.discardable", t
 // Whether the heap should be used for frames from animated images. On Android,
 // volatile memory keeps file handles open for each buffer.
 #if defined(ANDROID)
 pref("image.mem.animated.use_heap", true);
 #else
 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);
 
 // Allows image locking of decoded image data in content processes.
 pref("image.mem.allow_locking_in_content_processes", true);
 
 // Chunk size for calls to the image decoders