libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
8.8k stars 1.66k forks source link

Android: allow to re-do the sequence SDL_init / SDL_quit #7591

Open 1bsyl opened 1 year ago

1bsyl commented 1 year ago

It should be possible to re-do

SDL_init 
...
SDL_quit
SDL_init
...
SDL_quit
19:12:39.485  E  [SurfaceView[org.libsdl.app/org.libsdl.app.SDLActivity]#1(BLAST Consumer)1](id:4a6c00000001,api:1,p:19052,c:19052) connect: already connected (cur=1 req=1)
19:12:39.486  E  eglCreateWindowSurface: native_window_api_connect (win=0x704449f810) failed (0xffffffea) (already connected to another API?)
19:12:39.486  E  eglCreateWindowSurfaceTmpl:676 error 3003 (EGL_BAD_ALLOC)
19:12:39.486  I  pixel format wanted SDL_PIXELFORMAT_RGBA8888 (1), got SDL_PIXELFORMAT_RGBA8888 (1)
19:12:39.529  D  Compat change id reported: 171228096; UID 10437; state: ENABLED
19:12:39.605  V  onWindowFocusChanged(): false

Currently it fails to re-initiale GLES2, because 19:12:39.486 E eglCreateWindowSurface: native_window_api_connect (win=0x704449f810) failed (0xffffffea) (already connected to another API?)

surfaceView hasn't been destroyed, and is somehow still connected.

workaround is to minimize the window:

(see #7585 https://github.com/libsdl-org/SDL/issues/7567 )

1bsyl commented 1 year ago

Commenting out:

src/video/android/SDL_androidvideo.c:
//     device->GL_UnloadLibrary = Android_GLES_UnloadLibrary;

seems to allow do multiple Init/Quit/Init...