Keep FFmpeg final teardown off the UI thread - #138
Draft
Blackspirits wants to merge 1 commit into
Draft
Blackspirits wants to merge 1 commit into
Blackspirits wants to merge 1 commit into
Conversation
Blackspirits
force-pushed
the
audit/ffmpeg-ui-teardown-background-af88
branch
from
September 15, 2026 20:45
a22d999 to
0db53f2
Compare
Blackspirits
commented
Sep 15, 2026
Blackspirits
left a comment
Owner
Author
There was a problem hiding this comment.
Final adversarial review on 0db53f219c3e929752416e6dead7bdaca24b0def after CI SubtitleEdit#277: no blocker found. Verified final teardown is exactly-once, FFmpeg render-host ownership is transferred before detach, normal reusable Close remains synchronous, an already-posted FrameReady can only invalidate a detached control and cannot retain the player, and mpv/VLC retain their existing ordering. No merge/promotion performed.
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.
Purpose
Dependent lifetime/UI follow-up to #115 ("Harden FFmpeg session startup and teardown lifetime").
#115 made Session teardown fail closed when workers do not stop, but definitive VideoPlayerControl teardown still called FFmpeg
CloseFile()synchronously on the UI thread before the existing backgroundDispose().Current upstream
SubtitleEdit/subtitleeditmain was rechecked atd6917286e355976da953d0ee22208b4bf9461699; its latest change is unrelated and no open upstream PR was found for this boundary.Finding fixed
For FFmpeg,
CloseFile()callsSession.Dispose(). #115 safely joins demux, video, audio and presenter workers with a 5-second timeout per thread before releasing worker-visible resources.VideoPlayerControl.CloseAndDisposePlayer()previously calledClose()first, so a stuck worker could freeze layout rebuild, fullscreen/undock teardown or window close on the UI thread before execution ever reached the background Dispose already intended to protect UI responsiveness.Fix
IVideoPlayernow has a default-false final-teardown capability,DeferCloseFileToDispose; only FFmpeg opts in.During definitive teardown:
CloseFile();Close()remains unchanged and synchronous;FfmpegSoftwareControlexplicitly relinquishes the player and unsubscribesFrameReadybefore content detach;CloseAndDisposePlayer()itself is now idempotent, so repeated teardown cannot schedule a second Dispose.Native mpv/VLC keep the old ordering because the capability defaults false.
Regression coverage
Tests pin that:
Close()still closes synchronously;FfmpegPlayer + FfmpegSoftwareControlteardown transfers disposal ownership before content removal;Scope / branch state
af88aa7d7591721f6c509d5432f9a07d532bbeae0db53f219c3e929752416e6dead7bdaca24b0defd6917286e355976da953d0ee22208b4bf9461699AI assistance: ChatGPT was used for adversarial teardown/thread-affinity review, render-host disposal ownership modelling, idempotency analysis and focused concurrency regression design.
Final CI
Authoritative run: SubtitleEdit#277 on
0db53f219c3e929752416e6dead7bdaca24b0defFinal adversarial review was performed on this exact HEAD after CI; no blocker found.