Repository navigation
test: Check that media playback returns the packet on EOF and read errors - #734
Merged
zackees merged 3 commits intoOct 14, 2026
Merged
Conversation
Member
|
Both failures are the same clang-format violation (the "Rust Tests" job fails in Line 139 is over the column limit. Fix: |
zackees
marked this pull request as ready for review
October 14, 2026 23:11
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.
Status: draft. Opened so upstream PR CI can run it.
Fork branch:
test/media-packet-eof-leak, head72d744e325bdbe940904f7c706412c655811da0d(one commit on upstream/master1a096bf43).Problem
7e0f28957("media-playback: Return the packet to the pool when a read fails", closes #463) fixed a packet leak inmp_media_next_packet(): a failedav_read_frame()(EOF, network timeout, abort, read error) returned without putting the packet back in the pool. That commit has no regression test of its own. The leak was only visible through LeakSanitizer and valgrind ontest_media_network_timeout, so nothing in the default test run fails if the fix is removed.Root cause
Not a new bug. This PR only adds the missing guard for the one-line fix at
shared/media-playback/media-playback/media.c:180-186(mp_media_free_packet(media, pkt)before returning a negativeav_read_frame()result).Fix
Tests only. No production code changes. Adds
test_media_packet_eof_leakwith two cases:eof_releases_packet: demuxes a small committed Matroska fixture through the productionmp_media_next_packet()until EOF, drains the packet pool, and checks that every packet the code allocated was freed.read_error_releases_packet: forcesAVERROR(EIO)fromav_read_frame()through a test-side wrapper and checks that the packet is back in the pool after the failed read.No libobs test hook, exported symbol or sleep. The test includes
media.cthe same waytest_svt_av1.cdoes. It is registered intest/cmocka/tests.d/test_media_packet_eof_leak.cmake, guarded byif(TARGET OBS::libobs AND TARGET FFmpeg::avformat).Fixture:
test/cmocka/data/media_packet_eof_leak.mkvis a 5 s, 16x16 ffv1 plus 48 kHz mono PCM clip (any small media file would do). Regenerate withffmpeg -f lavfi -i "color=c=black:s=16x16:r=10:d=5,format=yuv420p,geq=lum='5*N':cb=128:cr=128" -f lavfi -i "aevalsrc='500*(floor(t*10)+1)/32768':s=48000:d=5:c=mono" -c:v ffv1 -c:a pcm_s16le -t 5 out.mkv.test_media_network_timeout. Rejected because that test needs a network stack and only shows the leak under a sanitizer; this one fails in a plain run.Evidence
Local, macOS arm64, Debug, Xcode generator,
ENABLE_UNIT_TESTS=ON, frontend/scripting/browser/websocket OFF, no sanitizer.Passes on current master (fix present):
test_media_packet_eof_leakpasses 2/2 withENABLE_RUST_LIBOBS=OFFand withENABLE_RUST_LIBOBS=ON:Fails when the fix is reverted: with only the three added lines in
media.cfrom7e0f28957removed (git show 7e0f28957 -- shared/media-playback/media-playback/media.c | git apply -R), rebuilt and rerun in both OFF and ON, both cases fail:The revert was local only and has been restored; the pushed branch contains no production change.
Real-run evidence: not applicable. This adds a headless test; no full OBS session was run.
Fork CI: not run. Our self-hosted CI is down (see our note on #699), so this relies on upstream PR CI. Linux OFF/ON, GCC
-Werrorand LeakSanitizer have not been run.Compatibility & risk
No C API or ABI change and no production code change. The only added build surface is one cmocka target, one
tests.dfragment and a ~480 KB fixture. Local validation covers macOS arm64 only; Linux (GCC,-Werror, LeakSanitizer) was not run. The branch is based on1a096bf43; upstream/master has since advanced (including media-playback seek changes inaccf62aa1), so re-rungit merge-tree --write-tree upstream/master <head>and re-check the head before posting.Status
Status: draft. Opened so upstream PR CI can run it. The earlier RED+GREEN draft is obsolete because upstream merged the fix first.
How this was tested
test_media_packet_eof_leakon macOS arm64 Debug withENABLE_UNIT_TESTS=ON, forENABLE_RUST_LIBOBS=OFFandON. It passes on current master and fails (both cases) with the7e0f28957change reverted locally. No sanitizer was enabled locally.Thank you to the obs-rust maintainers and contributors for building this project in the open. In the American spirit of free expression and individual independence, and with the principle of judging contributions on their merit alone, this PR is a small piece of what independent people can build when they come together.