зеркало из https://github.com/mozilla/gecko-dev.git
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)
This commit is contained in:
Родитель
cb18b15c36
Коммит
3a8485e6e6
|
@ -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
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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<GfxPrefSetting>&& 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();
|
||||
|
||||
|
|
|
@ -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<wr::ExternalImageId> extId = SharedSurfacesChild::GetExternalId(this);
|
||||
if (extId) {
|
||||
aExtIdOut = wr::AsUint64(extId.ref());
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t*
|
||||
|
|
|
@ -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<SharedMemoryBasic> 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
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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<SharedUserData*>(aSurface->GetUserData(&sSharedKey));
|
||||
if (!data) {
|
||||
|
@ -456,20 +455,5 @@ SharedSurfacesChild::Unshare(const wr::ExternalImageId& 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
|
||||
|
|
|
@ -10,10 +10,8 @@
|
|||
#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 {
|
||||
|
@ -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<wr::ExternalImageId>
|
||||
GetExternalId(const gfx::SourceSurfaceSharedData* aSurface);
|
||||
|
||||
private:
|
||||
SharedSurfacesChild() = delete;
|
||||
~SharedSurfacesChild() = delete;
|
||||
|
@ -92,8 +83,6 @@ private:
|
|||
|
||||
static void Unshare(const wr::ExternalImageId& aId, nsTArray<ImageKeyData>& aKeys);
|
||||
static void DestroySharedUserData(void* aClosure);
|
||||
|
||||
static gfx::UserDataKey sSharedKey;
|
||||
};
|
||||
|
||||
} // namespace layers
|
||||
|
|
|
@ -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
|
|
@ -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<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
|
||||
|
|
|
@ -29,7 +29,6 @@ class SourceSurfaceSharedDataWrapper;
|
|||
namespace layers {
|
||||
|
||||
class SharedSurfacesChild;
|
||||
class SharedSurfacesMemoryReport;
|
||||
|
||||
class SharedSurfacesParent final
|
||||
{
|
||||
|
@ -45,8 +44,7 @@ public:
|
|||
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,
|
||||
|
@ -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:
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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() { }
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -188,6 +188,11 @@ public:
|
|||
|
||||
void Add(NotNull<CachedSurface*> 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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -206,22 +206,9 @@ public:
|
|||
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
|
||||
|
||||
|
|
|
@ -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<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;
|
||||
|
@ -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<nsIMemoryReporterManager> 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<ImageMemoryCounter>& 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);
|
||||
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
#include "nsProperties.h"
|
||||
|
||||
#include "mozilla/IntegerPrintfMacros.h"
|
||||
#include "mozilla/SizeOfState.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче