From 1de1e80d5077157fc25503c4699969c57929795d Mon Sep 17 00:00:00 2001 From: Simeon Bird Date: Fri, 20 Mar 2015 20:18:46 -0400 Subject: [PATCH] Fix hang on nvidia hardware when deleting sync objects When a sync object is deleted, the fence it is connected to must already be signalled, or the driver will busy-wait forever. Signal fences before deleting syncs to avoid this. BUG: 343551 FIXED-IN: 5.3 REVIEW: 123090 --- scene_opengl.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scene_opengl.cpp b/scene_opengl.cpp index 30b113dfd0..1793004c7a 100644 --- a/scene_opengl.cpp +++ b/scene_opengl.cpp @@ -123,6 +123,17 @@ SyncObject::SyncObject() SyncObject::~SyncObject() { + // If glDeleteSync is called before the xcb fence is signalled + // the nvidia driver (the only one to implement GL_SYNC_X11_FENCE_EXT) + // deadlocks waiting for the fence to be signalled. + // To avoid this, make sure the fence is signalled before + // deleting the sync. + if (m_state == Resetting || m_state == Ready){ + trigger(); + // The flush is necessary! + // The trigger command needs to be sent to the X server. + xcb_flush(connection()); + } xcb_sync_destroy_fence(connection(), m_fence); glDeleteSync(m_sync);