frontend, captions: Fix caption dialog hang #12729
Open
+20
−31
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
When captions are enabled and the caption dialog is opened, the ui initialization in
CaptionsDialog::CaptionsDialog()
caused an event trigger which then restarted the caption thread. During the restart (which also happens when changing caption settings)CaptionStream::Stop()
is supposed to notify/wake waiting reader thread, but the way mutex is handled inCaptionStream::Read()
may cause the thread to miss the notification and then wait infinitely. Fix includes changes to mutex handling, but also adding a newstop
flag to prevent callingwait()
whenStop()
has been called.Additional fix for mutex handling in
CaptionStream::CopyTo()
, which acquired the size to copy outside of mutex lock.There is also potential issue in
mssapi_captions::main_thread()
which has a busy inner loop and the stop event is checked only in an outer loop, but this seemed more unlikely to happen in practice than the above fixes. Something to keep an eye out for though.Motivation and Context
Fixes #12626
How Has This Been Tested?
Seeking testers, since I'm unable to reproduce the original issue.
Note that since opening the dialog no longer restarts the caption thread, testing the fix should be done by changing the caption settings while the captions are enabled instead.
Types of changes
Checklist: