Skip to content

fix!: refuse nonempty field-less sample runs - #248

Closed
kixelated wants to merge 1 commit into
mainfrom
codex/refuse-fieldless-truns
Closed

kixelated wants to merge 1 commit into
mainfrom
codex/refuse-fieldless-truns

Conversation

@kixelated

@kixelated kixelated commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Problem

A field-less trun expands its sample count into a Vec without consuming per-sample bytes. The 4096-entry cap applies per run, so a roughly 16 KB moof with 1000 runs still materializes 4.1 million entries before media validation. This is the parser-side gap tracked by moq-dev/moq#6864.

Approach

Refuse nonempty runs without per-sample fields on decode and encode, including first-sample-flags-only runs. Remove the arbitrary 4096 cap and allocate ordinary entries only as their fields are read. Empty runs remain supported.

Impact

  • Breaking input/output support change: valid nonempty runs that inherit every field from tfhd/trex now return Error::Unsupported.
  • Migration: emit at least one per-sample field with its resolved value, or choose a counted representation before landing this proposal.
  • No Rust signature changes and no change to supported MP4 field encoding.

Alternatives

Replace Trun.entries: Vec<TrunEntry> with a representation that stores repeated default entries as a count. That preserves field-less files but changes downstream APIs. Another count cap does not bound expansion across many runs.

Validation

Both new refusal tests fail on the original parser. Local just check passed, including all-feature compilation, Clippy with warnings denied, and formatting (cargo-shear reported existing unused-file warnings).

CI passed 380 tests and failed the AV1, BBB, and ESDS fixture tests because they contain valid field-less runs. These assertions remain intact. The local all-feature test run was cancelled while waiting for the host load gate after CI supplied this decisive result.

Decisions needed

The fixture failures show that field-less runs are used by real supported inputs. Recommendation: replace the refusal proposal with a counted representation and migrate consumers together. This draft makes the narrower refusal option and its compatibility cost reviewable; do not merge it as-is or weaken the fixture tests to accept the regression. The MoQ resolver is independently useful, but fully bounding parsing still needs this representation change, a release, and adoption.

(Written by GPT-6)

Co-Authored-By: GPT-6 <noreply@openai.com>
@kixelated

Copy link
Copy Markdown
Owner Author

Superseded by #254, which stores field-less runs as a count instead of refusing them, per the 2026-10-26 maintainer decision. The AV1, BBB, and ESDS fixtures keep passing there. Recommend closing this one once #254 lands; I've left it open for the maintainer.

(Written by Claude Opus 5.5)

@kixelated

Copy link
Copy Markdown
Owner Author

Closing in favor of kixelated/mp4-atom#254, now merged. It stores field-less runs as a count rather than refusing them, so the AV1, BBB, and ESDS fixtures keep decoding.

(Written by Claude Opus 5.5)

@kixelated kixelated closed this Oct 28, 2026
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