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.
This commit is contained in:
Sylvain Becker 2019-01-03 23:22:50 +01:00
parent 2e19343df6
commit ca184ac386
1 changed files with 10 additions and 2 deletions

View File

@ -42,6 +42,10 @@ SDL_EGL_MakeCurrent_impl(Android)
int int
Android_GLES_SwapWindow(_THIS, SDL_Window * window) Android_GLES_SwapWindow(_THIS, SDL_Window * window)
{ {
int retval;
SDL_LockMutex(Android_ActivityMutex);
/* The following two calls existed in the original Java code /* The following two calls existed in the original Java code
* If you happen to have a device that's affected by their removal, * If you happen to have a device that's affected by their removal,
* please report to Bugzilla. -- Gabriel * please report to Bugzilla. -- Gabriel
@ -49,7 +53,11 @@ Android_GLES_SwapWindow(_THIS, SDL_Window * window)
/*_this->egl_data->eglWaitNative(EGL_CORE_NATIVE_ENGINE); /*_this->egl_data->eglWaitNative(EGL_CORE_NATIVE_ENGINE);
_this->egl_data->eglWaitGL();*/ _this->egl_data->eglWaitGL();*/
return SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface); retval = SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);
SDL_UnlockMutex(Android_ActivityMutex);
return retval;
} }
int int