Commit 43b50d71 authored by Brett Kilty's avatar Brett Kilty Committed by Commit Bot

Fix SIGKILL on start if GPU disabled

https://chromium-review.googlesource.com/c/chromium/src/+/1949007
introduced a 100% crash on Android with GPU
disabled. No fallback_modes_ are pushed and
new code was added to SIGKILL the process in
this case.

Bug: b/147243153 (internal)
Test: Local before/after device test
Change-Id: I0788d9562378b5b729a40f4e71db9c3993c6885c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2018245Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Reviewed-by: default avatarSean Gilhuly <sgilhuly@chromium.org>
Commit-Queue: Brett Kilty <brettk@google.com>
Auto-Submit: Brett Kilty <brettk@google.com>
Cr-Commit-Position: refs/heads/master@{#735535}
parent eb5f91b6
......@@ -34,6 +34,7 @@
#include "base/trace_event/trace_event.h"
#include "base/version.h"
#include "build/build_config.h"
#include "build/chromecast_buildflags.h"
#include "cc/base/switches.h"
#include "components/viz/common/features.h"
#include "content/browser/gpu/gpu_memory_buffer_manager_singleton.h"
......@@ -508,7 +509,14 @@ void GpuDataManagerImplPrivate::InitializeGpuModes() {
#endif // !OS_ANDROID && !OS_CHROMEOS
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (!command_line->HasSwitch(switches::kDisableGpu)) {
if (command_line->HasSwitch(switches::kDisableGpu)) {
#if BUILDFLAG(IS_CHROMECAST)
fallback_modes_.clear();
fallback_modes_.push_back(gpu::GpuMode::DISABLED);
#elif defined(OS_ANDROID) || defined(OS_CHROMEOS)
CHECK(false) << "GPU acceleration is required on certain platforms!";
#endif // IS_CHROMECAST
} else {
// On Fuchsia Vulkan must be used when it's enabled by the WebEngine
// embedder. Falling back to SW compositing in that case is not supported.
#if defined(OS_FUCHSIA)
......@@ -586,6 +594,13 @@ bool GpuDataManagerImplPrivate::GpuProcessStartAllowed() const {
// TODO(kylechar/zmo): Remove special case for Windows here.
return GpuAccessAllowed(nullptr);
#else
#if BUILDFLAG(IS_CHROMECAST)
// Chromecast with GPU disabled should not try to run in the GPU process.
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kDisableGpu)) {
return false;
}
#endif // IS_CHROMECAST
// For all other platforms we either always run the display compositor in the
// GPU process (Linux, Mac and Fuchsia) or GPU access is never disabled
// (Android and Chrome OS).
......
......@@ -11,6 +11,7 @@
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "build/chromecast_buildflags.h"
#include "content/browser/gpu/gpu_data_manager_impl_private.h"
#include "content/browser/gpu/gpu_data_manager_testing_autogen.h"
#include "content/browser/gpu/gpu_data_manager_testing_entry_enums_autogen.h"
......@@ -294,7 +295,12 @@ TEST_F(GpuDataManagerImplPrivateTest, FallbackWithSwiftShaderDisabled) {
TEST_F(GpuDataManagerImplPrivateTest, GpuStartsWithGpuDisabled) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(switches::kDisableGpu);
ScopedGpuDataManagerImplPrivate manager;
#if BUILDFLAG(IS_CHROMECAST)
// GPU should not start if disabled.
EXPECT_EQ(gpu::GpuMode::DISABLED, manager->GetGpuMode());
#else
EXPECT_EQ(gpu::GpuMode::SWIFTSHADER, manager->GetGpuMode());
#endif // IS_CHROMECAST
}
#endif // !OS_ANDROID && !OS_CHROMEOS
......
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