Show MKV progress window for multi-track files (#12193)#12197
Merged
Conversation
The Matroska progress window (PR #11712) only appeared for single-track files. With multiple subtitle tracks, the Pick-Matroska-track dialog opens first and its preview called GetSubtitle synchronously on the UI thread. That first call is the one that reads/caches all cluster data, so the dialog froze with no progress window. Rewrite the dialog preview (TrackChanged -> async TrackChangedAsync) to parse off the UI thread via Task.Run and show the same 25 MB-gated PleaseWaitWindow until the initial cluster read completes. Serialize parsing with a SemaphoreSlim (MatroskaFile is not thread-safe) plus a token to drop stale previews on rapid selection changes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Confirmed v5.1.0-beta12 fixes this (tested on real media). |
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.
Fixes #12193
Problem
The Matroska "please wait" progress window (added in #11712) only appeared when an MKV had a single subtitle track. With multiple tracks, the Pick Matroska track dialog opens first, the UI froze during parsing, and the progress window never showed.
Root cause
MatroskaFile.GetSubtitle(...)reads and caches the whole file's cluster data on its first call; later calls are instant. That first read is the slow part.ExtractMatroskaSubtitleAsync, which shows the progress window. Works.SelectAndScrollToRow(0)firedTrackChanged(), which calledGetSubtitle(...)synchronously on the UI thread to build the preview — that first (heavy) read froze the UI with no progress window.Fix
In
PickMatroskaTrackViewModel:TrackChanged()→async TrackChangedAsync(). Parsing now runs off the UI thread inTask.Runvia a staticBuildPreview(...)that returns plain data (text + pre-decoded AvaloniaBitmaps, no controls); grid rows/Imagecontrols are built back on the UI thread.PleaseWaitWindowwith the determinate progress callback, only until the initial cluster read completes (_clusterLoaded), so later track switches don't flash a progress window.SemaphoreSlim(MatroskaFileisn't thread-safe — single sharedFileStream) plus a_trackChangeTokento discard stale previews on rapid selection changes.Se.LogErrorso a parse error in the fire-and-forget task isn't unobserved.format.ToText(...)call from the oldAddTextContent(result was unused).Testing
Builds clean (0 warnings / 0 errors). Not yet exercised against a real >25 MB multi-track MKV — reviewer confirmation on real media welcome.
🤖 Generated with Claude Code