Skip to content

fix(sender): preserve encoded frame references under backpressure - #194

Merged
swellweb merged 1 commit into
swellweb:maint-3.5from
Betafer:codex/fix-video-reference-budget-v3.5-20260912
Sep 14, 2026
Merged

swellweb merged 1 commit into
swellweb:maint-3.5from
Betafer:codex/fix-video-reference-budget-v3.5-20260912

Conversation

@Betafer

@Betafer Betafer commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Why

Thanks again for TargetBridge and for the guidance to send small, tested follow-ups. While using a headless Mac mini with an iMac as its display, we reproduced HEVC missing-reference errors when the network queue briefly filled.

handleEncoded currently drops non-keyframes after VideoToolbox has encoded them. Those frames can be references for later frames, so sending the rest of the sequence can leave the Receiver unable to decode until a new keyframe.

Focused change

  • Reserve a shared budget for pending network packets plus in-flight encoder frames before encoding, on both capture paths.
  • Keep every encoded frame, preserving the reference chain.
  • Bound the queue even when transport acknowledgements are delayed; invalid experimental limits are clamped.
  • No protocol, codec, bitrate, renderer or Receiver changes.

Based directly on current maint-3.5 (fb45b5f); two files only. This is independent of the monitor-mode/onboarding drafts.

Validation

  • ruby TargetBridge-Sender/scripts/test_video_queue_budget.rb passes on Apple Silicon. It executes the production budget policy and checks both call sites, bounded reservations, delayed acknowledgements, encoding completion/failure and invalid limits.
  • The exact rebased Sender source builds with Xcode for macOS arm64.
  • Before/after installed builds: headless Mac mini M4 → iMac 24 M4, HEVC 4096×2304, same Wi-Fi path and preset. Two baseline sessions produced missing-reference errors; the corrected sessions produced none, with droppedPost=0 and sampled pending+in-flight counts within the configured budget.
  • This is a correctness/backpressure result, not an optical 60-FPS claim. Existing log intervals can include delayed bursts. H.264 uses the same policy but was not separately hardware-benchmarked in this run; raw NV12 is unchanged.

No personal certificates, logs containing desktop content, credentials, network configuration or generated build stamps are included.

@swellweb
swellweb merged commit 7532d62 into swellweb:maint-3.5 Sep 14, 2026
4 checks passed
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.

2 participants