Skip to main content

WebAssembly, WebCodecs & WebGPU

1. W3C WebAssembly Standards (TR)

The W3C TR WebAssembly filter lists six documents covering three specs (each in v1 and v2):

SpecStatus
WebAssembly Core SpecificationStandard
WebAssembly JavaScript InterfaceStandard
WebAssembly Web APIStandard

These cover the binary format, JS bindings, and streaming compilation only — not media or graphics APIs.


2. WebGPU Status

ItemDetail
Specw3.org/TR/webgpu
StatusCandidate Recommendation Draft (CRD), last updated May 2026
Shading language (WGSL)Also CRD as of May 2026
Browser supportAll major browsers (Chrome, Safari, Firefox); >84% globally
Governing bodyW3C GPU for the Web Working Group

Note: WebGL is governed by Khronos Group, not W3C. WebGPU is the modern W3C-standardized successor for GPU access on the web.


3. Video Frame Rendering with WebGPU

WebGPU is well-suited for video frame rendering, especially when combined with WebCodecs:

<video> or VideoDecoder (WebCodecs)

VideoFrame

importExternalTexture() ← zero-copy GPU import

Render Pipeline (WGSL shaders)

GPUCanvasContext (<canvas>)

Key advantage: importExternalTexture()

  • Avoids CPU-side pixel copying by importing decoded frames directly to GPU memory
  • Enables full shader-based post-processing in the same pass:
    • Color space conversion, tone mapping (HDR)
    • Chroma keying / green screen
    • Real-time filters, overlays, multi-video compositing

WebGPU vs WebGL for video

FeatureWebGLWebGPU
Video texture importtexImage2D(video)importExternalTexture()
Zero-copy pathLimitedYes
Compute shaders on framesNoYes
WebAssembly integrationIndirectDesigned for it

4. WebAssembly Direct Access to WebGPU

Short answer: Not yet — JavaScript is still required as the bridge.

Current reality

C++ / Rust code
↓ (compiled by Emscripten / wasm-bindgen)
WebAssembly module
↓ (JS glue code, auto-generated)
JavaScript WebGPU API

GPU

The Wasm module calls WebGPU through auto-generated JS bindings — not natively.

Active proposals moving toward direct access

ProposalPurpose
WebIDL Bindings (→ Component Model)Wasm calling Web APIs without JS glue overhead
Component ModelStructured interface types between Wasm and host
Memory64Removes 4GB linear memory limit for large GPU workloads
WASIFuture extensions may include GPU access

5. WebIDL Bindings Proposal: Where It Went

The proposal evolved through a chain of repos before being absorbed:

StageRepoStatus
WebIDL Bindings (original)github.com/WebAssembly/webidl-bindingsArchived
Interface Typesgithub.com/WebAssembly/interface-typesArchived
Component Model (current)github.com/WebAssembly/component-modelActive, Phase 1
Direct Web API access from WasmNo formal proposal yetUnder discussion

Follow today: github.com/WebAssembly/component-model and component-model.bytecodealliance.org

Component Model phase outlook

  • Expected to advance to Phase 2 after WASI 0.3 release (released Feb 2026)
  • Phase 5 (standard) likely after WASI 1.0, expected late 2026 / early 2027

6. WebCodecs + WebAssembly Interop

WebCodecs spec status

ItemDetail
Specw3.org/TR/webcodecs
Governing bodyW3C Media Working Group
Browser supportChrome, Edge (full); Firefox, Safari (improving throughout 2025–2026)

Current interop path (always via JS)

VideoDecoder (WebCodecs, JS)
↓ output callback
VideoFrame (JS object)
↓ videoFrame.copyTo(arrayBuffer) ← copy #1
ArrayBuffer (JS memory)
↓ write into Wasm linear memory
WebAssembly processes pixels
↓ write result back to ArrayBuffer
new VideoFrame(buffer) ← copy #2

VideoEncoder / Canvas / WebGPU

The core problem: mandatory double copy

  • VideoFrame.copyTo() always copies — no mechanism to transfer ownership
  • new VideoFrame(buffer) creates a second copy
  • Full HD frame copy cost: ~10–20ms on desktop, ~40–60ms on mobile
  • Frame budget: only 40ms at 25fps, 20ms at 50fps — very tight

What's being discussed (no formal proposal yet)

IdeaStatus
Memory mapping for WasmDiscussed in WICG reducing-memory-copies repo; not yet a formal proposal
Zero-copy via WebGPUPartial: importExternalTexture() avoids CPU copy when going GPU→GPU
SharedArrayBufferAvailable now; enables parallel worker processing but doesn't eliminate copies

7. Practical Recommendations (2026)

GoalBest path today
Video decoding + GPU renderingWebCodecs → importExternalTexture() → WebGPU
CPU-side frame processing in WasmWebCodecs → copyTo() → Wasm linear memory (via SharedArrayBuffer for parallelism)
Avoid shipping codec in WasmUse WebCodecs (3× faster than ffmpeg.wasm in benchmarks)
Follow zero-copy Wasm progressWatch github.com/WebAssembly/component-model and W3C CG meetings

ResourceURL
W3C WebAssembly TR filterhttps://www.w3.org/TR/?filter-tr-name=WebAssembly
WebGPU spechttps://www.w3.org/TR/webgpu/
WebCodecs spechttps://www.w3.org/TR/webcodecs/
Component Model repohttps://github.com/WebAssembly/component-model
Component Model docshttps://component-model.bytecodealliance.org/
WICG reducing-memory-copieshttps://github.com/WICG/reducing-memory-copies
WebGL (Khronos)https://registry.khronos.org/webgl/specs/latest/