Commit e7eca0a6 authored by kylechar's avatar kylechar Committed by Commit Bot

Add memory dump support to VizProcessContextProvider.

VizProcessContextProvider is missing memory reporting logic found in
ContextProviderCommandBuffer. Make VizProcessContextFactory a
MemoryDumpProvider so display compositor gpu memory is reported again.

This is expected to have an impact on the gpu and skia memory tracing
categories. This isn't a regression itself, it's just fixing memory
reporting that was broken when VizDisplayCompositor experiment was
enabled by fieldtrial test config.

Bug: 876508
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: Ia885fccd122dbfc8909f62e0a970c10ab3499632
Reviewed-on: https://chromium-review.googlesource.com/1209985Reviewed-by: default avatarJonathan Backer <backer@chromium.org>
Commit-Queue: kylechar <kylechar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592417}
parent f14a9324
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "base/sys_info.h" #include "base/sys_info.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/memory_dump_manager.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/viz/common/gpu/context_lost_observer.h" #include "components/viz/common/gpu/context_lost_observer.h"
#include "components/viz/common/gpu/context_lost_reason.h" #include "components/viz/common/gpu/context_lost_reason.h"
...@@ -103,12 +104,20 @@ VizProcessContextProvider::VizProcessContextProvider( ...@@ -103,12 +104,20 @@ VizProcessContextProvider::VizProcessContextProvider(
// there will be a circular reference preventing destruction. // there will be a circular reference preventing destruction.
gles2_implementation_->SetLostContextCallback(base::BindOnce( gles2_implementation_->SetLostContextCallback(base::BindOnce(
&VizProcessContextProvider::OnContextLost, base::Unretained(this))); &VizProcessContextProvider::OnContextLost, base::Unretained(this)));
base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
this, "VizProcessContextProvider", base::ThreadTaskRunnerHandle::Get());
} else { } else {
UmaRecordContextLost(CONTEXT_INIT_FAILED); UmaRecordContextLost(CONTEXT_INIT_FAILED);
} }
} }
VizProcessContextProvider::~VizProcessContextProvider() = default; VizProcessContextProvider::~VizProcessContextProvider() {
if (context_result_ == gpu::ContextResult::kSuccess) {
base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider(
this);
}
}
void VizProcessContextProvider::AddRef() const { void VizProcessContextProvider::AddRef() const {
base::RefCountedThreadSafe<VizProcessContextProvider>::AddRef(); base::RefCountedThreadSafe<VizProcessContextProvider>::AddRef();
...@@ -239,4 +248,20 @@ void VizProcessContextProvider::OnContextLost() { ...@@ -239,4 +248,20 @@ void VizProcessContextProvider::OnContextLost() {
GetContextLostReason(state.error, state.context_lost_reason)); GetContextLostReason(state.error, state.context_lost_reason));
} }
bool VizProcessContextProvider::OnMemoryDump(
const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) {
DCHECK_EQ(context_result_, gpu::ContextResult::kSuccess);
gles2_implementation_->OnMemoryDump(args, pmd);
gles2_helper_->OnMemoryDump(args, pmd);
if (gr_context_) {
gpu::raster::DumpGrMemoryStatistics(
gr_context_->get(), pmd,
gles2_implementation_->ShareGroupTracingGUID());
}
return true;
}
} // namespace viz } // namespace viz
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <memory> #include <memory>
#include "base/observer_list.h" #include "base/observer_list.h"
#include "base/trace_event/memory_dump_provider.h"
#include "components/viz/common/gpu/context_cache_controller.h" #include "components/viz/common/gpu/context_cache_controller.h"
#include "components/viz/common/gpu/context_provider.h" #include "components/viz/common/gpu/context_provider.h"
#include "components/viz/service/viz_service_export.h" #include "components/viz/service/viz_service_export.h"
...@@ -42,7 +43,8 @@ class ContextLostObserver; ...@@ -42,7 +43,8 @@ class ContextLostObserver;
// for the display compositor. // for the display compositor.
class VIZ_SERVICE_EXPORT VizProcessContextProvider class VIZ_SERVICE_EXPORT VizProcessContextProvider
: public base::RefCountedThreadSafe<VizProcessContextProvider>, : public base::RefCountedThreadSafe<VizProcessContextProvider>,
public ContextProvider { public ContextProvider,
public base::trace_event::MemoryDumpProvider {
public: public:
VizProcessContextProvider( VizProcessContextProvider(
scoped_refptr<gpu::CommandBufferTaskExecutor> task_executor, scoped_refptr<gpu::CommandBufferTaskExecutor> task_executor,
...@@ -84,6 +86,10 @@ class VIZ_SERVICE_EXPORT VizProcessContextProvider ...@@ -84,6 +86,10 @@ class VIZ_SERVICE_EXPORT VizProcessContextProvider
const gpu::SharedMemoryLimits& mem_limits); const gpu::SharedMemoryLimits& mem_limits);
void OnContextLost(); void OnContextLost();
// base::trace_event::MemoryDumpProvider implementation.
bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) override;
const gpu::ContextCreationAttribs attributes_; const gpu::ContextCreationAttribs attributes_;
std::unique_ptr<gpu::InProcessCommandBuffer> command_buffer_; std::unique_ptr<gpu::InProcessCommandBuffer> command_buffer_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment