Skip to content

fix(media): count grid ordinals as skipped when the sample stream ends early - #914

Merged
JArmandoAnaya merged 2 commits into
mainfrom
fix/850-video-import-skipped
Oct 12, 2026
Merged

JArmandoAnaya merged 2 commits into
mainfrom
fix/850-video-import-skipped

Conversation

@JArmandoAnaya

@JArmandoAnaya JArmandoAnaya commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #850.

materialize() in the media worker broke out of its loop when the decoder's sample generator ended before the grid did, so every remaining ordinal was in neither the materialized frames nor skipped.

  • The decode loop moves into a pure core helper, walkGrid() (frontend/media/src/grid-walk.ts), which records each remaining ordinal as skipped on an early end, unless the run was cancelled.
  • VideoImportResult.skipped now documents materialized + skipped.length === expected for an uncancelled run.
  • vitest coverage for null samples, early end, empty stream and both cancel paths; each case was mutation-checked.
  • A Chromium spec drives real null samples through materialize() (a clip cut mid-GOP, so the leading frames have no key frame).

Scope note: with mediabunny 1.61.3 the sample stream emits one item per requested timestamp and ends early only after return() (a cancel), so the early-end path is not reachable in an uncancelled run today. The fix is protection against a future change, and only the walkGrid unit tests exercise it. The browser spec covers the null-sample path, which the old code already handled, so it passes on both old and new code.

Verified locally: media vitest 24/24, lint, build, Chromium suite 24/24.

…s early (#850)

The worker's materialize() loop broke out when the decoder's sample
generator finished before the grid did, so every remaining ordinal was in
neither the materialized frames nor `skipped`. The loop now lives in a
pure core helper, walkGrid(), which records each remaining ordinal as
skipped unless the run was cancelled, and computes the ordinal in one
place for visited, null and padded positions.

walkGrid has vitest coverage for null samples, an early end, an empty
stream and both cancel paths. The doc on VideoImportResult.skipped now
states materialized + skipped.length === expected for an uncancelled run.
#850)

Every browser case asserted an empty `skipped`, so the null-sample path was
covered only by the walkGrid unit tests. A VP8 clip cut mid-GOP, built in the
page with mediabunny, leaves three grid ordinals with no key frame to decode
from; the spec asserts they land in `skipped` and that materialized plus
skipped equals expected.
@JArmandoAnaya
JArmandoAnaya merged commit 8d162b8 into main Oct 12, 2026
31 checks passed
@JArmandoAnaya
JArmandoAnaya deleted the fix/850-video-import-skipped branch October 12, 2026 08:21
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.

VideoImportResult.skipped under-reports when decoding ends before the grid does

1 participant