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 - Deadlock in android after locking screen
Summary: Deadlock in android after locking screen
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: 2.0.0
Hardware: All Android (All)
: P2 major
Assignee: Gabriel Jacobo
QA Contact: Sam Lantinga
URL:
Keywords: target-2.0.0
: 2023 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-08-08 11:09 UTC by Alexey
Modified: 2013-08-12 10:15 UTC (History)
1 user (show)

See Also:


Attachments
Wait for more events before blocking (953 bytes, patch)
2013-08-08 14:01 UTC, Gabriel Jacobo
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.