Skip to content

Commit

Permalink
Add kDisableLayerTreeHostMemoryPressure switch to LayerTreeHostImpl
Browse files Browse the repository at this point in the history
Chromecast is seeing issues when the active layer releases its
resources, disabling the memory pressure listener fixes it.

It is possible that because chromecast devices set critical memory
pressure to very low amounts (<30MB) coupled with the gpu driver not
being able to actually free memory until existing rendering commands
have completed, the memory pressure handler freeing things that then
get reallocated right away for the next frame can actually increase
memory pressure, triggering an actual OOM condition on device

Bug: b/118774931
Test: None
Change-Id: Iff393de370b7250ebe5c4ec21a1f225e3887c0f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2140608
Commit-Queue: Albert Chaulk <achaulk@chromium.org>
Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758985}
  • Loading branch information
Albert Chaulk authored and Commit Bot committed Apr 14, 2020
1 parent 8e9c833 commit f471504
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions cc/base/switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ const char kCheckDamageEarly[] = "check-damage-early";
// Enables the GPU benchmarking extension
const char kEnableGpuBenchmarking[] = "enable-gpu-benchmarking";

// Disables LayerTreeHost::OnMemoryPressure
const char kDisableLayerTreeHostMemoryPressure[] =
"disable-layer-tree-host-memory-pressure";

// Renders a border around compositor layers to help debug and study
// layer compositing.
const char kShowCompositedLayerBorders[] = "show-composited-layer-borders";
Expand Down
3 changes: 3 additions & 0 deletions cc/base/switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ CC_BASE_EXPORT extern const char kCheckDamageEarly[];
// Switches for both the renderer and ui compositors.
CC_BASE_EXPORT extern const char kEnableGpuBenchmarking[];

// Switches for LayerTreeHost.
CC_BASE_EXPORT extern const char kDisableLayerTreeHostMemoryPressure[];

// Debug visualizations.
CC_BASE_EXPORT extern const char kShowCompositedLayerBorders[];
CC_BASE_EXPORT extern const char kUIShowCompositedLayerBorders[];
Expand Down
11 changes: 8 additions & 3 deletions cc/trees/layer_tree_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "base/auto_reset.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/containers/adapters.h"
#include "base/containers/flat_map.h"
Expand All @@ -31,6 +32,7 @@
#include "cc/base/devtools_instrumentation.h"
#include "cc/base/histograms.h"
#include "cc/base/math_util.h"
#include "cc/base/switches.h"
#include "cc/benchmarks/benchmark_instrumentation.h"
#include "cc/debug/rendering_stats_instrumentation.h"
#include "cc/input/browser_controls_offset_manager.h"
Expand Down Expand Up @@ -370,9 +372,12 @@ LayerTreeHostImpl::LayerTreeHostImpl(
this, settings.top_controls_show_threshold,
settings.top_controls_hide_threshold);

memory_pressure_listener_.reset(
new base::MemoryPressureListener(base::BindRepeating(
&LayerTreeHostImpl::OnMemoryPressure, base::Unretained(this))));
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableLayerTreeHostMemoryPressure)) {
memory_pressure_listener_.reset(
new base::MemoryPressureListener(base::BindRepeating(
&LayerTreeHostImpl::OnMemoryPressure, base::Unretained(this))));
}

SetDebugState(settings.initial_debug_state);
}
Expand Down

0 comments on commit f471504

Please sign in to comment.