diff --git a/gfx/ipc/GPUParent.cpp b/gfx/ipc/GPUParent.cpp index caffad8e9b45..e4b3bfc57ca1 100644 --- a/gfx/ipc/GPUParent.cpp +++ b/gfx/ipc/GPUParent.cpp @@ -13,6 +13,7 @@ #include "gfxPrefs.h" #include "GLContextProvider.h" #include "GPUProcessHost.h" +#include "GPUProcessManager.h" #include "mozilla/Assertions.h" #include "mozilla/Telemetry.h" #include "mozilla/TimeStamp.h" @@ -460,13 +461,30 @@ GPUParent::RecvNotifyGpuObservers(const nsCString& aTopic) return IPC_OK(); } +/* static */ void +GPUParent::GetGPUProcessName(nsACString& aStr) +{ + auto processType = XRE_GetProcessType(); + unsigned pid = 0; + if (processType == GeckoProcessType_GPU) { + pid = getpid(); + } else { + MOZ_DIAGNOSTIC_ASSERT(processType == GeckoProcessType_Default); + pid = GPUProcessManager::Get()->GPUProcessPid(); + } + + nsPrintfCString processName("GPU (pid %u)", pid); + aStr.Assign(processName); +} + mozilla::ipc::IPCResult GPUParent::RecvRequestMemoryReport(const uint32_t& aGeneration, const bool& aAnonymize, const bool& aMinimizeMemoryUsage, const MaybeFileDesc& aDMDFile) { - nsPrintfCString processName("GPU (pid %u)", (unsigned)getpid()); + nsAutoCString processName; + GetGPUProcessName(processName); mozilla::dom::MemoryReportRequestClient::Start( aGeneration, aAnonymize, aMinimizeMemoryUsage, aDMDFile, processName); diff --git a/gfx/ipc/GPUParent.h b/gfx/ipc/GPUParent.h index f0e864497111..6e05a5db9dbc 100644 --- a/gfx/ipc/GPUParent.h +++ b/gfx/ipc/GPUParent.h @@ -26,6 +26,11 @@ public: static GPUParent* GetSingleton(); + // Gets the name of the GPU process, in the format expected by about:memory. + // There must be a GPU process active, and the caller must be either in that + // process or the parent process. + static void GetGPUProcessName(nsACString& aStr); + bool Init(base::ProcessId aParentPid, const char* aParentBuildID, MessageLoop* aIOLoop, diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 3ab4e46899b4..9f2d9fce65f7 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -663,8 +663,18 @@ struct WebRenderMemoryReporterHelper { void Report(size_t aBytes, const char* aName) const { + // Generally, memory reporters pass the empty string as the process name to + // indicate "current process". However, if we're using a GPU process, the + // measurements will actually take place in that process, and it's easier to + // just note that here rather than trying to invoke the memory reporter in + // the GPU process. + nsAutoCString processName; + if (gfxConfig::IsEnabled(Feature::GPU_PROCESS)) { + GPUParent::GetGPUProcessName(processName); + } + nsPrintfCString path("explicit/gfx/webrender/%s", aName); - mCallback->Callback(EmptyCString(), path, + mCallback->Callback(processName, path, nsIMemoryReporter::KIND_HEAP, nsIMemoryReporter::UNITS_BYTES, aBytes, EmptyCString(), mData); }