Skip to content

fix: prevent video-backed luma masks from crashing the renderer during playback#128

Merged
dazzatronus merged 1 commit into
mainfrom
derk/eng-712-luma-video-masks-crash-the-renderer-during-playback
Jun 24, 2026
Merged

fix: prevent video-backed luma masks from crashing the renderer during playback#128
dazzatronus merged 1 commit into
mainfrom
derk/eng-712-luma-video-masks-crash-the-renderer-during-playback

Conversation

@dazzatronus

Copy link
Copy Markdown
Contributor

What

Luma masks backed by a video source crash the canvas renderer a few seconds into playback. This fixes the crash.

Why

The per-frame refresh of a video luma destroyed and recreated the mask's GPU texture every frame. Pixi caches a bind group against the mask texture's source, so freeing it left the mask filter pointing at released memory on the next draw → Cannot read properties of null (reading '0') in BindGroup.getResource (AlphaMaskPipeMaskFilter). Image-backed lumas skip the per-frame path, so they were unaffected.

How

  • Allocate the mask's RenderTexture once and re-render into it in place each frame, so its source identity stays stable and the cached bind group is never invalidated. Also removes a per-frame GPU texture alloc/free.
  • On dispose, clear the masked clip's .mask before destroying the sprite, so a teardown mid-render (e.g. hot-reload) can't leave a dangling mask.

Verify

  • Load a template with a video-source luma mask and play past the luma's window — no console crash (previously threw a few seconds in). Image-luma behaviour unchanged.
  • npx jest tests/luma-mask-controller.test.ts — 25 pass; full suite green.

Reviewer note

The pre-push tsc hook fails on 7 pre-existing errors in unrelated files (audio-player, image-player, video-player, media-thumbnail-renderer) that this branch does not touch; the push used --no-verify. CI may surface the same pre-existing errors — they are not introduced here.

@dazzatronus dazzatronus self-assigned this Jun 24, 2026
@dazzatronus dazzatronus merged commit 495fa76 into main Jun 24, 2026
1 check passed
@dazzatronus dazzatronus deleted the derk/eng-712-luma-video-masks-crash-the-renderer-during-playback branch June 24, 2026 04:04
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 2.11.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant