OffscreenCanvasRenderingContext2D: commit() method
Deprecated
Avoid using this feature in new projects. This feature may be a candidate for removal from web standards or browsers.>
Note: This feature is available in Web Workers.
Non-standard: This feature is not standardized. We do not recommend using non-standard features in production, as they have limited browser support, and may change or be removed. However, they can be a suitable alternative in specific cases where no standard option exists.
The
OffscreenCanvasRenderingContext2D.commit()
method of the Canvas 2D API was intended to copy the rendering context's bitmap to the bitmap of the placeholder <canvas> element of the associated OffscreenCanvas object.
The copy operation is synchronous. Calling this method is not needed for the transfer, since it happens automatically during the event-loop execution.
Syntax
commit()
Parameters
None.
Return value
None (undefined).
Examples
const placeholder = document.createElement("canvas");
const offscreen = placeholder.transferControlToOffscreen();
const ctx = offscreenCanvas.getContext("2d");
// Perform some drawing using the 2d context
ctx.fillStyle = "blue";
ctx.fillRect(0, 0, 10, 10);
// Push placeholder to the canvas element
ctx.commit();
Specifications
Not part of any specification.
Browser compatibility
See also
- The interface defining this method:
OffscreenCanvasRenderingContext2D