We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2022

Summary: Deadlock in android after locking screen
Product: SDL Reporter: Alexey <alexey.petruchik>
Component: *don't know*Assignee: Gabriel Jacobo <gabomdq>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: major    
Priority: P2 CC: gabomdq
Version: 2.0.0Keywords: target-2.0.0
Hardware: All   
OS: Android (All)   
Attachments: Wait for more events before blocking

Description Alexey 2013-08-08 11:09:39 UTC
When app screen locks SDL thread is locked while main thread is waiting for SDL thread to end in onDestroy() handler. More info here: http://lists.libsdl.org/pipermail/sdl-libsdl.org/2013-August/089657.html
Comment 1 Gabriel Jacobo 2013-08-08 13:37:36 UTC
*** Bug 2023 has been marked as a duplicate of this bug. ***
Comment 2 Gabriel Jacobo 2013-08-08 14:01:54 UTC
Created attachment 1276 [details]
Wait for more events before blocking

Let me know if this patch fixes things. Thanks!
Comment 3 Alexey 2013-08-09 11:02:34 UTC
This patch really fixes missing SDL_APP_DIDENTERBACKGROUND. But the real issue is deadlock upon screen lock caused by onDestroy(). After some search I found solution. Activity is destroyed because after screen lock screen orientation changes from landscape to portrait. To disable activity recreation we need add line to AndroidManifest.xml:

android:configChanges="orientation|keyboardHidden|screenSize"

More details here:

http://stackoverflow.com/questions/16771319/android-activity-ondestroy-called-on-screen-lock
http://stackoverflow.com/questions/9948315/activity-lifecycle-x-power-button-x-lock-screen
Comment 4 Gabriel Jacobo 2013-08-12 10:15:51 UTC
This should fix it: http://hg.libsdl.org/SDL/rev/171a7ab71f28

Instead of pausing/resuming on surfaceChanged, we only pause/resume on onWindowFocusChanged.

I was able to reproduce and fix the problem in my phone, and as far as I could tell there were no side effects to this patch, but please feel free to reopen if something got broken because of this change.