[Mesa-dev] [PATCH] platform_android: prevent deadlock in droid_swap_buffers

Haixia Shi hshi at chromium.org
Wed May 25 23:02:45 UTC 2016


To avoid blocking other EGL calls, release the display mutex before
we enqueue buffer to android frameworks and re-acquire the mutex
upon return.

TEST=verify pinch zoom in Photos app no longer causes hangs

Signed-off-by: Haixia Shi <hshi at chromium.org>
---
 src/egl/drivers/dri2/platform_android.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index 25d02f5..f3e5d38 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -434,8 +434,15 @@ droid_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
 
    dri2_flush_drawable_for_swapbuffers(disp, draw);
 
-   if (dri2_surf->buffer)
+   if (dri2_surf->buffer) {
+      /* To avoid blocking other EGL calls, release the display mutex before
+       * we enter droid_window_enqueue_buffer() and re-acquire the mutex upon
+       * return.
+       */
+      mtx_unlock(&disp->Mutex);
       droid_window_enqueue_buffer(dri2_surf);
+      mtx_lock(&disp->Mutex);
+   }
 
    (*dri2_dpy->flush->invalidate)(dri2_surf->dri_drawable);
 
-- 
2.8.0.rc3.226.g39d4020



More information about the mesa-dev mailing list