Skip to main content

HTML-in-canvasv4.0.447

note

This is not the same as the <HtmlInCanvas> component for designing visuals. This page describes a @remotion/web-renderer option that uses HTML-in-canvas to capture full frames during client-side rendering.

On supported Chromium-based browsers, @remotion/web-renderer can optionally capture full frames using the experimental HTML-in-canvas APIs.

info

Use a recent version of Google Chrome or another Chromium-based browser with chrome://flags/#canvas-draw-element enabled. Current Chrome stable releases ship canvas.requestPaint() together with drawElementImage, which is required for correct frame capture. See Compatibility for details.

Enabling the option does not guarantee that this path runs. If the browser does not have HTML-in-canvas enabled, or if the composition contains an <HtmlInCanvas> in Chrome earlier than 157, it falls back to the default frame capturing mechanism.

Enabling​

In code​

Pass allowHtmlInCanvas: true to renderMediaOnWeb() or renderStillOnWeb(). The default is false when you omit the field.

Example
await renderStillOnWeb({ composition, frame: 0, inputProps: {}, allowHtmlInCanvas: true, });

In the Studio​

Open the render modal, go to the Advanced tab, and turn on Allow HTML-in-canvas. The initial value comes from your config and CLI defaults.

As the Studio default​

remotion.config.ts
Config.setAllowHtmlInCanvasEnabled(true);

Or start Studio with --allow-html-in-canvas. See setAllowHtmlInCanvasEnabled() and npx remotion studio.

Check if HTML-in-canvas was used​

If HTML-in-canvas was used, you will see a warning in the browser console:

Using Chromium experimental HTML-in-canvas (drawElementImage) for this frame. Pixels may differ from the built-in DOM composer. Set allowHtmlInCanvas: false to force software rasterization. See https://remotion.dev/docs/client-side-rendering/html-in-canvas

If native capture starts but fails while capturing a frame, a warning is printed and the renderer falls back to the built-in DOM composer:

Not using HTML-in-canvas: drawElementImage failed (...); falling back to the built-in DOM composer.

If HTML-in-canvas is unavailable, disabled, or would require a nested capture in Chrome earlier than 157, the built-in DOM composer is selected.

Compatibility​

BrowsersEnvironments
Chrome
Firefox
Safari

HTML-in-canvas depends on Chromium flag chrome://flags/#canvas-draw-element, which must be enabled explicitly.

Use a recent Chrome or Chromium version with the flag enabled for full support. Compositions containing <HtmlInCanvas> use native capture in Chrome 157 or newer. Earlier versions use the built-in DOM composer.

Nested HTML-in-canvas capture is currently intended for client-side rendering in your browser. Remotion's server-side browser is Chrome 149 and does not support nesting yet.

See also​