Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Changes
Fixes an issue where the entire emulator could freeze attempting to shut down.
The waitGS function (called by the MTVU thread) waits for the MTGS work queue to empty entirely by spinning on a lock that the MTGS thread normally holds while it's working. This caused two issues:
While we don't really care about MTVU state in the case of an exit, we would like to not abort in the case of a pause since otherwise unpausing will not work.
Based on this, there are two possible solutions:
The MTGS thread holds a mutex (
mtxBusy
) throughout operation (including calls to waitGS), which would need to be dropped if we want to pause the thread (otherwise the emulator will deadlock on exit). While this does remain an option, the consequences of dropping that mutex in the middle of operation would need to be investigated first.At the moment, option 2 seems like the easier option, and is what is implemented here. I don't expect anything bad to come from it, other than taking an extra frame or two to pause, but you never know.
Rationale behind Changes
Included in the
Description of Changes
sectionSuggested Testing Steps
Play games, pause and unpause the emulator a lot, try to quit the emulator. Observe CPU usage when paused (it should be very low).