Skip to content

OffscreenCanvas #161

@fserb

Description

@fserb

Description

OffscreenCanvas allows for a faster graphics API that is detached from the Document. It also enables out-of-main-thread graphics API on WebWorkers. The support should include 2D, WebGL, and WebGPU support, both on main thread and on workers.

Rationale

OffscreenCanvas on Workers has a pretty strong developer demand. We can see tutorials and demos all over the place. Developers recognize and identify the multiple use cases: out of main thread rendering, and faster DOM-independent operations. OffscreenCanvas is also widely used inside Google.

On WASM codebases, it’s a necessary API to support out-of-main-thread rendering, which is common in games (with the WebGL context).

For 2D context, the extra performance (a lot of operations are faster on OffscreenCanvas due to its independence from the Document and style) and the ability to step outside the main thread processing (which is often a contentious resource), makes it a widely used feature.

Firefox tracking bug: OffscreenCanvas, 2D.
WebKit tracking bug: OffscreenCanvas.

Specification

WHATWG relevant spec:
https://html.spec.whatwg.org/multipage/canvas.html#the-offscreencanvas-interface

The spec needs some refreshment that we are ready to work on and would do it sooner, if this gets picked up by Interop: we need to clean up the old commit() spec that doesn’t exist anymore, and write a new rendering model for Workers.

Tests

Canvas2D: wpt/html/canvas/offscreen
WebGL: wpt/webgl
WebGPU: gpuweb/cts

The coverage for 2D is pretty broad, including WebWorker, transferred OffscreenCanvas, and main thread.
WebGL has a worker.js IDL test, but it seems to be missing on the repo.
WebGPU has only minor coverage on WPT. We would add at least some basic usage tests (not the full CTS).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions