[SDL] Resume on SDL Android

Gabriel Jacobo gabomdq at gmail.com
Sat Mar 30 08:18:43 PDT 2013


Good find! Can you send me a patch or upload it to Bugzilla? I'll test and
commit it.


2013/3/30 Jonathan Dearborn <grimfang4 at gmail.com>

> Ah, I think I got it.  On my device, onCreate() is being called on resume.
>  Is that expected?  Anyhow, onCreate() sets mIsPaused to false.  The
> solution, in my view, is to set mIsPaused to false at its declaration
> (public static boolean mIsPaused = false;) and remove the setting in
> onCreate() (mIsPaused = false;) so that its value survives future
> onCreate() calls.  It's working so far!
>
> Jonny D
>
>
> On Fri, Mar 29, 2013 at 1:22 PM, Jonathan Dearborn <grimfang4 at gmail.com>wrote:
>
>> It seems inconsistent.  I have actually gotten it to resume, but more
>> often it does this on resume:
>>
>> 03-29 13:15:50.100: V/SDL(16780): surfaceCreated()
>> 03-29 13:15:50.147: V/SDL(16780): surfaceChanged()
>> 03-29 13:15:50.147: V/SDL(16780): pixel format RGB_565
>> 03-29 13:15:50.147: V/SDL(16780): Window size:800x1280
>> 03-29 13:15:50.147: V/SDL(16780): startApp()
>> 03-29 13:15:50.147: V/SDL(16780): startApp() mSDLThread is not null
>> 03-29 13:15:50.147: V/SDL(16780): startApp() mIsPaused is false
>>
>> So SDLActivity.mIsPaused is not getting set all the time on pause or it
>> is not surviving until the resume call.  That makes my app thread block.
>> :-/  Is it reasonably safe to remove the check on mIsPaused?  What else
>> could cause this?
>>
>> Jonny D
>>
>>
>>
>> On Fri, Mar 29, 2013 at 12:50 PM, Jonathan Dearborn <grimfang4 at gmail.com>wrote:
>>
>>> To be more clear, the logs within the if(SDL_Sem*Wait(Android_ResumeSem)
>>> == 0) are not happening, so it seems that the Android_ResumeSem is not
>>> being released.
>>>
>>> Jonny D
>>>
>>>
>>> On Fri, Mar 29, 2013 at 12:35 PM, Jonathan Dearborn <grimfang4 at gmail.com
>>> > wrote:
>>>
>>>> Here's what I get when BLOCK_ON_PAUSE is 1:
>>>>
>>>> 03-29 12:22:31.844: W/SDL/APP(12394): Pump
>>>> 03-29 12:22:31.860: W/SDL/APP(12394): Pump
>>>> 03-29 12:22:31.875: W/SDL/APP(12394): Pump
>>>> 03-29 12:22:31.899: W/SDL/APP(12394): Pump
>>>> 03-29 12:22:31.907: V/SDL(12394): surfaceDestroyed()
>>>> 03-29 12:22:31.907: W/SDL/APP(12394): nativePause
>>>> 03-29 12:22:31.907: W/SDL/APP(12394): Android_Window
>>>> 03-29 12:22:31.907: W/SDL/APP(12394): Post PauseSem
>>>> 03-29 12:22:31.907: W/SDL/APP(12394): Sending pause events
>>>> 03-29 12:22:31.954: W/SDL/APP(12394): Pump
>>>> 03-29 12:22:31.954: D/OpenGLRenderer(12394): Flushing caches (mode 0)
>>>> 03-29 12:22:31.954: W/SDL/APP(12394): Pausing
>>>> 03-29 12:22:31.954: E/APPLICATION(12394): SDL_WINDOWEVENT_SIZE_CHANGED
>>>> 03-29 12:22:31.954: W/SDL/APP(12394): Pump
>>>> 03-29 12:22:31.954: W/SDL/APP(12394): Pausing
>>>> 03-29 12:22:31.954: E/APPLICATION(12394): SDL_WINDOWEVENT_FOCUS_LOST
>>>> 03-29 12:22:31.954: W/SDL/APP(12394): Pump
>>>> 03-29 12:22:31.954: W/SDL/APP(12394): Pausing
>>>> 03-29 12:22:31.954: E/APPLICATION(12394): SDL_WINDOWEVENT_MINIMIZED
>>>> 03-29 12:22:31.961: W/SDL/APP(12394): Pump
>>>> 03-29 12:22:31.961: W/SDL/APP(12394): Pausing
>>>> 03-29 12:22:32.079: W/SDL/APP(12394): Pump
>>>> 03-29 12:22:32.079: W/SDL/APP(12394): isPaused && !isPausing
>>>> 03-29 12:22:32.086: D/OpenGLRenderer(12394): Flushing caches (mode 1)
>>>>
>>>> Then it blocks and is in the background...
>>>>
>>>> When I resume...
>>>>
>>>> 03-29 12:22:50.602: V/SDL(12394): surfaceCreated()
>>>> 03-29 12:22:50.633: V/SDL(12394): surfaceChanged()
>>>> 03-29 12:22:50.633: V/SDL(12394): pixel format RGB_565
>>>> 03-29 12:22:50.633: V/SDL(12394): Window size:800x1280
>>>>
>>>> Then nothing else.  Black screen, no input response.
>>>>
>>>>
>>>>
>>>> With BLOCK_ON_PAUSE set to 0, the same sort of thing happens.  When the
>>>> app is paused, it repeats Pump, isPaused, and this queue error continually.
>>>>  Then it does this on resume:
>>>>
>>>> 03-29 12:25:56.711: W/SDL/APP(12790): Pump
>>>> 03-29 12:25:56.711: W/SDL/APP(12790): isPaused
>>>> 03-29 12:25:56.711: E/SurfaceTextureClient(12790): queueBuffer: error
>>>> queuing buffer to SurfaceTexture, -19
>>>> 03-29 12:25:56.719: W/SDL/APP(12790): Pump
>>>> 03-29 12:25:56.719: W/SDL/APP(12790): isPaused
>>>> 03-29 12:25:56.727: E/SurfaceTextureClient(12790): queueBuffer: error
>>>> queuing buffer to SurfaceTexture, -19
>>>> 03-29 12:25:56.735: W/SDL/APP(12790): Pump
>>>> 03-29 12:25:56.735: W/SDL/APP(12790): isPaused
>>>> 03-29 12:25:56.743: E/SurfaceTextureClient(12790): queueBuffer: error
>>>> queuing buffer to SurfaceTexture, -19
>>>> 03-29 12:25:56.750: V/SDL(12790): surfaceCreated()
>>>> 03-29 12:25:56.758: W/SDL/APP(12790): Pump
>>>> 03-29 12:25:56.758: W/SDL/APP(12790): isPaused
>>>> 03-29 12:25:56.758: E/SurfaceTextureClient(12790): queueBuffer: error
>>>> queuing buffer to SurfaceTexture, -19
>>>> 03-29 12:25:56.766: W/SDL/APP(12790): Pump
>>>> 03-29 12:25:56.766: W/SDL/APP(12790): isPaused
>>>> 03-29 12:25:56.766: E/SurfaceTextureClient(12790): queueBuffer: error
>>>> queuing buffer to SurfaceTexture, -19
>>>> 03-29 12:25:56.782: W/SDL/APP(12790): Pump
>>>> 03-29 12:25:56.782: W/SDL/APP(12790): isPaused
>>>> 03-29 12:25:56.782: E/SurfaceTextureClient(12790): queueBuffer: error
>>>> queuing buffer to SurfaceTexture, -19
>>>> 03-29 12:25:56.790: V/SDL(12790): surfaceChanged()
>>>> 03-29 12:25:56.790: V/SDL(12790): pixel format RGB_565
>>>> 03-29 12:25:56.790: V/SDL(12790): Window size:800x1280
>>>> 03-29 12:25:56.790: W/SDL/APP(12790): Pump
>>>> 03-29 12:25:56.790: W/SDL/APP(12790): isPaused
>>>> 03-29 12:25:56.790: E/SurfaceTextureClient(12790): queueBuffer: error
>>>> queuing buffer to SurfaceTexture, -19
>>>> 03-29 12:25:56.805: W/SDL/APP(12790): Pump
>>>> 03-29 12:25:56.805: W/SDL/APP(12790): isPaused
>>>> 03-29 12:25:56.805: E/SurfaceTextureClient(12790): queueBuffer: error
>>>> queuing buffer to SurfaceTexture, -19
>>>> 03-29 12:25:56.821: W/SDL/APP(12790): Pump
>>>> 03-29 12:25:56.821: W/SDL/APP(12790): isPaused
>>>>
>>>> Then it repeats the Pump, isPaused, and queue error forever with a
>>>> black screen and no interaction.  So, essentially the same as with
>>>> BLOCK_ON_PAUSE.
>>>>
>>>> Jonny D
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Fri, Mar 29, 2013 at 10:49 AM, Gabriel Jacobo <gabomdq at gmail.com>wrote:
>>>>
>>>>>
>>>>>
>>>>>
>>>>> 2013/3/29 Jonathan Dearborn <grimfang4 at gmail.com>
>>>>>
>>>>>> I've been having trouble getting my Android app to behave acceptably
>>>>>> when resumed from pause.  I receive SDL_WINDOWEVENT_FOCUS_LOST
>>>>>> and SDL_WINDOWEVENT_MINIMIZED, but I never
>>>>>> receive SDL_WINDOWEVENT_FOCUS_GAINED or SDL_WINDOWEVENT_RESTORED.
>>>>>>
>>>>>> Whether or not I enable SDL_ANDROID_BLOCK_ON_PAUSE, the app comes
>>>>>> back from pause as a black screen and it seems that I can't interact with
>>>>>> it at all.  When SDL_ANDROID_BLOCK_ON_PAUSE is 0, control remains with my
>>>>>> code, but subsequent OpenGL calls do nothing.
>>>>>>
>>>>>> Perhaps my GL context is being lost?  Maybe a Java thread remains
>>>>>> blocked?
>>>>>>
>>>>>> I'm running Android 4.0.3 on a Kindle Fire HD 7.
>>>>>>
>>>>>> Jonny D
>>>>>>
>>>>>
>>>>>
>>>>> You do need to keep the message pump going until the app blocks
>>>>> itself, other than that I've no suggestions.
>>>>>
>>>>> Can you add a few print statements
>>>>> in Java_org_libsdl_app_SDLActivity_nativePause,
>>>>> Java_org_libsdl_app_SDLActivity_nativeResume and Android_PumpEvents to see
>>>>> where it may be getting stuck?
>>>>>
>>>>> --
>>>>> Gabriel.
>>>>>
>>>>> _______________________________________________
>>>>> SDL mailing list
>>>>> SDL at lists.libsdl.org
>>>>> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>>>>>
>>>>>
>>>>
>>>
>>
>
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
>


-- 
Gabriel.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20130330/8db61fee/attachment-0009.htm>


More information about the SDL mailing list