Android black screen on resume (again)

When i press the home button during the game, then return to the app the screen is going black. Game is still running with sounds menu interaction etc.
I tried recreating all textures, didn’t work.
I am getting these errors:

2021-05-10 15:58:07.043 27151-27240/com.blueskied.summerbound E/libEGL: eglMakeCurrentImpl:1100 error 3002 (EGL_BAD_ACCESS)
2021-05-10 15:58:07.043 27151-27240/com.blueskied.summerbound E/EGL_emulation: eglMakeCurrent: error: EGL_BAD_ACCESS: context 0xf5d69de0 current to another thread!
2021-05-10 15:58:07.043 27151-27240/com.blueskied.summerbound E/EGL_emulation: tid 27240: eglMakeCurrent(1816): error 0x3002 (EGL_BAD_ACCESS)

1 Like

I had this problem earlier and it was caused by setting a flag before I created the OpenGL context. Are you using the SDL renderer? I enabled an SRGB flag on OpenGL and that broke the context when I navigated back to the application.

After I identified the flag that was causing the problem (and stopped enabling it), I had to set up a process to completely recreate everything in OpenGL every time the player navigates back to the application–shaders, textures, and models. Are you doing that already? I don’t have much experience with the SDL renderer but perhaps this can help you find whatever’s causing your problem. I assume you’re checking for those six required events. Are you positive that you’re not touching anything related to OpenGL after you receive those events?

1 Like

Thanks for your reply.
I don’t do anything with the context programmatically. Doesn’t the SDL library handle it?
Error occurs when i press the Overview button (app gets deactivated), then quickly tap on the app again.
What six required events?

Error log:
V/SDL: onWindowFocusChanged(): true
V/SDL: nativeResume()
E/EGL_emulation: eglMakeCurrent: error: EGL_BAD_ACCESS: context 0xf466f250 current to another thread!
E/EGL_emulation: tid 27092: eglMakeCurrent(1816): error 0x3002 (EGL_BAD_ACCESS)
E/libEGL: eglMakeCurrentImpl:1100 error 3002 (EGL_BAD_ACCESS)
E/libEGL: call to OpenGL ES API with no current context (logged once per thread)
E/EGL_emulation: eglMakeCurrent: error: EGL_BAD_ACCESS: context 0xf466f250 current to another thread!
E/EGL_emulation: tid 27092: eglMakeCurrent(1816): error 0x3002 (EGL_BAD_ACCESS)
E/libEGL: eglMakeCurrentImpl:1100 error 3002 (EGL_BAD_ACCESS)

V/SDL: onWindowFocusChanged(): true
V/SDL: nativeResume()
E/EGL_emulation: eglMakeCurrent: error: EGL_BAD_ACCESS: context 0xf466f250 current to another thread!
E/EGL_emulation: tid 27092: eglMakeCurrent(1816): error 0x3002 (EGL_BAD_ACCESS)
E/libEGL: eglMakeCurrentImpl:1100 error 3002 (EGL_BAD_ACCESS)
E/libEGL: call to OpenGL ES API with no current context (logged once per thread)
E/EGL_emulation: eglMakeCurrent: error: EGL_BAD_ACCESS: context 0xf466f250 current to another thread!
E/EGL_emulation: tid 27092: eglMakeCurrent(1816): error 0x3002 (EGL_BAD_ACCESS)
E/libEGL: eglMakeCurrentImpl:1100 error 3002 (EGL_BAD_ACCESS)

The EGL_BAD_ACCESS error means the OpenGL context isn’t restoring when your application opens; either because it didn’t save it correctly or because it didn’t restore it correctly.

These are the events you need to handle: SDL_EventType - SDL Wiki

As soon as you receive SDL_APP_WILLENTERBACKGROUND, you have to stop touching OpenGL, and you can only resume your rendering operations after you have received SDL_APP_DIDENTEROROEGROUND. Doing anything with OpenGL between these two messages will result in the (unrecoverable) EGL_BAD_ACCESS error.

As a note: even though I’m talking specifically about OpenGL and you mentioned that you aren’t using it directly, SDL is still using it, so you have to ensure you aren’t rendering or calling any OpenGL functions between receiving those two events.

1 Like

Thanks a lot! I didn’t know about these events.