On Thu, May 4, 2017 at 7:47 AM, Chad Versace <chadvers...@chromium.org> wrote:
> From: Chad Versace <c...@kiwitree.net>
>
> That is, call ANativeWindow::cancelBuffer in droid_destroy_surface().
>
> This should prevent application deadlock when the app destroys the
> EGLSurface after EGL has acquired a buffer from SurfaceFlinger
> (ANativeWindow::dequeueBuffer) but before EGL has released it
> (ANativeWindow::enqueueBuffer).
>
> This patch is part of a series for fixing
> android.hardware.camera2.cts.RobustnessTest#testAbandonRepeatingRequestSurface
> on Chrome OS x86 devices.
>
> Cc: Tomasz Figa <tf...@chromium.org>
> Cc: Nicolas Boichat <drink...@chromium.org>
> Cc: Tapani Pälli <tapani.pa...@intel.com>
> ---
>  src/egl/drivers/dri2/platform_android.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/src/egl/drivers/dri2/platform_android.c 
> b/src/egl/drivers/dri2/platform_android.c
> index 35f2e5dbe6..f45fcdf4ff 100644
> --- a/src/egl/drivers/dri2/platform_android.c
> +++ b/src/egl/drivers/dri2/platform_android.c
> @@ -264,10 +264,15 @@ droid_window_enqueue_buffer(_EGLDisplay *disp, struct 
> dri2_egl_surface *dri2_sur
>  }
>
>  static void
> -droid_window_cancel_buffer(_EGLDisplay *disp, struct dri2_egl_surface 
> *dri2_surf)
> +droid_window_cancel_buffer(struct dri2_egl_surface *dri2_surf)
>  {
> -   /* no cancel buffer? */
> -   droid_window_enqueue_buffer(disp, dri2_surf);
> +   int ret;
> +
> +   ret = dri2_surf->window->cancelBuffer(dri2_surf->window, 
> dri2_surf->buffer, -1);
> +   if (ret < 0) {
> +      _eglLog(_EGL_WARNING, "ANativeWindow::cancelBuffer failed");
> +      dri2_surf->base.Lost = true;

Lost is an EGLBoolean, so this should be EGL_TRUE (caused problems for
me while backporting to an older branch that does not include
stdbool.h in this file).

Next patch has a similar minor problem, I'll upload a fix.

> +   }
>  }
>
>  static __DRIbuffer *
> @@ -399,7 +404,7 @@ droid_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, 
> _EGLSurface *surf)
>
>     if (dri2_surf->base.Type == EGL_WINDOW_BIT) {
>        if (dri2_surf->buffer)
> -         droid_window_cancel_buffer(disp, dri2_surf);
> +         droid_window_cancel_buffer(dri2_surf);
>
>        dri2_surf->window->common.decRef(&dri2_surf->window->common);
>     }
> --
> 2.12.0
>
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to