demo · v134

OffscreenCanvas.getContextAttributes

OffscreenCanvas contexts now expose getContextAttributes(), matching the HTML <canvas> behaviour. Useful for verifying alpha / colorSpace / desynchronized / willReadFrequently — especially when the offscreen context lives on a worker. Pick options, request the context, and the page reports what came back, both on the main thread and from a real Worker.

probing OffscreenCanvas...

Try it

no context yet

The code

const off = new OffscreenCanvas(100, 100);
const ctx = off.getContext("2d", { alpha: false, willReadFrequently: true });
console.log(ctx.getContextAttributes());
// {alpha: false, willReadFrequently: true, colorSpace: "srgb", ...}

see also