Skip to content

Open from URL: marshal download timer tick to UI thread#11652

Merged
niksedk merged 1 commit into
mainfrom
fix/download-url-timer-ui-thread
Jun 16, 2026
Merged

Open from URL: marshal download timer tick to UI thread#11652
niksedk merged 1 commit into
mainfrom
fix/download-url-timer-ui-thread

Conversation

@niksedk

@niksedk niksedk commented Jun 16, 2026

Copy link
Copy Markdown
Member

What

DownloadVideoFromUrlViewModel polls the background download task with a System.Timers.Timer. The Elapsed handler fires on a thread-pool thread but writes [ObservableProperty] values bound to the UI (StatusText, Error) and closes the window. Touching bound state off the UI thread can throw "Call from invalid thread" or leave the UI in an inconsistent state.

This wraps the tick in Dispatcher.UIThread.Post(...) so all of it runs on the UI thread. Since Close() is now always called on the UI thread, its own inner Post is removed.

Why

Tightens a real thread-affinity smell in the "Open video from URL → Download and open" flow. Surfaced while investigating #11644 (freeze after opening a video from a URL with subtitles). This is not confirmed to be the cause of that report — the leading hypothesis there is the embedded video player rendering a specific container/codec — but the cross-thread property writes are a genuine latent bug worth fixing regardless.

Testing

  • dotnet build UI.csproj succeeds with 0 warnings / 0 errors.
  • Behavior unchanged on the happy path; the timer tick now always executes on the UI thread.

🤖 Generated with Claude Code

DownloadVideoFromUrlViewModel uses a System.Timers.Timer to poll the
background download task. Its Elapsed handler runs on a thread-pool
thread but writes observable properties bound to the UI (StatusText,
Error) and closes the window. Touching bound state off the UI thread
can throw "call from invalid thread" or leave the UI inconsistent.

Marshal the whole tick to the UI thread via Dispatcher.UIThread.Post.
Close() is now always called on the UI thread, so it no longer needs
its own Post.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@niksedk niksedk merged commit 7b67b0a into main Jun 16, 2026
1 of 3 checks passed
@niksedk niksedk deleted the fix/download-url-timer-ui-thread branch June 16, 2026 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant