RetroAchievements / RAIntegration

The DLL responsible to integrate emulators with RetroAchievements.org
https://retroachievements.org
MIT License
98 stars 23 forks source link

fix deadlock trying to shutdown from non-UI thread #1077

Closed Jamiras closed 7 months ago

Jamiras commented 7 months ago

The shutdown process is expecting the Windows message queue to be available to pump messages.

In the PPSSPP implementation, the shutdown is called from a background thread, and the UI thread is blocked waiting for the background thread to stop. This causes a deadlock.

The solution is to change the calls that close the windows to use PostMessage, and let the message queue actually close the windows when it frees up. However, at that point the DLL is no longer loaded, so there were several issues trying to dispatch messages to the custom WndProcs. To address that, as part of the shutdown process, replace all of the custom WndProcs with default ones.