From 7e300dbc58ae5c6766eab6a7d29b54f8c908ed4d Mon Sep 17 00:00:00 2001 From: Scott Moreau Date: Fri, 31 Aug 2012 03:18:15 -0600 Subject: [PATCH] simple-egl: Avoid race condition. After explaining the problem on irc, Pekka dictated this solution which works. The problem is that simple-egl can hang when toggling fullscreen because of a race where (quoting Pekka) "if it dispatches the frame callback simple-egl itself requested before the Mesa's own frame callback came, simple-egl will go to its redraw routing and call eglSwapBuffers so you end up effectively calling eglSwapBuffers from within eglSwapBuffers, and deadlock". This patch avoids redrawing (which calls eglSwapBuffers) when there is a pending frame callback. --- clients/simple-egl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/clients/simple-egl.c b/clients/simple-egl.c index a3315712..808c2eea 100644 --- a/clients/simple-egl.c +++ b/clients/simple-egl.c @@ -262,7 +262,9 @@ configure_callback(void *data, struct wl_callback *callback, uint32_t time) wl_callback_destroy(callback); window->configured = 1; - redraw(data, NULL, time); + + if (window->callback == NULL) + redraw(data, NULL, time); } static struct wl_callback_listener configure_callback_listener = { @@ -363,6 +365,9 @@ redraw(void *data, struct wl_callback *callback, uint32_t time) static uint32_t start_time = 0; struct wl_region *region; + assert(window->callback == callback); + window->callback = NULL; + if (callback) wl_callback_destroy(callback);