Android: black screen after resume

Hi.

my logs are saying something like this:

V/SDL (14728): onPause()
E/libEGL (14728): call to OpenGL ES API with no current context (logged
once per thread)
V/SDL (14728): nativePause()
V/SDL (14728): onWindowFocusChanged(): false
V/SDL (14728): surfaceDestroyed()
I/ActivityManager( 435): START u0 {act=android.intent.action.MAIN
cat=[android.intent.category.LAUNCHER] flg=0x10200000
cmp=org.foobar/.FooBar} from pid 769
V/SDL (14728): onResume()
V/SDL (14728): surfaceCreated()
V/SDL (14728): surfaceChanged()
V/SDL (14728): pixel format RGB_565
V/SDL (14728): Window size:1280x736
V/SDL (14728): onWindowFocusChanged(): true
V/SDL (14728): nativeResume()

The screen stays black after resume - input is still working as
expected. Just rendering isn’t. I’m using the SDL GLES2 renderer.

I’m not sure about the libEGL error that is reported in the logs. Every
little bit of help is welcome. Thanks a lot

Martin

Sounds like after OnPause (which I understand to be the system
suspending your app?), your GL context is getting trashed. You may
need to recreate it upon resume.

JosephOn Sat, Oct 05, 2013 at 09:41:32PM +0200, Martin Gerhardy wrote:

Hi.

my logs are saying something like this:

V/SDL (14728): onPause()
E/libEGL (14728): call to OpenGL ES API with no current context
(logged once per thread)
V/SDL (14728): nativePause()
V/SDL (14728): onWindowFocusChanged(): false
V/SDL (14728): surfaceDestroyed()
I/ActivityManager( 435): START u0 {act=android.intent.action.MAIN
cat=[android.intent.category.LAUNCHER] flg=0x10200000
cmp=org.foobar/.FooBar} from pid 769
V/SDL (14728): onResume()
V/SDL (14728): surfaceCreated()
V/SDL (14728): surfaceChanged()
V/SDL (14728): pixel format RGB_565
V/SDL (14728): Window size:1280x736
V/SDL (14728): onWindowFocusChanged(): true
V/SDL (14728): nativeResume()

The screen stays black after resume - input is still working as
expected. Just rendering isn’t. I’m using the SDL GLES2 renderer.

I’m not sure about the libEGL error that is reported in the logs.
Every little bit of help is welcome. Thanks a lot

2013/10/5 Martin Gerhardy <martin.gerhardy at gmail.com>

Hi.

my logs are saying something like this:

V/SDL (14728): onPause()
E/libEGL (14728): call to OpenGL ES API with no current context (logged
once per thread)
V/SDL (14728): nativePause()
V/SDL (14728): onWindowFocusChanged(): false
V/SDL (14728): surfaceDestroyed()
I/ActivityManager( 435): START u0 {act=android.intent.action.**MAIN
cat=[android.intent.category.**LAUNCHER] flg=0x10200000
cmp=org.foobar/.FooBar} from pid 769
V/SDL (14728): onResume()
V/SDL (14728): surfaceCreated()
V/SDL (14728): surfaceChanged()
V/SDL (14728): pixel format RGB_565
V/SDL (14728): Window size:1280x736
V/SDL (14728): onWindowFocusChanged(): true
V/SDL (14728): nativeResume()

The screen stays black after resume - input is still working as expected.
Just rendering isn’t. I’m using the SDL GLES2 renderer.

I’m not sure about the libEGL error that is reported in the logs. Every
little bit of help is welcome. Thanks a lot

I updated my game with the latest changes from HG (I thought some of the
refactoring going on the GL ES 2 renderer could be the cause of the issues
you were seeing), but unfortunately I’m unable to reproduce the problem.

The libEGL message is harmless.–
Gabriel.

my logs are saying something like this:

V/SDL     (14728): onPause()
E/libEGL  (14728): call to OpenGL ES API with no current context
(logged once per thread)
V/SDL     (14728): nativePause()
V/SDL     (14728): onWindowFocusChanged(): false
V/SDL     (14728): surfaceDestroyed()
I/ActivityManager(  435): START u0 {act=android.intent.action.MAIN
cat=[android.intent.category.LAUNCHER] flg=0x10200000
cmp=org.foobar/.FooBar} from pid 769
V/SDL     (14728): onResume()
V/SDL     (14728): surfaceCreated()
V/SDL     (14728): surfaceChanged()
V/SDL     (14728): pixel format RGB_565
V/SDL     (14728): Window size:1280x736
V/SDL     (14728): onWindowFocusChanged(): true
V/SDL     (14728): nativeResume()


The screen stays black after resume - input is still working as
expected. Just rendering isn't. I'm using the SDL GLES2 renderer.

