You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reported in version: HG 2.0 Reported for operating system, platform: Android (All), ARM
Comments on the original bug report:
On 2012-02-19 09:58:05 +0000, Stevie Frederick wrote:
After initializing a window context and blitting imagery to the screen using said window with the combination of: GetWindowSurface() and UpdateWindowSurface(), the image is correctly displayed to the screen/display device.
However, when the Android application loses focus, i.e. onPause() is fired, these windows lose their context.
A call to UpdateWindowSurface with the previously initialized surface will bring back an error from Android's Surface module:
Surface: using an invalid surface id=1, identity=%d, should be identity=%d
Destroying the window with SDL_DestroyWindow and recreating with SDL_CreateWindow freezes the application.
Application will freeze during recreation of window:
W/SharedBufferStack( 97): waitForCondition(ReallocateCondition) timed out (identity=1030, status=0). CPU may be pegged. trying again.
Actively searching for work-arounds.
On 2012-02-27 08:23:03 +0000, Gabriel Jacobo wrote:
In short, previously SDL under Android right out quit when it lost focus, now it remains active but as you loose the GL context, you have to re create your textures. This is an Android only issue, as it doesn't seem to happen in any of the other supported architectures (even iOS). I suggested in my post some potentials fixes/workarounds but I haven't got around to implementing any of these.
On 2012-05-28 15:30:44 +0000, Gabriel Jacobo wrote:
Created attachment 862
A few fixes required for proper pause/resume support on Android
This is a patch for SDLActivity.java that allows for pause/resume of activities and it should work as is under Android > 3.0.
To complement this patch, on you app you should listen for SDL_WINDOWEVENT_RESTORED (only under Android), and call SDL_GL_CreateContext(window) to restore the GL Context, that's the only thing you need to do.
The only "to do" for this would be sending a message where the Log line:
Log.e("SDL", "Old EGL Context doesnt work, trying with a new one");
is, to let the app know that it has to reload its textures...or we could get fancy and try to do it automagically (saving all textures to memory on pause and then restoring them on resume?)
On 2012-06-01 15:12:34 +0000, Gabriel Jacobo wrote:
Created attachment 864
Recreate the GL context automatically
Attaching my best attempt at the complimentary part of the first patch, the one that automatically re-creates the GL context on the appropriate thread.
There's no simple solution to this problem...You can't add this in GLES_WindowEvent / GLES2_WindowEvent because they are called through SDL_SetEventFilter, so they are called in the Java thread vs the SDL thread.
In the interest of speed, I've added a global variable (yuck!) that tracks the hidden/paused state of the Android window, and we do the peeking of events only in the case that the window has been hidden.
There's two To-Dos in the patch:
TODO: Should we double check if we are on the same thread that originally created the GL context? If for some reason the user is pumping events in a separate thread other than the main SDL thread, this can cause problems.
TODO: If the context can't be recovered, send the user a message to let him know that the GL context has changed behind the scenes
On 2012-06-18 18:10:48 +0000, Gabriel Jacobo wrote:
Created attachment 880
Recreate the GL context automatically
Uploading improved patch, this one uses two semaphores and no messages, and offers the possibility of blocking the event loop while on pause with #if SDL_ANDROID_BLOCK_ON_PAUSE
I'm using this patch now in my system and it works like a charm.
On 2012-06-19 10:13:15 +0000, Gabriel Jacobo wrote:
This bug report was migrated from our old Bugzilla tracker.
These attachments are available in the static archive:
A few fixes required for proper pause/resume support on Android (Android_PauseResume.patch, text/plain, 2012-05-28 15:30:44 +0000, 1916 bytes)Recreate the GL context automatically (bug1425-2.patch, text/plain, 2012-06-01 15:12:34 +0000, 4058 bytes)Reported in version: HG 2.0
Reported for operating system, platform: Android (All), ARM
Comments on the original bug report:
On 2012-02-19 09:58:05 +0000, Stevie Frederick wrote:
On 2012-02-27 08:23:03 +0000, Gabriel Jacobo wrote:
On 2012-05-28 15:30:44 +0000, Gabriel Jacobo wrote:
On 2012-06-01 15:12:34 +0000, Gabriel Jacobo wrote:
On 2012-06-18 18:10:48 +0000, Gabriel Jacobo wrote:
On 2012-06-19 10:13:15 +0000, Gabriel Jacobo wrote:
The text was updated successfully, but these errors were encountered: