From 577cd47e54bb88c81b7a5b5a6d658d8d61b2c747 Mon Sep 17 00:00:00 2001 From: Andras Becsi <andras.becsi@digia.com> Date: Thu, 6 Nov 2014 12:38:31 +0100 Subject: [PATCH] <chromium> FIXUP Convert sync points to GL fence syncs. GpuCommandBufferStub::OnRetireSyncPoint is also called as a result of shutdown destruction where there is a race condition between the ramp-down of the GLContext and the DestroyGLFence() and GLFence::CreateWithoutFlush() calls. This would result in sporadic shutdown crashes or asserts when a page is closed while browsing WebGL content like fishgl.com. Avoid the additional calls if there is no current context. Task-number: QTBUG-42295 Change-Id: I5aed0df7adca9c95eda71925399d39fd770fffa1 Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com> --- .../common/gpu/gpu_command_buffer_stub.cc | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/chromium/content/common/gpu/gpu_command_buffer_stub.cc b/chromium/content/common/gpu/gpu_command_buffer_stub.cc index 84d611a8ce2..61c96156383 100644 --- a/chromium/content/common/gpu/gpu_command_buffer_stub.cc +++ b/chromium/content/common/gpu/gpu_command_buffer_stub.cc @@ -852,19 +852,22 @@ void GpuCommandBufferStub::OnRetireSyncPoint(uint32 sync_point) { GpuChannelManager* manager = channel_->gpu_channel_manager(); #if defined(TOOLKIT_QT) - // Only keep the last fence alive to keep its temporary ownership in GpuCommandBufferStub - // simple in case where Qt would not pick this fence to eventually destroy it. - DestroyGLFence(manager->sync_point_gl_fences_, last_fence_sync_point_); - // We submitted all resource-producing GL commands, convert the logical sync point into a GL fence - // to allow Qt's GL context to wait for the results of commands submitted in this context using the - // sync point as reference. - scoped_ptr<gfx::GLFence> fence = scoped_ptr<gfx::GLFence>(gfx::GLFence::CreateWithoutFlush()); - if (fence) - manager->sync_point_gl_fences_.insert(std::make_pair(sync_point, fence.release())); - // Flush regardless of the success of the fence creation to at least make sure that commands - // producing our textures are in the pipe before the scene graph inserts its own on the other thread. - glFlush(); - last_fence_sync_point_ = sync_point; + bool has_current_context = !!gfx::GLContext::GetCurrent(); + if (has_current_context) { + // Only keep the last fence alive to keep its temporary ownership in GpuCommandBufferStub + // simple in case where Qt would not pick this fence to eventually destroy it. + DestroyGLFence(manager->sync_point_gl_fences_, last_fence_sync_point_); + // We submitted all resource-producing GL commands, convert the logical sync point into a GL fence + // to allow Qt's GL context to wait for the results of commands submitted in this context using the + // sync point as reference. + scoped_ptr<gfx::GLFence> fence = scoped_ptr<gfx::GLFence>(gfx::GLFence::CreateWithoutFlush()); + if (fence) + manager->sync_point_gl_fences_.insert(std::make_pair(sync_point, fence.release())); + // Flush regardless of the success of the fence creation to at least make sure that commands + // producing our textures are in the pipe before the scene graph inserts its own on the other thread. + glFlush(); + last_fence_sync_point_ = sync_point; + } #endif manager->sync_point_manager()->RetireSyncPoint(sync_point); -- GitLab