From 759299794cf4b9ba4b783cf1c5d996dc3d7f215b Mon Sep 17 00:00:00 2001 From: sievers Date: Fri, 5 Jun 2015 10:08:13 -0700 Subject: [PATCH] Android: Enable 'crash GPU process on context lost' WAR for Mali-400 BUG=496438 NOTRY=True Review URL: https://codereview.chromium.org/1149233004 Cr-Commit-Position: refs/heads/master@{#333076} --- content/common/gpu/gpu_command_buffer_stub.cc | 8 ++++++++ gpu/command_buffer/service/gles2_cmd_decoder.cc | 19 +++++++++++++------ gpu/command_buffer/service/gles2_cmd_decoder.h | 4 ++++ gpu/command_buffer/service/gles2_cmd_decoder_mock.h | 1 + gpu/config/gpu_driver_bug_list_json.cc | 15 ++++++++++++++- 5 files changed, 40 insertions(+), 7 deletions(-) diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc index 729f66d7da4f..bd57c41f19d2 100644 --- a/content/common/gpu/gpu_command_buffer_stub.cc +++ b/content/common/gpu/gpu_command_buffer_stub.cc @@ -22,6 +22,7 @@ #include "content/common/gpu/media/gpu_video_decode_accelerator.h" #include "content/common/gpu/media/gpu_video_encode_accelerator.h" #include "content/public/common/content_client.h" +#include "content/public/common/content_switches.h" #include "gpu/command_buffer/common/constants.h" #include "gpu/command_buffer/common/gles2_cmd_utils.h" #include "gpu/command_buffer/common/mailbox.h" @@ -472,6 +473,13 @@ void GpuCommandBufferStub::OnInitialize( decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group_.get())); + if (!base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kSingleProcess) && + !base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kInProcessGPU)) { + decoder_->SetAllowExit(true); + } + scheduler_.reset(new gpu::GpuScheduler(command_buffer_.get(), decoder_.get(), decoder_.get())); diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index 717c635c9b2e..a14f72e11199 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -685,6 +685,7 @@ class GLES2DecoderImpl : public GLES2Decoder, void SetAsyncPixelTransferManagerForTest( AsyncPixelTransferManager* manager) override; void SetIgnoreCachedStateForTest(bool ignore) override; + void SetAllowExit(bool allow_exit) override; void ProcessFinishedAsyncTransfers(); bool GetServiceTextureId(uint32 client_texture_id, @@ -1997,6 +1998,8 @@ class GLES2DecoderImpl : public GLES2Decoder, GLuint validation_fbo_multisample_; GLuint validation_fbo_; + bool allow_exit_; + typedef gpu::gles2::GLES2Decoder::Error (GLES2DecoderImpl::*CmdHandler)( uint32 immediate_data_size, const void* data); @@ -2509,7 +2512,8 @@ GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group) gpu_debug_commands_(false), validation_texture_(0), validation_fbo_multisample_(0), - validation_fbo_(0) { + validation_fbo_(0), + allow_exit_(false) { DCHECK(group); // The shader translator is used for WebGL even when running on EGL @@ -4494,6 +4498,10 @@ void GLES2DecoderImpl::SetIgnoreCachedStateForTest(bool ignore) { state_.SetIgnoreCachedStateForTest(ignore); } +void GLES2DecoderImpl::SetAllowExit(bool allow_exit) { + allow_exit_ = allow_exit; +} + void GLES2DecoderImpl::OnFboChanged() const { if (workarounds().restore_scissor_on_fbo_change) state_.fbo_binding_for_scissor_workaround_dirty = true; @@ -11326,11 +11334,10 @@ void GLES2DecoderImpl::MarkContextLost(error::ContextLostReason reason) { current_decoder_error_ = error::kLostContext; context_was_lost_ = true; - // Some D3D drivers cannot recover from device lost in the GPU process - // sandbox. Allow a new GPU process to launch. - if (workarounds().exit_on_context_lost) { - LOG(ERROR) << "Exiting GPU process because some drivers cannot reset" - << " a D3D device in the Chrome GPU process sandbox."; + // Work around issues with recovery by allowing a new GPU process to launch. + if (workarounds().exit_on_context_lost && allow_exit_) { + LOG(ERROR) << "Exiting GPU process because some drivers cannot recover" + << " from problems."; #if defined(OS_WIN) base::win::SetShouldCrashOnProcessDetach(false); #endif diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.h b/gpu/command_buffer/service/gles2_cmd_decoder.h index ac01c95804cc..3fc862379787 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder.h @@ -171,6 +171,10 @@ class GPU_EXPORT GLES2Decoder : public base::SupportsWeakPtr, virtual void SetIgnoreCachedStateForTest(bool ignore) = 0; + // Allow the decoder to exit the current process. + // Defaults to |false|. + virtual void SetAllowExit(bool allow_exit) = 0; + // Gets the QueryManager for this context. virtual QueryManager* GetQueryManager() = 0; diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_mock.h b/gpu/command_buffer/service/gles2_cmd_decoder_mock.h index 65df53c53dfd..1e5357dae483 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_mock.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_mock.h @@ -89,6 +89,7 @@ class MockGLES2Decoder : public GLES2Decoder { MOCK_METHOD1(SetAsyncPixelTransferManagerForTest, void(AsyncPixelTransferManager*)); MOCK_METHOD1(SetIgnoreCachedStateForTest, void(bool ignore)); + MOCK_METHOD1(SetAllowExit, void(bool allow)); MOCK_METHOD3(DoCommand, error::Error(unsigned int command, unsigned int arg_count, const void* cmd_data)); diff --git a/gpu/config/gpu_driver_bug_list_json.cc b/gpu/config/gpu_driver_bug_list_json.cc index 3373968bc64d..191cca97f7ab 100644 --- a/gpu/config/gpu_driver_bug_list_json.cc +++ b/gpu/config/gpu_driver_bug_list_json.cc @@ -19,7 +19,7 @@ const char kGpuDriverBugListJson[] = LONG_STRING_CONST( { "name": "gpu driver bug list", // Please update the version number whenever you change this file. - "version": "8.09", + "version": "8.10", "entries": [ { "id": 1, @@ -1411,6 +1411,19 @@ LONG_STRING_CONST( "features": [ "remove_pow_with_constant_exponent" ] + }, + { + "id": 119, + "description": "Context lost recovery often fails on Mali-400 on Android.", + "cr_bugs": [496438], + "os": { + "type": "android" + }, + "gl_vendor": "ARM.*", + "gl_renderer": ".*Mali-400.*", + "features": [ + "exit_on_context_lost" + ] } ] } -- 2.11.4.GIT