Reject FFmpeg frames from cancelled sessions - #102
Conversation
Blackspirits
left a comment
There was a problem hiding this comment.
Independent adversarial re-check: deferred teardown means an old present worker can finish an iteration after close/replacement. The final guard serializes publication with _loadLock and rejects frames when the player is disposed, the Session cancellation is set, or the active cancellation identity no longer matches. Rejected frames are returned through the original VideoFrameQueue, which disposes them when closed. Lock order remains _loadLock -> _currentFrameLock, matching load/close cleanup, so no new inversion was introduced. Full CI #34780599136 passed restore, build and the complete suite on the first run; UITests reported 5,151 passed, 9 skipped, 0 failed. Retry was not used. No blocker identified. Keep draft; no merge performed.
Summary
#100 allows Session teardown to return after a bounded wait and defer final cleanup until a stubborn worker actually exits. That removes the resource use-after-free window, but it exposes a UI-lifetime race that the old blocking teardown normally hid.
A present worker from the cancelled Session can finish an iteration after close/replacement and call
FfmpegPlayer.Present, publishing an obsolete frame back into the owner after the new load has already taken over.This change, layered on #100:
FfmpegPlayer.Present;_loadLock;_loadLock→_currentFrameLock;This means deferred workers may finish, but they cannot resurrect stale media in the UI.
Validation
7c93a495f0b757b5c8f1c1725eddccf71fab964aVideoFrameQueue, which disposes them when the queue is already closedAI assistance: ChatGPT was used to review cross-session frame ownership after deferred FFmpeg teardown.