SDL window after pause/resume on Android

Hi,

Have some issues with pause/resume on Android (tested on
Emulator API level 16, 4.1.2 and two real devices also with
Android 4.xxx).

The application creates a window, surface, texture and
renderer. The surface->pixels is used as drawing buffer then
I call
SDL_UpdateTexture(texture, NULL, surface->pixels, surface->pitch);
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer);
to update the window.

This works fine as long as application is in focus, but on
pause/resume if I don’t handle
SDL_APP_[DID/WILL]ENTER[FORE/BACK]GROUND events the screen
after resume is black, even if I try to update the window.
The app is still running and I can see in the logs that
events are handled.

I tried to recreate window when application enters the
foreground again (destroy all old objects and create new
ones) but then I get a crash:

backtrace:
#00 pc 000730e6 libSDL2.so (SDL_EGL_CreateSurface+9)
#01 pc 0007cc07 libSDL2.so (Android_CreateWindow+154)
#02 pc 0007c3f1 libSDL2.so (SDL_CreateWindow+396)
#03 pc 0001fbe5 libmain.so (init(unsigned int, unsigned int, unsigned int)+164)

bellow some traces before the crash:

I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp( 688): SDL_APP_WILLENTERBACKGROUND
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp( 688): SDL_APP_DIDENTERBACKGROUND
V/SDL ( 688): onWindowFocusChanged(): false
W/EGL_emulation( 254): eglSurfaceAttrib not implemented
V/SDL ( 688): surfaceDestroyed()
W/EGL_emulation( 206): eglSurfaceAttrib not implemented
V/SDL ( 688): onResume()
V/SDL ( 688): surfaceCreated()
V/SDL ( 688): surfaceChanged()
V/SDL ( 688): pixel format RGB_565
V/SDL ( 688): Window size:800x1216
D/ ( 149): HostConnection::get() New Host Connection established 0x2a3b8e00, tid 160
V/SDL ( 688): onWindowFocusChanged(): true
V/SDL ( 688): nativeResume()
E/EGL_emulation( 688): tid 702: eglMakeCurrent(947): error 0x3002 (EGL_BAD_ACCESS)
E/libEGL ( 688): eglMakeCurrent:534 error 3002 (EGL_BAD_ACCESS)
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp( 688): SDL_APP_WILLENTERFOREGROUND
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp( 688): SDL_APP_DIDENTERFOREGROUND
E/EGL_emulation( 688): tid 702: eglMakeCurrent(947): error 0x3002 (EGL_BAD_ACCESS)
E/libEGL ( 688): eglMakeCurrent:534 error 3002 (EGL_BAD_ACCESS)
E/libEGL ( 688): call to OpenGL ES API with no current context (logged once per thread)
E/EGL_emulation( 688): tid 702: eglMakeCurrent(947): error 0x3002 (EGL_BAD_ACCESS)
E/libEGL ( 688): eglMakeCurrent:534 error 3002 (EGL_BAD_ACCESS)
W/libEGL ( 688): eglTerminate() called w/ 3 objects remaining

//this will recreate the window.
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp( 688): platform_support::init 800,1216,161
F/libc ( 688): Fatal signal 11 (SIGSEGV) at 0x00000008
(code=1), thread 702 (SDLThread)
I/DEBUG ( 33): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG ( 33): Build fingerprint: 'generic/sdk/generic:4.1.2/MASTER/495790:eng/test-keys’
I/DEBUG ( 33): pid: 688, tid: 702, name: UNKNOWN >>> com.traffar.game_of_life <<<
I/DEBUG ( 33): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000008

Could You give me some hints how this could be solved?
Thanks!
Przemek

Can you post a log from an actual device? I usually don’t bother much with
emulator crashes (specially related to EGL/OpenGL ES) because the
implementation leaves a lot to desire and stuff that works just fine on
actual devices crashes the simulator for obscure reasons.

Also, if you can, post a test case to reproduce (or better yet, open an
issue in Bugzilla and attach it there).

Finally, generally speaking you don’t need to recreate the window

2013/12/27 Przemyslaw Rzepecki > Hi,

