Fence FFmpeg frame publication by seek serial - #133
Draft
Blackspirits wants to merge 2 commits into
Draft
Blackspirits wants to merge 2 commits into
Blackspirits wants to merge 2 commits into
Conversation
Blackspirits
commented
Sep 15, 2026
Blackspirits
left a comment
Owner
Author
There was a problem hiding this comment.
Final adversarial review on 10c80c025d96d3b079e0bf279d05c8265c925071 after authoritative CI SubtitleEdit#266. Rechecked seek-lock ordering, frame claim/publication ordering, queue/current-frame lock interactions, callback deferral outside _seekLock, and stale-serial rejection. No blocker found in this tranche.
This was referenced Sep 16, 2026
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 FFmpeg presenter follow-up to #132 ("Do not recycle FFmpeg frames removed by seek flush").
This tranche intentionally uses #132 as its base. #132 removes the object-reuse/data race for frames asynchronously removed by seek flush; this PR closes the separate publication race where a normal frame can pass the presenter's early serial check and still be published after a newer seek serial commits.
Current upstream
SubtitleEdit/subtitleeditmain was rechecked at0e8b50b27f4084a12cd4a3b0ed01245366f91379; the latest delta is Japanese localization only and does not touch the FFmpeg player or frame queue.Finding fixed
A frame from the previous serial could be published after a seek committed
PresentLoop()checks the head frame against_currentSerial, but that check happened beforeShowFrame().A successful seek can interleave in the gap:
_currentSerial == N;_currentSerial = N+1under_seekLock;ShowFrame();ShowFrame()pops the still-present serial-N frame and publishes it to the UI.The identity check only proves that the same queue object was popped. It does not prove that its serial is still current at publication time.
With #132 in place, the old frame object itself is no longer eligible for asynchronous pool reuse, so the remaining boundary is ordering publication against seek commit.
Fix
ShowFrame()now treats publication as part of the seek-serial transaction:frame.Serial == _currentSerialunder_seekLock;FrameReadyuntil after the lock is released, so UI/user callbacks never execute under the seek lock.Because
PerformSeek()commits_currentSerialunder the same lock, the ordering is now explicit:The earlier
PresentLoop()serial check remains as a cheap fast-path; correctness no longer depends on its timing.Regression coverage
A pure helper test pins the publication classification:
The lock placement itself is reviewed structurally because the native/session pipeline is not instantiated by the pure test suite.
Scope / branch state
cd1ba8af5d5e0e7f7b576d7da96ccce4cfa26c8b10c80c025d96d3b079e0bf279d05c8265c925071AI assistance: ChatGPT was used for adversarial seek/presenter interleaving analysis, lock-order review, publication-boundary design, and focused regression coverage.
Final CI
Authoritative run: SubtitleEdit#266 on
10c80c025d96d3b079e0bf279d05c8265c925071Final adversarial review was performed on this exact HEAD after CI; no blocker found.