Skip to main content

HTML-in-canvas for client-side renderingv4.0.447

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

Currently, HTML-in-canvas is only available in Chrome.

Enabling the option does not guarantee that HTML-in-canvas client-side rendering is being used. If HtmlInCanvas.isNestingSupported() returns false, 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. With renderMediaOnWeb():

Using Chromium experimental HTML-in-canvas (drawElementImage) for video frames. 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

With renderStillOnWeb(), the warning says for this frame instead of for video frames.

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 a browser without nesting support, the built-in DOM composer is selected.

Compatibility​

BrowsersEnvironments
Chrome
Firefox
Safari

See also​