Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Direct Video Plane Access for WebNN

Open
#961 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
8/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Active
Tech stack
javascript

Research direction

This is a design proposal for the WebNN specification, not a code change, and the maintainers have not settled the API shape. Read the proposal and its API sketch, which adds a copyVideoFrameTo method that takes a VideoFrame and copies its NV12 planes into an MLTensor and a GPUTexture. Done would mean agreed spec text and an accepted format list, which needs maintainer discussion before any drafting.

Written by the indexing model from the issue text.

Description

Video processing workloads need the original NV12 luma and chroma values: the model processes luma only, and its output replaces the source luma before recombination with chroma.

WebGPU's importExternalTexture exposes color-converted RGB, not raw planes. Recovering the original values requires inverting that conversion in a shader. I verified byte-exact recovery against VideoFrame.copyTo (which does not copy directly into an MLTensor) only after matching the browser's BT.709 transfer handling and its matrix coefficients to the default sRGB destination. Exact recovery therefore depends on browser-specific color handling.

Even if WebGPU fully specified the conversion, a sampling API would remain the wrong abstraction for raw plane access. Moreover, even with raw-plane access, WebGPU couldn't copy luma directly into the model’s MLTensor.

Proposal: Since luma is model input, let WebNN copy a VideoFrame's planes without color conversion into caller-provided tensor or texture destinations. WebNN can then select the most efficient device-specific transfer path, giving video-inference workloads direct plane access without shader-based color conversion workarounds.

API sketch (NV12):

const uvTexture = gpuDevice.createTexture({
  size: [W / 2, H / 2],
  format: 'rg8unorm',
  usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.TEXTURE_BINDING,
});
// WebNN may use `gpuDevice` for per-plane GPU copies
context.copyVideoFrameTo(frame, {
  y: yTensor,       // uint8 [H, W]
  uv: uvTexture,
});

Supported formats and API details are open for discussion. Feedback on the direction is welcome.

@huningxin @reillyeon @RafaelCintron @fdwr

Dominant language
Bikeshed
Stars
566
Forks
72
Avg merge
6d 5h
Merged PRs (30d)
1

Getting set up

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.

More from webmachinelearning/webnn

All issues in webmachinelearning/webnn

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.