Skip to content

Release detached seek frame when the FFmpeg video loop exits - #94

Draft
Blackspirits wants to merge 1 commit into
upl/review-base-c77cfrom
fix/ffmpeg-last-dropped-frame-release-c77c
Draft

Release detached seek frame when the FFmpeg video loop exits#94
Blackspirits wants to merge 1 commit into
upl/review-base-c77cfrom
fix/ffmpeg-last-dropped-frame-release-c77c

Conversation

@Blackspirits

@Blackspirits Blackspirits commented Sep 13, 2026

Copy link
Copy Markdown
Owner

Summary

During seek handling, lastDropped holds one converted VideoFrame outside VideoFrameQueue while decoding advances from the key frame to the requested target.

If the video loop exits or throws before that frame is presented/returned, the frame becomes unreachable. VideoFrame owns unmanaged HGlobal memory and has no finalizer.

This current-base port:

  • moves lastDropped to the full video-loop lifetime;
  • returns it in finally;
  • preserves all normal paths that already null/return/push it;
  • remains safe after queue shutdown because VideoFrameQueue.Return disposes frames when closed.

Validation

  • based on upstream c77c4b428649ce7030e6cf218b4d7c384b955232
  • supersedes draft Release detached seek frame when the FFmpeg video loop exits #91 on the older hardware-decoder base
  • remains applicable after the new padded/aligned VideoFrame allocation; the allocation is larger now, so leaking it is no less relevant
  • diff is limited to FfmpegPlayer.cs
  • full solution restore passed
  • full solution build passed
  • full solution test suite passed on the first run
  • UI suite: 5,151 passed, 9 skipped, 0 failed (5,160 total)
  • retry step was not used
  • validation run: #34778788393

AI assistance: ChatGPT was used to revalidate unmanaged frame ownership after the BGRA buffer layout changed.

@Blackspirits Blackspirits left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent adversarial re-check on current upstream: lastDropped remains detached from VideoFrameQueue while seeking and owns unmanaged HGlobal memory. The enlarged padded/aligned VideoFrame allocation makes the leak more expensive, not less. Returning it from the video-loop finally is safe because VideoFrameQueue.Return disposes immediately after queue close. Full CI #34778788393 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.

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