Repository navigation
quest: container export ends cleanly when its broadcast closes #8064
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3a865da
quest: container export ends cleanly when its broadcast closes
kixelated cf33eb2
quest: export-close fixes ExportSource for every container, and both …
kixelated b829b7c
quest: export-close covers the source's own broadcast and the catalog…
kixelated 8876960
quest: export-close ends at the catalog broadcast's end, and covers p…
kixelated File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # [M] Container export ends cleanly when its broadcast closes | ||
|
|
||
| ## Goal | ||
|
|
||
| A container export (FLV, MKV, TS, fMP4, or MP4) whose broadcast instance | ||
| closes in an orderly way returns `None`, as each one's docs promise ("`None` | ||
| when the broadcast ends"), after the media it already read, whichever of the | ||
| track's shutdown error and the instance's close arrives first. A failure that | ||
| is no orderly shutdown, such as malformed media or a failed transport, still | ||
| fails the export. | ||
|
|
||
| ## Plan | ||
|
|
||
| Decided 2026-11-06 (maintainer, on moq-dev/studio's /quest-plan): m3, since | ||
| the studio is a named consumer that is not urgent. | ||
|
|
||
| A broadcast's orderly end reaches an export by three paths, and each must | ||
| end it cleanly whichever signal comes first: | ||
|
|
||
| - **Renditions on the source's own broadcast**, the studio's case. | ||
| `ExportSource::poll_track` (`rs/moq-mux/src/container/source.rs`) sets | ||
| `instance` only for a sibling (`sibling: *path != self.path` in | ||
| `rs/moq-mux/src/source.rs`), so these never consult `poll_closed` and any | ||
| shutdown-class error fails the export. | ||
| - **Sibling renditions.** `poll_track` ends one on a shutdown-class error | ||
| (`Cancel`, `Closed`, `GoingAway`, a session cancel) only if | ||
| `instance.poll_closed` is already ready. | ||
| - **The catalog track**, which every exporter polls before its media (for | ||
| fMP4, `catalog.poll_next(waiter)?` in `container/fmp4/export.rs`). The | ||
| catalog consumer returns `Cancel` when its track is lost | ||
| (`a_lost_track_is_a_transport_error` in `catalog/hang/consumer.rs`), so an | ||
| orderly leave can fail the export there before any media is read. | ||
|
|
||
| Fix them in the shared source and the catalog consumer, so every exporter | ||
| gets it; `mp4::Export` ends when the fMP4 export under it does. The | ||
| catalog-owning broadcast's end is the export's end: a sibling still | ||
| publishing stops being read then, rather than keeping the export open. | ||
| Buffered media still drains before `None`. Prove it through whole exports, where the | ||
| catalog's and the media's shutdown arrive in both orders against the | ||
| instance's close. | ||
|
|
||
| Open: how the error-first order resolves. Holding a shutdown-class error | ||
| until the instance closes cannot be the whole answer: nothing bounds that | ||
| wait if the instance stays live, and no timeout may decide it. Prefer fixing | ||
| the order at its source, so an instance's end is visible before its tracks | ||
| (catalog included) report shutdown, locally and over the wire, if moq-net can | ||
| promise that; otherwise find what else tells the two apart. Reproduce both | ||
| orders first. | ||
|
|
||
| A failure that is no orderly shutdown (malformed media, a protocol violation, | ||
| producers that went away unfinished) still fails the export even once the | ||
| instance has gone, whether the sibling's subscription had resolved | ||
| (`a_sibling_failure_outlives_its_instance` pins this) or was still pending, | ||
| which no test covers yet. `a_remote_sibling_ends_with_its_instance` covers | ||
| the remote case. | ||
|
|
||
| Consumer: the studio's per-guest recorder | ||
| ([moq-dev/studio#65](https://github.com/moq-dev/studio/pull/65)) treats an | ||
| export error as the guest leaving only if the broadcast already reads as | ||
| closed (`is_closed` in `rs/moq-studio/src/record.rs`), so a departure whose | ||
| track error arrives first marks the recording failed. The studio drops that | ||
| check when it next bumps `moq`. | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: moq-dev/moq
Length of output: 15615
Script executed:
Repository: moq-dev/moq
Length of output: 42135
Script executed:
Repository: moq-dev/moq
Length of output: 36161
Script executed:
Repository: moq-dev/moq
Length of output: 39755
Script executed:
Repository: moq-dev/moq
Length of output: 15984
Cover a live sibling when the primary broadcast closes.
If the primary closes while a sibling stays live, fMP4 can keep reading sibling frames after catalog EOF instead of returning
None. Require a primary-close signal to stop sibling reads, and add a whole-export test that keeps the sibling publishing after primary closure.