Have some issues with pause/resume on Android (tested on
Emulator API level 16, 4.1.2 and two real devices also with
Android 4.xxx).

The application creates a window, surface, texture and
renderer. The surface->pixels is used as drawing buffer then
I call
SDL_UpdateTexture(texture, NULL, surface->pixels, surface->pitch);
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer);
to update the window.

This works fine as long as application is in focus, but on
pause/resume if I don’t handle
SDL_APP_[DID/WILL]ENTER[FORE/BACK]GROUND events the screen
after resume is black, even if I try to update the window.
The app is still running and I can see in the logs that
events are handled.

I tried to recreate window when application enters the
foreground again (destroy all old objects and create new
ones) but then I get a crash:

backtrace:
#00 pc 000730e6 libSDL2.so (SDL_EGL_CreateSurface+9)
#01 pc 0007cc07 libSDL2.so (Android_CreateWindow+154)
#02 pc 0007c3f1 libSDL2.so (SDL_CreateWindow+396)
#03 pc 0001fbe5 libmain.so (init(unsigned int, unsigned int, unsigned
int)+164)

bellow some traces before the crash:

I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp( 688):
SDL_APP_WILLENTERBACKGROUND
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp( 688):
SDL_APP_DIDENTERBACKGROUND
V/SDL ( 688): onWindowFocusChanged(): false
W/EGL_emulation( 254): eglSurfaceAttrib not implemented
V/SDL ( 688): surfaceDestroyed()
W/EGL_emulation( 206): eglSurfaceAttrib not implemented
V/SDL ( 688): onResume()
V/SDL ( 688): surfaceCreated()
V/SDL ( 688): surfaceChanged()
V/SDL ( 688): pixel format RGB_565
V/SDL ( 688): Window size:800x1216
D/ ( 149): HostConnection::get() New Host Connection established
0x2a3b8e00, tid 160
V/SDL ( 688): onWindowFocusChanged(): true
V/SDL ( 688): nativeResume()
E/EGL_emulation( 688): tid 702: eglMakeCurrent(947): error 0x3002
(EGL_BAD_ACCESS)
E/libEGL ( 688): eglMakeCurrent:534 error 3002 (EGL_BAD_ACCESS)
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp( 688):
SDL_APP_WILLENTERFOREGROUND
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp( 688):
SDL_APP_DIDENTERFOREGROUND
E/EGL_emulation( 688): tid 702: eglMakeCurrent(947): error 0x3002
(EGL_BAD_ACCESS)
E/libEGL ( 688): eglMakeCurrent:534 error 3002 (EGL_BAD_ACCESS)
E/libEGL ( 688): call to OpenGL ES API with no current context (logged
once per thread)
E/EGL_emulation( 688): tid 702: eglMakeCurrent(947): error 0x3002
(EGL_BAD_ACCESS)
E/libEGL ( 688): eglMakeCurrent:534 error 3002 (EGL_BAD_ACCESS)
W/libEGL ( 688): eglTerminate() called w/ 3 objects remaining

//this will recreate the window.
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp( 688):
platform_support::init 800,1216,161
F/libc ( 688): Fatal signal 11 (SIGSEGV) at 0x00000008
(code=1), thread 702 (SDLThread)
I/DEBUG ( 33): *** *** *** *** *** *** *** *** *** *** *** *** *** ***


I/DEBUG ( 33): Build fingerprint:
'generic/sdk/generic:4.1.2/MASTER/495790:eng/test-keys’
I/DEBUG ( 33): pid: 688, tid: 702, name: UNKNOWN >>>
com.traffar.game_of_life <<<
I/DEBUG ( 33): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr
00000008

Could You give me some hints how this could be solved?
Thanks!
Przemek


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Gabriel.

Hi,

Thanks for the comments. At the moment I have no real device with me. I will
re-test and post the logs shortly after the new year. Seems on the emulator its
enough with:

SDL_Init(SDL_INIT_VIDEO);
SDL_Window*
mwindow = SDL_CreateWindow(“test”,
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
Android_ScreenWidth,
Android_ScreenHeight,
SDL_WINDOW_FULLSCREEN);
SDL_DestroyWindow(mwindow);
mwindow = SDL_CreateWindow(“test”,
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
Android_ScreenWidth,
Android_ScreenHeight,
SDL_WINDOW_FULLSCREEN);

to get the crash.

Regards,
Przemek

2013/12/27 Gabriel Jacobo >

Can you post a log from an actual device? I usually don’t bother much with
emulator crashes (specially related to EGL/OpenGL ES) because the
implementation leaves a lot to desire and stuff that works just fine on
actual devices crashes the simulator for obscure reasons.

Also, if you can, post a test case to reproduce (or better yet, open an
issue in Bugzilla and attach it there).

Finally, generally speaking you don’t need to recreate the window

Message-ID: <20131227152442.GA13514 at SDF-EU.ORG>
Content-Type: text/plain; charset=us-ascii

This works fine as long as application is in focus, but on
pause/resume if I don’t handle
SDL_APP_[DID/WILL]ENTER[FORE/BACK]GROUND events the screen
after resume is black, even if I try to update the window.
The app is still running and I can see in the logs that
events are handled.

Bear in mind, since I don’t currently work on a mobile platform I
don’t know if this is a bug, but is there any particular reason why
you don’t want to handle these events? I’d expect them to be rather
important for a properly behaving mobile application.> Date: Fri, 27 Dec 2013 15:24:42 +0000

From: Przemyslaw Rzepecki
To: sdl at lists.libsdl.org
Subject: [SDL] SDL window after pause/resume on Android

OK, thank You for that information. When I don’t recreate
the window (and use same, surface, renderer etc) there is no
crash but the screen is only black. I attach the logs from
Sony LT25i/Android 4.1.2 (there are two files, one where the
window is recreated and I get a crash, other with a black
screen).

Source code is available in a public repo:
https://bitbucket.org/przemekr/game_of_life_agg/src
https://bitbucket.org/przemekr/game_of_life_agg/src/master/agg-2.5/src/platform/sdl2/agg_platform_support.cpp
(I try to get AGG running on SDL2 and Android).

is there any particular reason why
you don’t want to handle these events?
Jared: I was not precise, sorry. I handle those event and
stop my app from doing any updates when in background. Only
after resume I get a black screen (window is not updated) so
I tried to add SDL_DestroyWindow, SDL_CreateWindow when I
foreground again, but then I got the crash.

Best regards,
Przemek
-------------- next part --------------
I/ActivityManager( 546): Start proc com.traffar.game_of_life for activity com.traffar.game_of_life/.game_of_lifeActivity: pid=14917 uid=10226 gids={1015, 1028}
D/dalvikvm(14917): Trying to load lib /data/data/com.traffar.game_of_life/lib/libSDL2.so 0x4286b2a8
D/dalvikvm(14917): Added shared lib /data/data/com.traffar.game_of_life/lib/libSDL2.so 0x4286b2a8
D/dalvikvm(14917): Trying to load lib /data/data/com.traffar.game_of_life/lib/libmain.so 0x4286b2a8
D/dalvikvm(14917): Added shared lib /data/data/com.traffar.game_of_life/lib/libmain.so 0x4286b2a8
D/dalvikvm(14917): No JNI_OnLoad found in /data/data/com.traffar.game_of_life/lib/libmain.so 0x4286b2a8, skipping init
V/SDL (14917): onResume()
V/SDL (14917): surfaceCreated()
V/SDL (14917): surfaceChanged()
V/SDL (14917): pixel format RGB_565
V/SDL (14917): Window size:720x1184
I/SDL (14917): SDL_Android_Init()
I/SDL (14917): SDL_Android_Init() finished!
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(14917): platform support, re-create window, renderer, surface on resume
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(14917): platform_support::init 720,1184,1
D/libEGL (14917): loaded /system/lib/egl/libEGL_adreno200.so
D/libEGL (14917): loaded /system/lib/egl/libGLESv1_CM_adreno200.so
D/libEGL (14917): loaded /system/lib/egl/libGLESv2_adreno200.so
V/SDL (14917): onWindowFocusChanged(): true
I/Adreno200-EGL(14917): <qeglDrvAPI_eglInitialize:269>: EGL 1.4 QUALCOMM build: (Merge)
I/Adreno200-EGL(14917): Build Date: 01/23/13 Wed
I/Adreno200-EGL(14917): Local Branch: BlueJBUpgrade
I/Adreno200-EGL(14917): Remote Branch:
I/Adreno200-EGL(14917): Local Patches:
I/Adreno200-EGL(14917): Reconstruct Branch:
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(14917): surface at 0x5c482420
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(14917): on draw done
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(14917): unknown win event type 10
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(14917): unknown win event type 6
V/SDL (14917): onPause()
E/libEGL (14917): call to OpenGL ES API with no current context (logged once per thread)
V/SDL (14917): nativePause()
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(14917): unknown win event type 6
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(14917): unknown win event type 13
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(14917): unknown win event type 7
V/SDL (14917): onWindowFocusChanged(): false
V/SDL (14917): surfaceDestroyed()
V/SDL (14917): onResume()
V/SDL (14917): surfaceCreated()
V/SDL (14917): surfaceChanged()
V/SDL (14917): pixel format RGB_565
V/SDL (14917): Window size:720x1184
V/SDL (14917): onWindowFocusChanged(): true
V/SDL (14917): nativeResume()
W/Adreno200-EGL(14917): <qeglDrvAPI_eglMakeCurrent:2789>: EGL_BAD_ACCESS
E/libEGL (14917): eglMakeCurrent:534 error 3002 (EGL_BAD_ACCESS)
W/Adreno200-EGL(14917): <qeglDrvAPI_eglMakeCurrent:2808>: EGL_BAD_ACCESS
E/libEGL (14917): eglMakeCurrent:534 error 3002 (EGL_BAD_ACCESS)
W/libEGL (14917): eglTerminate() called w/ 3 objects remaining
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(14917): SDL_APP_WILLENTERBACKGROUND
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(14917): SDL_APP_DIDENTERBACKGROUND
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(14917): SDL_APP_WILLENTERFOREGROUND
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(14917): SDL_APP_DIDENTERFOREGROUND
E/libEGL (14917): call to OpenGL ES API with no current context (logged once per thread)
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(14917): platform_support::init 720,1184,1
F/libc (14917): Fatal signal 11 (SIGSEGV) at 0x00000008 (code=1), thread 14936 (SDLThread)
I/DEBUG (22887): pid: 14917, tid: 14936, name: SDLThread >>> com.traffar.game_of_life <<<
-------------- next part --------------
I/ActivityManager( 546): Start proc com.traffar.game_of_life for activity com.traffar.game_of_life/.game_of_lifeActivity: pid=12735 uid=10226 gids={1015, 1028}
D/dalvikvm(12735): Trying to load lib /data/data/com.traffar.game_of_life/lib/libSDL2.so 0x428641d0
D/dalvikvm(12735): Added shared lib /data/data/com.traffar.game_of_life/lib/libSDL2.so 0x428641d0
D/dalvikvm(12735): Trying to load lib /data/data/com.traffar.game_of_life/lib/libmain.so 0x428641d0
D/dalvikvm(12735): Added shared lib /data/data/com.traffar.game_of_life/lib/libmain.so 0x428641d0
D/dalvikvm(12735): No JNI_OnLoad found in /data/data/com.traffar.game_of_life/lib/libmain.so 0x428641d0, skipping init
V/SDL (12735): onResume()
V/SDL (12735): surfaceCreated()
V/SDL (12735): surfaceChanged()
V/SDL (12735): pixel format RGB_565
V/SDL (12735): Window size:720x1184
I/SDL (12735): SDL_Android_Init()
I/SDL (12735): SDL_Android_Init() finished!
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(12735): platform support, not changeing window, renderer, surface on resume
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(12735): platform_support::init 720,1184,1
D/libEGL (12735): loaded /system/lib/egl/libEGL_adreno200.so
D/libEGL (12735): loaded /system/lib/egl/libGLESv1_CM_adreno200.so
D/libEGL (12735): loaded /system/lib/egl/libGLESv2_adreno200.so
V/SDL (12735): onWindowFocusChanged(): true
I/Adreno200-EGL(12735): <qeglDrvAPI_eglInitialize:269>: EGL 1.4 QUALCOMM build: (Merge)
I/Adreno200-EGL(12735): Build Date: 01/23/13 Wed
I/Adreno200-EGL(12735): Local Branch: BlueJBUpgrade
I/Adreno200-EGL(12735): Remote Branch:
I/Adreno200-EGL(12735): Local Patches:
I/Adreno200-EGL(12735): Reconstruct Branch:
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(12735): surface at 0x5d443c08
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(12735): on draw done
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(12735): unknown win event type 10
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(12735): unknown win event type 6
V/SDL (12735): onPause()
E/libEGL (12735): call to OpenGL ES API with no current context (logged once per thread)
V/SDL (12735): nativePause()
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(12735): unknown win event type 6
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(12735): unknown win event type 13
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(12735): unknown win event type 7
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(12735): SDL_APP_WILLENTERBACKGROUND
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(12735): SDL_APP_DIDENTERBACKGROUND
V/SDL (12735): onWindowFocusChanged(): false
V/SDL (12735): surfaceDestroyed()
V/SDL (12735): onResume()
V/SDL (12735): surfaceCreated()
V/SDL (12735): surfaceChanged()
V/SDL (12735): pixel format RGB_565
V/SDL (12735): Window size:720x1184
V/SDL (12735): onWindowFocusChanged(): true
V/SDL (12735): nativeResume()
W/Adreno200-EGL(12735): <qeglDrvAPI_eglMakeCurrent:2789>: EGL_BAD_ACCESS
E/libEGL (12735): eglMakeCurrent:534 error 3002 (EGL_BAD_ACCESS)
W/Adreno200-EGL(12735): <qeglDrvAPI_eglMakeCurrent:2808>: EGL_BAD_ACCESS
E/libEGL (12735): eglMakeCurrent:534 error 3002 (EGL_BAD_ACCESS)
W/libEGL (12735): eglTerminate() called w/ 3 objects remaining
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(12735): SDL_APP_WILLENTERFOREGROUND
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(12735): SDL_APP_DIDENTERFOREGROUND
E/libEGL (12735): call to OpenGL ES API with no current context (logged once per thread)
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(12735): on draw done
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(12735): unknown win event type 12
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(12735): unknown win event type 6
I/jni/src/agg-2.5/src/platform/sdl2/agg_platform_support.cpp(12735): unknown win event type 9

