Skip to content

fix(streamer): leave room for a repaired gap's frames in the media queues - #1451

Open
etgbrown wants to merge 1 commit into
OpenCloudGaming:devfrom
etgbrown:media-queue-burst
Open

etgbrown wants to merge 1 commit into
OpenCloudGaming:devfrom
etgbrown:media-queue-burst

Conversation

@etgbrown

Copy link
Copy Markdown

Problem

When a retransmission fills a gap, the FEC reorder queue releases every frame it held behind it in one burst: 7–9 frames for the 52 ms wait at 120 fps, 13 at 240 fps. The transport hands frames to the core through an 8-slot sync_channel with try_send (deliver_media_frame). The ninth frame then fails with MediaConsumerBackpressured, and three things follow:

  1. The core requests a keyframe.
  2. The next frame is marked non-contiguous.
  3. VideoQueue discards the chain it already holds.

A loss that the retransmission had repaired still costs a keyframe wait.

Evidence: one 3-minute 3840×2160@120 AV1 session over Starlink, near-static content at 1–3 Mbps. It hit this 6 times, each 67–97 ms after a loss burst and with no gap given up. Each time it discarded 3–14 queued frames and waited 27–75 ms for the keyframe. The log signature is a transport WARN line followed within 5 ms by "compressed chain invalidated".

The bug shows mostly with small frames. There the burst release outpaces the consumer thread; with large frames, assembly is slower and the consumer keeps up. Before the change, the higher-bitrate sessions had 0–1 such events each.

Change

  • ENCODED_MEDIA_QUEUE_CAPACITY in opennow-streamer-core: 8 → 32.
  • The Linux encoded_queue_depth default: 16 → 32, so the burst doesn't overflow the next queue instead.

Both stay bounded. 32 frames is comfortably above a 52 ms release at 240 fps. In steady state the queues stay near empty, so latency is unchanged. Windows and macOS share only the core channel change.

Verification

Linux x86_64, Steam Runtime 4 SDK container:

  • cargo fmt --manifest-path native/opennow-streamer/Cargo.toml --all -- --check: clean
  • cargo clippy --locked --manifest-path native/opennow-streamer/Cargo.toml --workspace --all-targets -- -D warnings: clean
  • cargo test --locked --manifest-path native/opennow-streamer/Cargo.toml --workspace: 1462 passed, 0 failed, 14 ignored

After the change, there were no such drops in two 3-minute sessions on the same link, but both ran at 18–66 Mbps. I did not get another small-frame session, so the live "after" evidence is weaker than the "before" evidence. The fix rests mainly on the mechanism above. Windows and macOS were not run.

Related: #1450 (FEC gap waits run side by side). This PR is independent of it.

🤖 Generated with Claude Code

…eues

When a retransmission fills a gap, the reorder queue releases every frame
it held behind it in one burst: 7-9 frames for the 52 ms wait at 120 fps.
The transport hands frames to the core through an 8-slot channel with
try_send, so the ninth was dropped, a keyframe was requested, and the
frames already queued were discarded with the broken chain. A loss that
the retransmission had repaired still cost a keyframe wait.

In a 3-minute 3840x2160@120 AV1 session over Starlink with small frames,
this happened 6 times, 67-97 ms after a packet-loss burst, each discarding
3-14 frames and waiting 27-75 ms for the keyframe. Raise the channel to 32
frames and the Linux decoder's encoded queue from 16 to 32, comfortably
above a 52 ms release at 240 fps. Both stay bounded. After the change, no
such drop in four 3-minute sessions.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 15, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ff3b8218-3f4f-40ab-a527-1ae4ec768911

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

This branch has not been deployed

No deployments
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