mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-05 22:30:29 +00:00
Revert "android: fixed a possible joystick-related deadlock on application termination"
This reverts commit6b4ae68460. It turns out this deadlock is possible for any joystick event delivery combined with an event watcher that locks joysticks. I'm reverting this change for now, and will be working on a better global solution for this problem. (cherry picked from commit76560f9e47)
This commit is contained in:
parent
b8601dc8a7
commit
9fe4e5cc87
1 changed files with 0 additions and 22 deletions
|
|
@ -178,26 +178,6 @@ static void Android_OnDestroy(void)
|
|||
|
||||
static void Android_HandleLifecycleEvent(SDL_AndroidLifecycleEvent event)
|
||||
{
|
||||
// Make sure we're holding the joystick lock before dispatching life cycle events
|
||||
// This prevents deadlocks of this form:
|
||||
// 1. SDL locks the event watch list to dispatch the lifecycle event
|
||||
// 2. a joystick sensor event arrives, taking the joystick lock
|
||||
// 3. the lifecycle event dispatch calls into the application event
|
||||
// watcher, which closes joysticks, trying to take the joystick lock
|
||||
// 4. SDL delivers the sensor event, trying lock the event watch list
|
||||
// 5. BOOM, deadlock!
|
||||
//
|
||||
// There are a few solutions to this, most of which involve unlocking the
|
||||
// event watch list while delivering events or unlocking the joystick lock
|
||||
// while delivering joystick events, both of which reduce performance and
|
||||
// are extremely risky, so we'll do this, which is the least risky option.
|
||||
//
|
||||
// If you end up needing to wait for another thread that handles joystick
|
||||
// events in your life cycle handling, then you can simply unlock joysticks,
|
||||
// wait for that thread to complete, and then re-lock joysticks.
|
||||
|
||||
SDL_LockJoysticks();
|
||||
|
||||
switch (event) {
|
||||
case SDL_ANDROID_LIFECYCLE_WAKE:
|
||||
// Nothing to do, just return
|
||||
|
|
@ -217,8 +197,6 @@ static void Android_HandleLifecycleEvent(SDL_AndroidLifecycleEvent event)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
SDL_UnlockJoysticks();
|
||||
}
|
||||
|
||||
static Sint64 GetLifecycleEventTimeout(bool paused, Sint64 timeoutNS)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue