RetroAchievements / RAIntegration

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

fix race condition integrating local code notes #1008

Closed Jamiras closed 1 year ago

Jamiras commented 1 year ago

fixes #997

There was a race condition where the main thread was trying to merge local code notes into the code notes list while a background thread was populating the list from the server response. If the code notes window or memory inspector was open, the background thread would block, waiting for the UI thread to become available so the UI could be updated. This would result in the server notes response processing thread waiting indefinitely while the game loaded on the main thread, and all local notes read while loading the game on the main thread would be overwritten by the server notes when the background thread was eventually allowed to continue.

Solution: Keep track of when server notes are being fetched and queue up changes until the fetch is complete, then apply the changes.