Hi,

Does anyone have any suggestion what might be wrong? Clearly
there is some issue with EGL context when the application
comes back from the background.

According to EGL refs EGL_BAD_ACCESS 0x3002:
EGL cannot access a requested resource (for example, a
context is bound in another thread).

Also when running on the emulator I notice error printed by
EGL (to stderr not to syslog):
GLESv2Imp.cpp:glUseProgram: error 0x501

That function is described as: glUseProgram ? install a
program object as part of current rendering state. And error
0x501: GL_INVALID_VALUE is generated if program is neither 0
nor a value generated by OpenGL.

This happens only when resuming from background, when
starting the application everything works fine. (see the
logs from previews mail).

Best regards,
PrzemekOn Fri, Jan 03, 2014 at 11:46:29AM +0000, Przemyslaw Rzepecki wrote:

OK, thank You for that information. When I don’t recreate
the window (and use same, surface, renderer etc) there is no
crash but the screen is only black. I attach the logs from
Sony LT25i/Android 4.1.2 (there are two files, one where the
window is recreated and I get a crash, other with a black
screen).

Source code is available in a public repo:
https://bitbucket.org/przemekr/game_of_life_agg/src
https://bitbucket.org/przemekr/game_of_life_agg/src/master/agg-2.5/src/platform/sdl2/agg_platform_support.cpp
(I try to get AGG running on SDL2 and Android).

is there any particular reason why
you don’t want to handle these events?
Jared: I was not precise, sorry. I handle those event and
stop my app from doing any updates when in background. Only
after resume I get a black screen (window is not updated) so
I tried to add SDL_DestroyWindow, SDL_CreateWindow when I
foreground again, but then I got the crash.

Best regards,
Przemek

Hello,

Just a few ideas :
1/ update to the latest version of SDL.

2/ You dont need to recreate the window/renderer when entering again in
foreground.

3/ Shouldn’t you use the Lock/Unlock functions when accessing the "pixels"
field ?

4/ As you said in you previous mail. As soon as you get the
WILL_ENTER_BACKGROUND event, you should stop calling any rendering function.
But are you actually checking the “events” fast enough in you application ?

Cheers,
SylvainOn Tue, Jan 7, 2014 at 5:24 PM, Przemyslaw Rzepecki wrote:

Hi,

Does anyone have any suggestion what might be wrong? Clearly
there is some issue with EGL context when the application
comes back from the background.

According to EGL refs EGL_BAD_ACCESS 0x3002:
EGL cannot access a requested resource (for example, a
context is bound in another thread).

Also when running on the emulator I notice error printed by
EGL (to stderr not to syslog):
GLESv2Imp.cpp:glUseProgram: error 0x501

That function is described as: glUseProgram ? install a
program object as part of current rendering state. And error
0x501: GL_INVALID_VALUE is generated if program is neither 0
nor a value generated by OpenGL.

This happens only when resuming from background, when
starting the application everything works fine. (see the
logs from previews mail).

Best regards,
Przemek

On Fri, Jan 03, 2014 at 11:46:29AM +0000, Przemyslaw Rzepecki wrote:

OK, thank You for that information. When I don’t recreate
the window (and use same, surface, renderer etc) there is no
crash but the screen is only black. I attach the logs from
Sony LT25i/Android 4.1.2 (there are two files, one where the
window is recreated and I get a crash, other with a black
screen).

Source code is available in a public repo:
https://bitbucket.org/przemekr/game_of_life_agg/src

https://bitbucket.org/przemekr/game_of_life_agg/src/master/agg-2.5/src/platform/sdl2/agg_platform_support.cpp

(I try to get AGG running on SDL2 and Android).

is there any particular reason why
you don’t want to handle these events?
Jared: I was not precise, sorry. I handle those event and
stop my app from doing any updates when in background. Only
after resume I get a black screen (window is not updated) so
I tried to add SDL_DestroyWindow, SDL_CreateWindow when I
foreground again, but then I got the crash.

Best regards,
Przemek


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Sylvain Becker

Thanks Sylvain!

I guess it might the lock/unlock issue. Right now I
don’t use it in my application (as I thought there is
only one thread). The 4) should be fine the events are
pulled before re-draw.

Best regards,On Tue, Jan 07, 2014 at 05:39:24PM +0100, Sylvain Becker wrote:

Hello,

Just a few ideas :
1/ update to the latest version of SDL.

2/ You dont need to recreate the window/renderer when entering again in
foreground.

3/ Shouldn’t you use the Lock/Unlock functions when accessing the "pixels"
field ?

4/ As you said in you previous mail. As soon as you get the
WILL_ENTER_BACKGROUND event, you should stop calling any rendering function.
But are you actually checking the “events” fast enough in you application ?

Cheers,
Sylvain

Hi,

After trying different changes and comparing with other
application I manage to find out that the problem was a
flag I passed when creating renderer. When using
SDL_RENDERER_SOFTWARE the GL context could not be recreated
on nativeResume, but everything works fine when I just pass
0 flags, in call to SDL_CreateRendere(window, -1, 0).

Thanks for Your comments.
Best regards,
Przemek> On Tue, Jan 07, 2014 at 05:39:24PM +0100, Sylvain Becker wrote:

Hello,

Just a few ideas :
1/ update to the latest version of SDL.

2/ You dont need to recreate the window/renderer when entering again in
foreground.

3/ Shouldn’t you use the Lock/Unlock functions when accessing the "pixels"
field ?

4/ As you said in you previous mail. As soon as you get the
WILL_ENTER_BACKGROUND event, you should stop calling any rendering function.
But are you actually checking the “events” fast enough in you application ?

Cheers,
Sylvain