remotion icon indicating copy to clipboard operation
remotion copied to clipboard

@remotion/web-renderer: mix-blend-mode is ignored by renderMediaOnWeb (drawn as normal)

Open DanZavy opened this issue 1 month ago • 0 comments

Bug Report 🐛

renderMediaOnWeb (@remotion/web-renderer 4.0.537) draws every element with a CSS mix-blend-mode as if the mode were normal. The <Player> blends correctly, so the exported video differs from the preview.

Reproduce

import { AbsoluteFill, Img } from "remotion";

export const Blend: React.FC = () => (
  <AbsoluteFill style={{ backgroundColor: "#1a1d24" }}>
    <Img src={someImage} style={{ position: "absolute", left: 80, top: 60, width: 320, height: 240 }} />
    <div
      style={{
        position: "absolute", left: 200, top: 120, width: 300, height: 160,
        backgroundColor: "#d94f2b", mixBlendMode: "multiply",
      }}
    />
  </AbsoluteFill>
);

Render it with renderMediaOnWeb, then compare a frame of the output with the same frame in the <Player>.

Expected: the square multiplies with the image, as it does in the Player.

Actual: the square is drawn opaque over the image, exactly as with mixBlendMode: "normal".

What we measured

We captured frame 10 of a 640 × 360, 30 fps composition from the Player and from the renderMediaOnWeb MP4, in Chromium 156. We did this for each of the 15 non-normal modes: multiply, screen, overlay, darken, lighten, color-dodge, color-burn, hard-light, soft-light, difference, exclusion, hue, saturation, color and luminosity. Each was applied once to a solid div and once to text over an image.

In all 30 cases the exported frame matched an export of the same composition drawn in normal mode, to every digit of the mean pixel difference. The Player frames did blend.

Searching dist/esm/index.mjs finds no reference to mixBlendMode or mix-blend-mode. The only globalCompositeOperation values set are internal masking ones (source-in, destination-in, destination-out).

Suggestion

CSS mix-blend-mode keywords map one to one onto the canvas globalCompositeOperation blend values, which share the same names. When the computed mix-blend-mode isn't normal, setting ctx.globalCompositeOperation to it while drawing that element's layer, then restoring it, might be enough. Isolation (isolation: isolate) and stacking contexts would need care.

Environment

  • @remotion/web-renderer, remotion, @remotion/player: 4.0.537
  • Chromium 156.0.8078.4 (Playwright), macOS, device pixel ratio 1

DanZavy avatar Oct 24 '26 09:10 DanZavy