TTS review: destroy mpv cores off the UI thread in Stop and row playback - #13684
Merged
Conversation
#13376 moved the TTS preview player's teardown to a worker thread because mpv_terminate_destroy on the UI thread corrupts state that later fails as an uncatchable access violation in IFrameworkInputPane.Unadvise when a window closes (#13567). That fix missed two sites in the review window: the Stop command and the row-to-row swap in PlayAudio (which the auto-continue timer drives on every transition) still disposed the core inline on the UI thread. Route both through DisposePlayerOffThread. Also add tools-log breadcrumbs to the review window's play/stop/close paths and on both sides of the TTS window's Window.Close() call, so the next crash report shows exactly how far teardown got. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follow-up to the #13376 fix, for #13567 (still crashing in beta 14).
The reporter's beta 14 crash has the byte-identical fault offset as the beta 11 report: an access violation during
IFrameworkInputPane.Unadvisewhile the TTS window's native window disposes. #13376's off-thread teardown covered the TTS window's voice preview and the review window'sOnClosing, but two sites inReviewSpeechViewModelstill ranmpv_terminate_destroyon the UI thread:Stop()disposed the playback core inline.PlayAudio()disposed the previous core inline before creating the next one — so playing a second row, or just letting auto-continue advance through rows, tore down a core on the UI thread at every transition.Both now route through the existing
DisposePlayerOffThread, andPlayAudioadopts the local-variable pattern fromTextToSpeechViewModel.PlayAudio(no half-initialized player left in_mpvContexton init failure, no null-deref race onLoadAudio).Since the crash is machine-specific and uncatchable, this also adds tools-log breadcrumbs: review window play/stop/OK/Cancel/closing, mpv dispose start/finish in both windows, and a line on each side of the TTS window's
Window.Close()call — a log ending between those two lines pinpoints the native crash.Tests:
dotnet test tests/UI/UITests.csproj --filter "FullyQualifiedName~TextToSpeech|FullyQualifiedName~ReviewSpeech"— 171 passed.🤖 Generated with Claude Code