Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(798)

Unified Diff: content/browser/renderer_host/compositor_impl_android.cc

Issue 2250473005: content: Fix Context creation logic in ContextProviderFactoryImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use mock factory Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/compositor_impl_android.cc
diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc
index 64ed74c16081a91a691be298cd48ce05a3e575d1..d46781e6ee75a509189ffe7f8deb8b9d131440d8 100644
--- a/content/browser/renderer_host/compositor_impl_android.cc
+++ b/content/browser/renderer_host/compositor_impl_android.cc
@@ -394,6 +394,7 @@ CompositorImpl::CompositorImpl(CompositorClient* client,
root_window_(root_window),
needs_animate_(false),
pending_swapbuffers_(0U),
+ num_successive_gpu_process_initialization_failures_(0),
num_successive_context_creation_failures_(0),
output_surface_request_pending_(false),
needs_begin_frames_(false),
@@ -649,26 +650,50 @@ void CompositorImpl::CreateVulkanOutputSurface() {
#endif
void CompositorImpl::CreateCompositorOutputSurface(
- const scoped_refptr<cc::ContextProvider>& context_provider) {
- // This callback should run only if we have a pending output surface request,
- // since that is when we should have queued a context request.
- // In case the surface was invalidated after the context request was queued,
- // the request should have been dropped by the ContextProviderFactory.
+ const scoped_refptr<cc::ContextProvider>& context_provider,
+ ui::ContextProviderFactory::ContextCreationResult result) {
DCHECK(output_surface_request_pending_);
- DCHECK(host_->visible());
- DCHECK(window_);
- DCHECK_NE(surface_handle_, gpu::kNullSurfaceHandle);
- DCHECK(context_provider);
-
- scoped_refptr<ContextProviderCommandBuffer> context_provider_command_buffer =
- static_cast<ContextProviderCommandBuffer*>(context_provider.get());
- std::unique_ptr<cc::OutputSurface> display_output_surface(
- new OutputSurfaceWithoutParent(
- context_provider_command_buffer,
- base::Bind(&CompositorImpl::PopulateGpuCapabilities,
- base::Unretained(this))));
- InitializeDisplay(std::move(display_output_surface), nullptr,
- std::move(context_provider));
+
+ switch (result) {
+ // Don't retry if we are shutting down or if the Gpu Surface handle was
+ // lost. The Gpu Surface handle loss should happen only if we are invisible
+ // or this was from a previous request and the current surface has changed,
+ // in which case we would have made another request with the factory.
+ case ui::ContextProviderFactory::ContextCreationResult::
+ FAILURE_FACTORY_SHUTDOWN:
+ case ui::ContextProviderFactory::ContextCreationResult::
+ FAILURE_GPU_SURFACE_HANDLE_LOST:
+ break;
+ case ui::ContextProviderFactory::ContextCreationResult::
+ FAILURE_GPU_PROCESS_INITIALIZATION_FAILED:
+ // Retry only if we are visible.
+ if (host_->visible()) {
+ LOG_IF(FATAL,
+ ++num_successive_gpu_process_initialization_failures_ >= 2)
+ << "Too many GPU Process initialization failures. Giving up... ";
+ HandlePendingOutputSurfaceRequest();
+ }
+ break;
+ case ui::ContextProviderFactory::ContextCreationResult::SUCCESS:
+ DCHECK(host_->visible());
+ DCHECK(window_);
+ DCHECK_NE(surface_handle_, gpu::kNullSurfaceHandle);
+ DCHECK(context_provider);
+
+ num_successive_gpu_process_initialization_failures_ = 0;
+ scoped_refptr<ContextProviderCommandBuffer>
+ context_provider_command_buffer =
+ static_cast<ContextProviderCommandBuffer*>(
+ context_provider.get());
+ std::unique_ptr<cc::OutputSurface> display_output_surface(
+ new OutputSurfaceWithoutParent(
+ context_provider_command_buffer,
+ base::Bind(&CompositorImpl::PopulateGpuCapabilities,
+ base::Unretained(this))));
+ InitializeDisplay(std::move(display_output_surface), nullptr,
+ std::move(context_provider));
+ break;
+ }
}
void CompositorImpl::InitializeDisplay(

Powered by Google App Engine
This is Rietveld 408576698