Skip to content

@remotion/web-renderer: Support raster URL masks - #9861

Merged
JonnyBurger merged 1 commit into
mainfrom
codex/web-renderer-url-masks
Jul 29, 2026
Merged

@remotion/web-renderer: Support raster URL masks#9861
JonnyBurger merged 1 commit into
mainfrom
codex/web-renderer-url-masks

Conversation

@JonnyBurger

@JonnyBurger JonnyBurger commented Jul 29, 2026

Copy link
Copy Markdown
Member

Summary

  • support a single same-origin, data:, or blob: raster mask-image: url() in @remotion/web-renderer
  • load, decode, cache, time out, and cancel mask resources inside the renderer for deterministic output
  • constrain URL masks to alpha semantics and explicitly supported size, position, repeat, origin, and clip values
  • bypass native HTML-in-canvas capture for URL-mask subtrees and cover the behavior with cross-browser visual tests
  • document the supported URL-mask subset from v4.0.501

Tests

  • bun run build
  • bun run stylecheck
  • bun run testwebrenderer (669 passed, 21 skipped)

Closes #7006

Preview

@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
bugs Ready Ready Preview, Comment Jul 29, 2026 9:42am
remotion Ready Ready Preview, Comment Jul 29, 2026 9:42am

Request Review

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed changes — adds raster URL mask support to @remotion/web-renderer with deterministic image loading, caching, abort, and timeout semantics, plus cross-browser screenshot tests.

  • Discriminated MaskImageInfo typeparseMaskImage in mask-image.ts now returns either a linear-gradient or URL mask via a tagged union, with a manual CSS url() parser and a validateUrlMaskImageStyle guard that rejects unsupported mask-size, mask-position, mask-repeat, mask-mode, mask-origin, and mask-clip values.
  • MaskImageLoaderState and getMaskImage — new file mask-image-loader.ts manages a Map-based promise cache, ImageBitmap lifecycle via [Symbol.dispose], timeout and AbortSignal-driven cancellation, same-origin/data:/blob: URL validation, createImageBitmap decoding, and fetch with credentials: 'same-origin'.
  • handleMask now async — branches on mask type: linear gradients use the existing createCanvasGradient path; URL masks load the bitmap via getMaskImage and apply it with drawImage + destination-in.
  • Bypass HTML-in-canvas for URL-mask subtreescontainsUrlMaskImage walks descendants and, when a URL mask is found, skips drawWithHtmlInCanvas in take-screenshot.ts (with shouldWarn: false) so the manual DOM composer handles the mask deterministically.
  • makeInternalState accepts signal and timeoutrenderMediaOnWeb and renderStillOnWeb threads the render abort signal and delayRenderTimeoutInMilliseconds through to the mask loader.
  • Docslimitations.mdx entry for raster URL masks available from v4.0.501, listing supported and unsupported config.
  • Tests — three browser tests (same-origin raster mask at 1x and 2x, cross-origin rejection), 6 new screenshot baselines covering chromium/firefox/webkit.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) (Claude Opus not used — the program covers this model; add its provider key to run your pick) | 𝕏

@JonnyBurger
JonnyBurger merged commit e416c0d into main Jul 29, 2026
31 of 32 checks passed
@JonnyBurger
JonnyBurger deleted the codex/web-renderer-url-masks branch July 29, 2026 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

web-renderer: Support mask-image: url()

1 participant