Repository navigation
fix(receiver): present only the newest decoded frame under backlog - #230
Merged
swellweb merged 1 commit intoNov 12, 2026
Merged
Conversation
Decode every VideoToolbox frame (the HEVC reference chain must stay intact) but upload and present only the newest one, so a backlog after a keyframe burst or a slow present is skipped instead of being rendered one 22 MB 5K upload at a time. - Retain the newest CVPixelBuffer, release any older pending one; present once per main-loop pass; drop the pending frame on disconnect and exit. - Bound each socket drain pass to 8 ms (TB_DRAIN_BUDGET_MS) so presenting is never starved. - Request an 8 MB socket receive buffer, falling back to 6 MB then 4 MB. - FPS log reports decoded and skipped-stale counts when skipping happens. Software/VAAPI decode and the raw NV12 passthrough path are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 9, 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.
Problem
The receiver runs decode, the 5K NV12 upload (
SDL_UpdateNVTexture, ~22 MB per frame) and present on one thread, strictly in order. When one frame runs long (most often a keyframe), later frames queue up and the receiver renders that backlog one frame at a time. It never catches up, so the stall spreads and TCP back-pressure makes the sender drop frames too. At 5K 60 this shows up as uneven frame rate and blocky artifacts.Change
CVPixelBufferRefthrough a new optionaltb_dec_set_pixbuf_cb()hook. Every frame is still decoded, because the HEVC reference chain must stay intact.main.ckeeps only the newest decoded frame (retained), releasing any older one, and presents it once per main-loop pass. The pending frame is dropped on disconnect and at exit.TB_DRAIN_BUDGET_MS) so presenting is never starved.N fps (decoded D, skipped S stale)when skipping happens.Software/VAAPI decode and the raw NV12 passthrough (
handle_raw_frame) are unchanged.Testing
Hardware: MacBook Air M5 (macOS 27.0.1) → iMac18,3 27" 5K 2017, Radeon Pro, macOS Ventura 13.7.8, Thunderbolt Bridge (40 Gb/s link). The receiver was cross-built x86_64 against the dylibs bundled in the official 3.6.0 receiver.
A/B at the 5K 60 profile, 120 s per scenario plus 5 reconnects. Note: the patched arm also ran the sender change from the companion PR, so the frame-rate and bitrate numbers below are for both together. The main-loop numbers are receiver-only.
drain_socket: one 6,371-frame FPS bucket over 131 s (0.02 loop ticks/s)iMac health while streaming the patched build: CPU 66 °C, GPU 60 °C, no throttling (
CPU_Speed_Limit100), 78% memory free, no swap.CI-equivalent checks on
maint-3.6+ this commit:make test: net parser 67, input queue 562, idle watchdog 12, receiver profile 13, status layout 43, all passing. Full receiver build clean.It has been running as my daily receiver since 2026-10-30.
Credits
Patch prepared by Ziyad Asghar. Applied to
maint-3.6, built, hardware A/B-tested and measured with Claude Opus 5.5 (Anthropic), credited via theCo-Authored-Bytrailer.I know maintainer time is limited at the moment, so I kept this small and self-contained. Happy to adjust anything.