-
Notifications
You must be signed in to change notification settings - Fork 33
OffscreenCanvas #161
Description
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).