The HTMLCanvasElement.transferControlToOffscreen()
method transfers control to an OffscreenCanvas
object, either on the main thread or on a worker.
The HTMLCanvasElement.transferControlToOffscreen()
method transfers control to an OffscreenCanvas
object, either on the main thread or on a worker.
js
transferControlToOffscreen()
None.
An OffscreenCanvas
object.
The following example shows how to transfer control to an OffscreenCanvas
object on the main thread.
js
const htmlCanvas = document.createElement("canvas"); const offscreen = htmlCanvas.transferControlToOffscreen(); const gl = offscreen.getContext("webgl"); // Some drawing using the gl context…
The following example shows how to transfer control to an OffscreenCanvas
object on a worker.
js
const offscreen = document.querySelector("canvas").transferControlToOffscreen(); const worker = new Worker("myworkerurl.js"); worker.postMessage({ canvas: offscreen }, [offscreen]);
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
transferControlToOffscreen |
69 | 79 | 105 | No | 56 | 16.4 | 69 | 69 | 105 | 48 | 16.4 | 10.0 |
HTMLCanvasElement
OffscreenCanvas
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/transferControlToOffscreen