Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android: Fix race condition in displayAlertMsg #12688

Merged

Conversation

JosJuice
Copy link
Member

@JosJuice JosJuice commented Apr 5, 2024

It was possible for sAlertMessageLock.notify() to be called before sAlertMessageLock.wait(), causing Dolphin to deadlock. In particular, this was guaranteed to happen if displayAlertMsg was called from the UI thread while the emulation activity is being destroyed, because runOnUiThread runs the passed-in anonymous function immediately when called from the UI thread.

By replacing Object.wait/Object.notify with Semaphore.acquire/Semaphore.release, it no longer matters what order the methods are called in.

It was possible for sAlertMessageLock.notify() to be called before
sAlertMessageLock.wait(), causing Dolphin to deadlock. In particular,
this was guaranteed to happen if displayAlertMsg was called from the UI
thread while the emulation activity is being destroyed, because
runOnUiThread runs the passed-in anonymous function immediately when
called from the UI thread.

By replacing Object.wait/Object.notify with Semaphore.acquire/
Semaphore.release, it no longer matters what order the methods are
called in.
@AdmiralCurtiss AdmiralCurtiss merged commit b623a36 into dolphin-emu:master Apr 12, 2024
11 checks passed
@JosJuice JosJuice deleted the android-alert-synchronize branch April 13, 2024 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants