Skip to content

moq-transcode: run() can't bootstrap from a demand-gated source that doesn't advertise its geometry #2788

Closed

Description

@kixelated

moq_transcode::run can't bootstrap from a publisher that only encodes while watched, unless that publisher advertises its geometry before encoding anything.

The cycle:

  1. run waits for a catalog snapshot with a usable video rendition, and only subscribes to the source video track afterwards (feed::Feed::new is constructed after the choose_source loop, and even then the subscribe happens lazily in Feed::listen, when a rung is actually demanded).
  2. resolve_rungs needs coded_width/coded_height to size the ladder.
  3. A demand-gated publisher (moq_video::encode::publish_capture, moq-boy) doesn't open its encoder until something subscribes to its video track.

So when the transcoder is the intended consumer, nobody subscribes, no keyframe is produced, the geometry never arrives, and run waits forever. This is the same shape as #2757: a consumer that needs the catalog first, and a publisher that won't produce until demanded.

#2768 fixes the case where the publisher's geometry is known up front (moq capture --width 1920 --height 1080 now advertises it before the camera opens, so the ladder resolves, a viewer subscribes to a rung, and only then does the camera open). The case that remains stuck is a publisher that advertises its codec but not its picture, which is what capture does when you don't pin a size, because a camera's negotiated mode isn't knowable without opening it.

Before #2768 this scenario hung too (capture published no video rendition at all until its first keyframe), so this isn't a regression from that PR. It's the part of the deadlock that publishing the rendition earlier doesn't reach.

Fix direction: give run a bootstrap path that can create demand on the source before it has a ladder, so the source is allowed to produce the keyframe that reveals its geometry. Subscribing to the source video track up front (and dropping it if no rung is ever wanted) would do it, at the cost of opening the camera to learn its mode. Alternatively the ladder could resolve lazily, per rung, once the feed yields its first decoded frame.

Found by Codex while reviewing #2768.

(written by Opus 5)

Activity

  1. coderabbitai commented on Aug 12, 2026

    @coderabbitai
    Contributor
    🔗 Related PRs

    #2266 - fix(moq-hls): reconcile catalog renditions [merged]
    #2439 - fix!: correct catalog, timeline, token, and teardown contracts found in API review [merged]
    #2608 - feat(bindings): publish raw video with a native encoder [merged]
    #2630 - fix!: reject a catalog whose broadcast reference escapes the root [merged]
    #2768 - feat(moq-video): advertise the catalog rendition before the first keyframe [open]


    📝 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. kixelated commented on Aug 12, 2026

    @kixelated
    CollaboratorAuthor

    Correction. The claim below that "before #2768 this scenario hung too" is wrong, and so is the framing of this issue as pre-existing.

    origin/main's capture_loop opens the camera regardless of demand until its first keyframe, and says so:

    // The catalog video rendition only appears once a frame has been encoded (the
    // importer reads the SPS). Until then we capture regardless of demand so a
    // catalog-driven subscriber can discover the track and trigger `used()`.
    // After that we release the camera while unwatched.
    let mut catalog_ready = false;

    That pre-roll is what produces the geometry a transcoder needs, unprompted. So native capture plus transcode does bootstrap on main, and the deadlock described here is introduced by removing the pre-roll, not uncovered by it. Thanks to Codex for catching the bad reasoning.

    The underlying ordering problem in run() is still real and still worth fixing (it's what makes the pre-roll load-bearing), but it is a blocker for making capture demand-gated rather than an independent defect. #2768 is being reworked accordingly.

    (written by Opus 5)

  3. kixelated commented on Sep 2, 2026

    @kixelated
    CollaboratorAuthor

    Retiring the quest for this in #3347 and closing with it. #2768 landed in its reworked shape: publish_capture opens the camera once at startup to probe the mode and advertises an exact rendition before any demand, so the rendition choose_source waits on (codec plus dimensions) exists from the first catalog snapshot and run() bootstraps. The "codec but no picture" rendition this issue describes no longer occurs in tree. The remaining resize-between-opens case is #2799.

    (written by Claude Fable 5.1)

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions