w3c / w3c/webcodecs

Initialize Visible Rect, Orientation, and Display Size can produce a zero display dimension

Open
#926 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

CR Blocking
Dominant language
HTML
Stars
1.3k
Forks
194
Avg merge
1d 13h
Merged PRs (30d)
3

Description

In the https://w3c.github.io/webcodecs/#videoframe-initialize-visible-rect-orientation-and-display-size algorithm, steps 8.3–8.4 compute the display size by scaling from the source frame:

...
  3. Let |displayWidth| be frame's [[visible width]] * widthScale, rounded to the nearest integer.
  4. Let |displayHeight| be frame's [[visible height]] * heightScale, rounded to the nearest integer.
...

If the source frame has a very small display dimension relative to its visible size, the scaling and rounding can produce zero. For example:

  const f0 = new VideoFrame(canvas, { timestamp: 0, displayWidth: 1280, displayHeight: 1 })
  // f0: visibleRect = {0,0,300,150}, displaySize = {1280,1}

  const f1 = new VideoFrame(f0, { visibleRect: { width: 187, height: 40 } })
  // heightScale = 1/150 ≈ 0.00667
  // displayHeight = round(0.00667 * 40) = round(0.267) = 0  ← zero!

I think we should reject this, the resulting f1 has a display height of 0, which is an invalid state: [[display height]] of 0 is explicitly rejected by Validate VideoFrameInit ... when provided explicitly (step 4), but not when computed implicitly -- but our intent is clear.

We should just throw the same error.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the WebCodecs “Initialize Visible Rect, Orientation, and Display Size” algorithm, especially steps 8.3–8.4, and compare its implicit sizing with the “Validate VideoFrameInit” zero-dimension check. Confirm the expected behavior for the supplied VideoFrame example and update the specification so the result cannot retain a zero display dimension.

Written by the indexing model from the issue text.

Assessment

Tech stack
html
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.