I'm not sure about the libEGL error that is reported in the logs.
Every little bit of help is welcome. Thanks a lot

I updated my game with the latest changes from HG (I thought some of
the refactoring going on the GL ES 2 renderer could be the cause of
the issues you were seeing), but unfortunately I’m unable to reproduce
the problem.

The libEGL message is harmless.

Unfortunatelly it doesn’t happen always for me, too. I’m not sure what
the trigger might be. In 99% of the cases it just works great.

If it’s about the gl context that is gone - shouldn’t (at least when i
use the render api) this be handled by sdl automagically?

2013/10/6 Martin Gerhardy <martin.gerhardy at gmail.com>

my logs are saying something like this:

V/SDL (14728): onPause()
E/libEGL (14728): call to OpenGL ES API with no current context (logged
once per thread)
V/SDL (14728): nativePause()
V/SDL (14728): onWindowFocusChanged(): false
V/SDL (14728): surfaceDestroyed()
I/ActivityManager( 435): START u0 {act=android.intent.action.MAIN
cat=[android.intent.category.LAUNCHER] flg=0x10200000
cmp=org.foobar/.FooBar} from pid 769
V/SDL (14728): onResume()
V/SDL (14728): surfaceCreated()
V/SDL (14728): surfaceChanged()
V/SDL (14728): pixel format RGB_565
V/SDL (14728): Window size:1280x736
V/SDL (14728): onWindowFocusChanged(): true
V/SDL (14728): nativeResume()

The screen stays black after resume - input is still working as expected.
Just rendering isn’t. I’m using the SDL GLES2 renderer.

I’m not sure about the libEGL error that is reported in the logs. Every
little bit of help is welcome. Thanks a lot

I updated my game with the latest changes from HG (I thought some of the
refactoring going on the GL ES 2 renderer could be the cause of the issues
you were seeing), but unfortunately I’m unable to reproduce the problem.

The libEGL message is harmless.

Unfortunatelly it doesn’t happen always for me, too. I’m not sure what the
trigger might be. In 99% of the cases it just works great.

If it’s about the gl context that is gone - shouldn’t (at least when i use
the render api) this be handled by sdl automagically?

Handling a context loss automagically is next to impossible as SDL would
need to keep a copy of each of your textures (and your render to texture
operations!) in memory. What SDL should do is send you a message about it,
which is in the TODO list (though it’s very unlikely you are losing the GL
context).

2013/10/6, Gabriel Jacobo :

Handling a context loss automagically is next to impossible as SDL would
need to keep a copy of each of your textures (and your render to texture
operations!) in memory. What SDL should do is send you a message about it,
which is in the TODO list (though it’s very unlikely you are losing the GL
context).

Or it could just make a copy when the context is about to get lost,
and restore the data when the context gets recreated (I would imagine
this is already an issue on Windows since Direct3D can lose the
context, at least on Windows XP?).

Although yeah, if the issue happens rarely (as opposed to
consistently) it’s probably not a context loss in this case.

I have the same problem. It could be reproduced even with SDL test gles2. repro rate 100%
Android 4.3.
Image comes back after lock screen.

Hi,
I can confirm that this problem exists on Android and on iOS.
After pausing application and activating it back, the window does not
update.
I tracked it to the call to glTexSubImage2D in SDL_render_gles.c function
GLES_UpdateTexture line 574 (renderdata->glTexSubImage2D)
This function, called with the same parameteres, returns
GL_INVALID_OPERATION after unpausing, while before pausing function
succeds.
P.On Sun, 6 Oct 2013, dmuratshin wrote:

I have the same problem. It could be reproduced even with SDL test gles2. repro rate 100%
Android 4.3.
Image comes back after lock screen.

dmuratshin wrote:

I have the same problem. It could be reproduced even with SDL test gles2. repro rate 100%
Android 4.3.
Image comes back after lock screen.

to be clear. I meant this test: testgles.c

dmuratshin wrote:

I have the same problem. It could be reproduced even with SDL test gles2. repro rate 100%
Android 4.3.
Image comes back after lock screen.

fixed now! thanks to Gabriel!

2013/10/10 dmuratshin

**

dmuratshin wrote:

I have the same problem. It could be reproduced even with SDL test
gles2. repro rate 100%
Android 4.3.
Image comes back after lock screen.

fixed now! thanks to Gabriel!

For anyone interested, the problem was that in apps that hammer the
SDL_GL_MakeCurrent function (like testgles), there was situations where
SDL_GL_MakeCurrent would make the context current after we’ve nulled it so
Android can free the EGL Surface, so the surface was never released and
that caused errors.

In other news, I’ve added a nifty script in build-scripts/androidbuild.sh
which should help people set up a basic Android project using SDL. Feedback
welcome!–
Gabriel.