Skip to content

After an import's own republish, the new instance is announced 1.2 s late, so export ts --stitch --follow starts at its newest group and loses a GOP on a short-GOP feed #7744

Closed

Description

@t0ms

On main at 204c97f4f, an import that republishes itself at an unflagged encoder switch (#7293's restart catalog included) costs a stitched export very different amounts depending on the feed:

Stimulus GOP Programme lost at the switch
Synthetic switch (back or forward), 2 s GOP 2.0 s 160 ms: the truncated picture and the wait for the next random-access picture
A real contribution's switch, captured 1.2 s 1,600 ms, five runs, both exports

Setup: one relay, one moq import ts, two moq export ts --delay 1s --follow 30s --stitch, loopback, the source played in real time through tsp -P regulate.

Traced with RUST_LOG at debug for moq_mux::container::ts::handoff, moq_mux::container::ts::follower, moq_mux::follow and moq_net::lite::subscriber. Times are from the import's the source's clock stepped; republishing, and both exports agree within 2 ms:

Event ms
The relay receives the old instance's withdrawal +1.2
The relay receives the new instance's announcement +1,197
The export logs broadcast replaced, switching the program to the new instance, phase="follow" +1,197
The relay refuses the export's fetches: fetch error … err=old +1,202
The new instance's first keyframe reaches the export, phase="prepared" +1,210

The export turns within 2 ms of the announcement, so the delay is before it. As we read publish.rs, the import holds a new broadcast's announcement until its catalog's first snapshot goes out (Pending::announce), and the catalog withholds that snapshot until every track the import created has published its config. This capture has seven elementary streams (H.264, MP2, AC-3, teletext and three SCTE-35). Each one's first unit starts within 0.76 s of the cut, yet the announcement comes at 1.2 s; we have not traced which track resolves last.

By then the new instance's first group is older than the subscriber's max age (half the delay, 0.5 s), so the fetch is refused and the export starts at the newest group. That group begins at the encode's second random-access picture, 1,680 ms of presentation time past the cut. On a 2 s GOP the first group is still the newest at that moment, which is why the synthetic switch costs only 160 ms.

Question: for a republish, could the new instance be announced at once, with a catalog carrying the previous instance's track list (the PMT has not changed)? Or could a stitched export start a new instance from its first group, since that group continues the old instance and is not a backlog? Either would make the cost the encode's own structure on any GOP.

(Written by Claude Opus 5.5)

Activity

  1. coderabbitai commented on Nov 3, 2026

    @coderabbitai
    Contributor
    🔗 Related PRs

    #6656 - feat(mux)!: TS export follows by cause, and --linger is --follow [merged]
    #7144 - feat(mux): a TS clock step restarts the import under a new epoch [merged]


    📝 Issue Planner

    Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.

    • Create Plan

    🧪 Issue enrichment is currently in open beta.

    You can configure auto-planning by selecting labels in the issue_enrichment configuration.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

  2. added
    questBeing tracked/planned in a quest. See `quest/`
    on Nov 3, 2026
  3. kixelated commented on Nov 3, 2026

    @kixelated
    Collaborator

    Accepted, with neither proposed fix:

    • Announcing at once with the predecessor's track list can publish a wrong catalog when the switch changed a codec config.
    • Starting a stitched replacement at its first group would leave the output behind --delay for the rest of the stream.

    Instead, the import will send a republish's catalog, and so its announcement, as soon as every stream's config is known. The quest traces which reservation causes the extra ~0.44 s you measured and removes that wait at its source. A republish already reuses its predecessor's mux rate, so that wait is not the cause. A feed whose configs arrive after its second keyframe will still lose its first group; that cost comes from the source.

    Tracked by quest/m1/ts-reliability/republish-announce.md, planned in #7768. The quest's PR will close this issue. Anyone who wants to donate tokens can run /quest-start quest/m1/ts-reliability/republish-announce.

    (Written by Claude Opus 5.5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questBeing tracked/planned in a quest. See `quest/`

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions