Skip to content
Browse files

Android: concurrency issue with egl_surface EGL_BAD_SURFACE - (bug 4142)

Occurs when application goes to background:
- Java activity is destroying SurfaceView holder and "egl_surface" (in onNativeSurfaceDestroyed())
- While native thread is in Android_GLES_SwapWindow(), prepared to call SDL_EGL_SwapBuffers()

The error is "call to eglSwapBuffers failed, reporting an error of EGL_BAD_SURFACE"

It an be reproduced easily by adding a SDL_Delay(100) at the begining of SDL_EGL_SwapBuffers(),
and putting the application into background.
  • Loading branch information
1bsyl committed Jan 3, 2019
1 parent 2e19343 commit ca184ac386d05852e8ebec09d98f3d1f80ba05da
Showing with 10 additions and 2 deletions.
  1. +10 −2 src/video/android/SDL_androidgl.c
@@ -42,14 +42,22 @@ SDL_EGL_MakeCurrent_impl(Android)
Android_GLES_SwapWindow(_THIS, SDL_Window * window)
int retval;


/* The following two calls existed in the original Java code
* If you happen to have a device that's affected by their removal,
* please report to Bugzilla. -- Gabriel

return SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);
retval = SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);


return retval;


0 comments on commit ca184ac

Please sign in to comment.