Commit d4194195 authored by Bo Liu's avatar Bo Liu Committed by Commit Bot

gpu: Move crash count reset to GpuProcessHost

Relying on browser compositor for the reset is problematic because
reset stops if app is in the background, which also happen to be the
time the GPU is most likely to be killed by Android.

Move the reset signal to any context creation success directly from
the GPU process. ContextProviderCommandBuffer::BindToCurrentThread
does more things like registering transfer buffers. But hopefully
those don't cause GPU crashes.

Bug: 777601
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I360c29c97c7a3222a84cb797c8be2f3fb65200db
Reviewed-on: https://chromium-review.googlesource.com/786271Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarFady Samuel <fsamuel@chromium.org>
Commit-Queue: Bo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#519869}
parent a6cf4e30
...@@ -480,6 +480,11 @@ void GpuServiceImpl::UpdateGpuInfoPlatform( ...@@ -480,6 +480,11 @@ void GpuServiceImpl::UpdateGpuInfoPlatform(
} }
#endif #endif
void GpuServiceImpl::DidCreateContextSuccessfully() {
DCHECK(main_runner_->BelongsToCurrentThread());
(*gpu_host_)->DidCreateContextSuccessfully();
}
void GpuServiceImpl::DidCreateOffscreenContext(const GURL& active_url) { void GpuServiceImpl::DidCreateOffscreenContext(const GURL& active_url) {
DCHECK(main_runner_->BelongsToCurrentThread()); DCHECK(main_runner_->BelongsToCurrentThread());
(*gpu_host_)->DidCreateOffscreenContext(active_url); (*gpu_host_)->DidCreateOffscreenContext(active_url);
......
...@@ -117,6 +117,7 @@ class VIZ_SERVICE_EXPORT GpuServiceImpl : public gpu::GpuChannelManagerDelegate, ...@@ -117,6 +117,7 @@ class VIZ_SERVICE_EXPORT GpuServiceImpl : public gpu::GpuChannelManagerDelegate,
void UpdateGpuInfoPlatform(base::OnceClosure on_gpu_info_updated); void UpdateGpuInfoPlatform(base::OnceClosure on_gpu_info_updated);
// gpu::GpuChannelManagerDelegate: // gpu::GpuChannelManagerDelegate:
void DidCreateContextSuccessfully() override;
void DidCreateOffscreenContext(const GURL& active_url) override; void DidCreateOffscreenContext(const GURL& active_url) override;
void DidDestroyChannel(int client_id) override; void DidDestroyChannel(int client_id) override;
void DidDestroyOffscreenContext(const GURL& active_url) override; void DidDestroyOffscreenContext(const GURL& active_url) override;
......
...@@ -773,10 +773,6 @@ void GpuProcessHost::SendDestroyingVideoSurface(int surface_id, ...@@ -773,10 +773,6 @@ void GpuProcessHost::SendDestroyingVideoSurface(int surface_id,
surface_id, base::Bind(&GpuProcessHost::OnDestroyingVideoSurfaceAck, surface_id, base::Bind(&GpuProcessHost::OnDestroyingVideoSurfaceAck,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
} }
void GpuProcessHost::DidSuccessfullyInitializeContext() {
gpu_recent_crash_count_ = 0;
}
#endif #endif
void GpuProcessHost::OnChannelEstablished( void GpuProcessHost::OnChannelEstablished(
...@@ -887,6 +883,15 @@ void GpuProcessHost::DidFailInitialize() { ...@@ -887,6 +883,15 @@ void GpuProcessHost::DidFailInitialize() {
RunRequestGPUInfoCallbacks(gpu_data_manager->GetGPUInfo()); RunRequestGPUInfoCallbacks(gpu_data_manager->GetGPUInfo());
} }
void GpuProcessHost::DidCreateContextSuccessfully() {
#if defined(OS_ANDROID)
// Android may kill the GPU process to free memory, especially when the app
// is the background, so Android cannot have a hard limit on GPU starts.
// Reset crash count on Android when context creation succeeds.
gpu_recent_crash_count_ = 0;
#endif
}
void GpuProcessHost::DidCreateOffscreenContext(const GURL& url) { void GpuProcessHost::DidCreateOffscreenContext(const GURL& url) {
urls_with_live_offscreen_contexts_.insert(url); urls_with_live_offscreen_contexts_.insert(url);
} }
......
...@@ -157,12 +157,6 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate, ...@@ -157,12 +157,6 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate,
// Tells the GPU process that the given surface is being destroyed so that it // Tells the GPU process that the given surface is being destroyed so that it
// can stop using it. // can stop using it.
void SendDestroyingVideoSurface(int surface_id, const base::Closure& done_cb); void SendDestroyingVideoSurface(int surface_id, const base::Closure& done_cb);
// Android-only notification when a context is initialized. Because the gpu
// process can be killed arbitrarily on this OS, the host needs to always
// restart it. This signal is used to differentiate a repeatedly failing gpu
// process from one that was functional but killed.
void DidSuccessfullyInitializeContext();
#endif #endif
// What kind of GPU process, e.g. sandboxed or unsandboxed. // What kind of GPU process, e.g. sandboxed or unsandboxed.
...@@ -202,6 +196,7 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate, ...@@ -202,6 +196,7 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate,
void DidInitialize(const gpu::GPUInfo& gpu_info, void DidInitialize(const gpu::GPUInfo& gpu_info,
const gpu::GpuFeatureInfo& gpu_feature_info) override; const gpu::GpuFeatureInfo& gpu_feature_info) override;
void DidFailInitialize() override; void DidFailInitialize() override;
void DidCreateContextSuccessfully() override;
void DidCreateOffscreenContext(const GURL& url) override; void DidCreateOffscreenContext(const GURL& url) override;
void DidDestroyOffscreenContext(const GURL& url) override; void DidDestroyOffscreenContext(const GURL& url) override;
void DidDestroyChannel(int32_t client_id) override; void DidDestroyChannel(int32_t client_id) override;
......
...@@ -54,7 +54,6 @@ ...@@ -54,7 +54,6 @@
#include "content/browser/browser_main_loop.h" #include "content/browser/browser_main_loop.h"
#include "content/browser/compositor/surface_utils.h" #include "content/browser/compositor/surface_utils.h"
#include "content/browser/gpu/compositor_util.h" #include "content/browser/gpu/compositor_util.h"
#include "content/browser/gpu/gpu_process_host.h"
#include "content/browser/renderer_host/render_widget_host_impl.h" #include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/common/gpu_stream_constants.h" #include "content/common/gpu_stream_constants.h"
#include "content/public/browser/android/compositor.h" #include "content/public/browser/android/compositor.h"
...@@ -689,8 +688,6 @@ void CompositorImpl::DidInitializeLayerTreeFrameSink() { ...@@ -689,8 +688,6 @@ void CompositorImpl::DidInitializeLayerTreeFrameSink() {
AddChildFrameSink(frame_sink_id); AddChildFrameSink(frame_sink_id);
pending_child_frame_sink_ids_.clear(); pending_child_frame_sink_ids_.clear();
DidSuccessfullyInitializeContext();
} }
void CompositorImpl::DidFailToInitializeLayerTreeFrameSink() { void CompositorImpl::DidFailToInitializeLayerTreeFrameSink() {
...@@ -791,8 +788,6 @@ void CompositorImpl::OnGpuChannelEstablished( ...@@ -791,8 +788,6 @@ void CompositorImpl::OnGpuChannelEstablished(
return; return;
} }
DidSuccessfullyInitializeContext();
// Unretained is safe this owns viz::Display which owns OutputSurface. // Unretained is safe this owns viz::Display which owns OutputSurface.
auto display_output_surface = std::make_unique<AndroidOutputSurface>( auto display_output_surface = std::make_unique<AndroidOutputSurface>(
context_provider, context_provider,
...@@ -863,16 +858,6 @@ void CompositorImpl::DidSwapBuffers() { ...@@ -863,16 +858,6 @@ void CompositorImpl::DidSwapBuffers() {
client_->DidSwapBuffers(); client_->DidSwapBuffers();
} }
void CompositorImpl::DidSuccessfullyInitializeContext() {
auto on_io_thread = [] {
GpuProcessHost* host = GpuProcessHost::Get();
if (host)
host->DidSuccessfullyInitializeContext();
};
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)
->PostTask(FROM_HERE, base::BindOnce(on_io_thread));
}
cc::UIResourceId CompositorImpl::CreateUIResource( cc::UIResourceId CompositorImpl::CreateUIResource(
cc::UIResourceClient* client) { cc::UIResourceClient* client) {
TRACE_EVENT0("compositor", "CompositorImpl::CreateUIResource"); TRACE_EVENT0("compositor", "CompositorImpl::CreateUIResource");
......
...@@ -148,8 +148,6 @@ class CONTENT_EXPORT CompositorImpl ...@@ -148,8 +148,6 @@ class CONTENT_EXPORT CompositorImpl
scoped_refptr<viz::VulkanContextProvider> vulkan_context_provider, scoped_refptr<viz::VulkanContextProvider> vulkan_context_provider,
scoped_refptr<viz::ContextProvider> context_provider); scoped_refptr<viz::ContextProvider> context_provider);
void DidSwapBuffers(); void DidSwapBuffers();
// Reports back when the gpu process is functioning. See crbug.com/772049.
void DidSuccessfullyInitializeContext();
bool HavePendingReadbacks(); bool HavePendingReadbacks();
......
...@@ -14,6 +14,9 @@ namespace gpu { ...@@ -14,6 +14,9 @@ namespace gpu {
class GpuChannelManagerDelegate { class GpuChannelManagerDelegate {
public: public:
// Called on any successful context creation.
virtual void DidCreateContextSuccessfully() = 0;
// Tells the delegate that an offscreen context was created for the provided // Tells the delegate that an offscreen context was created for the provided
// |active_url|. // |active_url|.
virtual void DidCreateOffscreenContext(const GURL& active_url) = 0; virtual void DidCreateOffscreenContext(const GURL& active_url) = 0;
......
...@@ -28,6 +28,7 @@ class TestGpuChannelManagerDelegate : public GpuChannelManagerDelegate { ...@@ -28,6 +28,7 @@ class TestGpuChannelManagerDelegate : public GpuChannelManagerDelegate {
// GpuChannelManagerDelegate implementation: // GpuChannelManagerDelegate implementation:
void SetActiveURL(const GURL& url) override {} void SetActiveURL(const GURL& url) override {}
void DidCreateContextSuccessfully() override {}
void DidCreateOffscreenContext(const GURL& active_url) override {} void DidCreateOffscreenContext(const GURL& active_url) override {}
void DidDestroyChannel(int client_id) override {} void DidDestroyChannel(int client_id) override {}
void DidDestroyOffscreenContext(const GURL& active_url) override {} void DidDestroyOffscreenContext(const GURL& active_url) override {}
......
...@@ -841,6 +841,7 @@ gpu::ContextResult GpuCommandBufferStub::Initialize( ...@@ -841,6 +841,7 @@ gpu::ContextResult GpuCommandBufferStub::Initialize(
} }
} }
manager->delegate()->DidCreateContextSuccessfully();
initialized_ = true; initialized_ = true;
return gpu::ContextResult::kSuccess; return gpu::ContextResult::kSuccess;
#endif // defined(OS_FUCHSIA) #endif // defined(OS_FUCHSIA)
......
...@@ -152,6 +152,8 @@ void DefaultGpuHost::DidInitialize( ...@@ -152,6 +152,8 @@ void DefaultGpuHost::DidInitialize(
void DefaultGpuHost::DidFailInitialize() {} void DefaultGpuHost::DidFailInitialize() {}
void DefaultGpuHost::DidCreateContextSuccessfully() {}
void DefaultGpuHost::DidCreateOffscreenContext(const GURL& url) {} void DefaultGpuHost::DidCreateOffscreenContext(const GURL& url) {}
void DefaultGpuHost::DidDestroyOffscreenContext(const GURL& url) {} void DefaultGpuHost::DidDestroyOffscreenContext(const GURL& url) {}
......
...@@ -93,6 +93,7 @@ class DefaultGpuHost : public GpuHost, public viz::mojom::GpuHost { ...@@ -93,6 +93,7 @@ class DefaultGpuHost : public GpuHost, public viz::mojom::GpuHost {
void DidInitialize(const gpu::GPUInfo& gpu_info, void DidInitialize(const gpu::GPUInfo& gpu_info,
const gpu::GpuFeatureInfo& gpu_feature_info) override; const gpu::GpuFeatureInfo& gpu_feature_info) override;
void DidFailInitialize() override; void DidFailInitialize() override;
void DidCreateContextSuccessfully() override;
void DidCreateOffscreenContext(const GURL& url) override; void DidCreateOffscreenContext(const GURL& url) override;
void DidDestroyOffscreenContext(const GURL& url) override; void DidDestroyOffscreenContext(const GURL& url) override;
void DidDestroyChannel(int32_t client_id) override; void DidDestroyChannel(int32_t client_id) override;
......
...@@ -17,6 +17,7 @@ interface GpuHost { ...@@ -17,6 +17,7 @@ interface GpuHost {
gpu.mojom.GpuFeatureInfo gpu_feature_info); gpu.mojom.GpuFeatureInfo gpu_feature_info);
DidFailInitialize(); DidFailInitialize();
DidCreateContextSuccessfully();
DidCreateOffscreenContext(url.mojom.Url url); DidCreateOffscreenContext(url.mojom.Url url);
DidDestroyOffscreenContext(url.mojom.Url url); DidDestroyOffscreenContext(url.mojom.Url url);
......
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