Repository navigation
fix(video): load the H.264 bootstrap cache without statx - #10
Producdevity merged 3 commits into
Conversation
loadBootstrap sized the cache with File.getEndPos(), which goes through File.stat() and statx. Kernel 4.9 has no statx, so on H700 devices the call failed, the error was swallowed and the saved SPS/PPS were never loaded, although they were written after every session. Read the file into a buffer one byte larger than the limit instead, which also detects oversized files, and log read failures in debug mode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughThe video pipeline now uses a dedicated cache reader with a 4104-byte capacity. The reader detects oversized files without calling ChangesBootstrap Cache Loading
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
All reported issues were addressed across 1 file
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
An oversized cache was rejected without a message, so in debug logs it looked the same as a missing one. Log it like the other skipped-cache cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for tracking this down and testing it on muOS. I added regression tests, trimmed the comments a bit (claude loves to write novels in comments 😂) |
Targets
masterbecause the bug is there:loadBootstraphas usedgetEndPos()since the early commits, and the GeForce NOW branch carries the same code. The branch name follows thefix/<kebab-case>pattern of yourfix/gfn-atomics-*branch, and the commit uses the conventional prefixes from #2-#4. The change is independent of #8 and #9.What does this change?
loadBootstrapinsrc/media/video/video_pipeline.zigsized the H.264 parameter-set cache withfile.getEndPos(). That goes throughFile.stat(), which usesstatx, andstatxonly exists from Linux 4.11. On the 4.9 kernels H700 devices ship, the call fails,catch return 0swallows the error, and the cache is never loaded, even thoughpersistBootstrapwrites it after every session. This is the limitationsrc/platform/linux/stat_compat.zigalready documents.The fix reads the file into a buffer one byte larger than
bootstrap_capacityand uses the byte count as the size. Empty and oversized files are rejected exactly as before, and nostatcall is involved. Read errors are now logged in debug mode, like the existing open errors.How did you test it?
On an Anbernic RG35XX-H (H700, muOS, kernel
4.9.170):Proving the bug. A small static aarch64 probe on the device, against the real cache file:
Debug logs from earlier streaming sessions never contain
H.264 bootstrap loaded, althoughh264-parameter-sets.bin(42 bytes, starting00 00 00 01 67) was present.With the fix (built on the GeForce NOW branch, where I can stream), one GFN session:
The whole cycle works: the cache is loaded at startup, rewritten after the session, and loaded again. The stream showed 0 decode errors, 0 corruption and 1 keyframe in the first second.
On
master,tools/zig.sh build testandtools/zig.sh build fmt-checkpass.I could not run
build releaseonmasterin my environment. Without the pkg-config isolation from3724080(onfeat/geforce-now), host headers leak into the SDL2 dependency build (L_tmpnamerrors instdio.h). That is unrelated to this change. Onfeat/geforce-now, the same change builds for release and has 0__aarch64_outline-atomics imports.Not measured: how much this speeds up the first picture. Without the cache the decoder waits for the server's parameter sets. In one session the first second presented 55 of 57 decoded frames, against 39 of 57 in an earlier session without the cache. That is a single comparison, not a benchmark. Xbox Cloud uses the same pipeline, but I have not tested it.
video_pipeline.zighas no host unit tests and needs FFmpeg and SDL headers, so I didn't add new build wiring for a one-function fix. I'm happy to add a test if you'd prefer a particular setup.AI disclosure
Per CONTRIBUTING: this was found and written with AI assistance (Claude). I reviewed the diff and verified the bug and the fix on hardware myself.
🤖 Generated with Claude Code
Summary by cubic
Fixes H.264 bootstrap cache loading on kernels older than 4.11, where
File.getEndPos()failed because it relies onstatx. The cache is now sized by reading the file directly, so saved SPS/PPS data loads correctly on H700 devices running kernel 4.9.bootstrap_cache.zig, covered by unit tests, including one that blocksstatxvia seccomp to prove the fix on kernel 4.9.Written for commit 85bacb1. Summary will update on new commits.
Summary by CodeRabbit