Skip to content

fix(moqt): TrackReader が subgroup stream を並行に読むようにする - #355

Merged
yuki-uchida merged 2 commits into
masterfrom
fix/track-reader-concurrent-streams
Sep 8, 2026
Merged

fix(moqt): TrackReader が subgroup stream を並行に読むようにする#355
yuki-uchida merged 2 commits into
masterfrom
fix/track-reader-concurrent-streams

Conversation

@yuki-uchida

Copy link
Copy Markdown
Collaborator

概要

TrackReader は現在の subgroup stream が FIN するまで次の stream を読まず、前の stream を閉じずに次の group を開く publisher(ブラウザの wasm クライアント)や 1 group に複数 subgroup を使う publisher に対して、最初の stream 以降を読めなくなっていました。
全 stream を並行に読む実装に直しました。

やったこと

  • 受付タスクが factory から届く stream ごとに読み取りタスクを spawn し、有界チャネル(64 object)で next_object() に渡す(消費側の遅れは QUIC フロー制御として publisher に伝わる)
  • object は到着順に返し、順序保証は同一 subgroup 内のみ(draft-14 §10.4)。TrackObjectsubgroup_id(field なし → 0、FirstObjectIdDelta 型 → 最初の object id)を追加。1 stream の失敗は Err として返し、他の stream は読み続ける
  • publish 側のテストヘルパーを test_support.rs に共通化し、「前の stream を閉じずに次の group を開く」「同一 group の 2 subgroup」「FirstObjectIdDelta の解決」「status object の読み飛ばしと stream close 後の継続」の 4 テストを追加

やらないこと

影響範囲

  • TrackObject にフィールドが増える(struct literal で組んでいる箇所はワークスペース内にない)。TrackReader::new はタスクを spawn するため tokio runtime 上で呼ぶ必要がある

テスト

  • 追加 4 件を含む cargo test -p moqt -p relay 全通過(新テストは 5 回連続で安定)。cargo clippy --workspace --all-targets --all-features -- -D warnings / cargo fmt --all -- --check 警告なし
  • 修正前の実装に新テストは流していない(subgroup_id がなくコンパイル不可)

accept_publish and the data-receiver helper move from the TrackWriter
tests to modules/test_support.rs so the TrackReader tests can publish
over the same in-process DUAL session.
…Reader

TrackReader read one subgroup stream until FIN before taking the next
stream from the factory. MoQT delivers subgroups on independent uni
streams that overlap in time, so a publisher that opens the next group
before closing the previous one (the browser wasm client only closes a
stream when it sends EndOfGroup), or that uses several subgroups per
group, stalled the reader after the first stream while later objects sat
in the factory's channel.

The reader now runs an accept task that spawns one reader task per
subgroup stream; readers feed a bounded channel so a slow consumer
applies QUIC flow control to the publisher. Objects are yielded in
arrival order, ordered only within a subgroup as the draft guarantees,
and TrackObject gains the resolved subgroup_id so consumers can order
across subgroups themselves. A failure in one stream is reported as Err
while the other streams keep being read.
@yuki-uchida
yuki-uchida merged commit eb29a75 into master Sep 8, 2026
15 checks passed
@yuki-uchida
yuki-uchida deleted the fix/track-reader-concurrent-streams branch September 8, 2026 07:35
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