Skip to content

fix(shaders): request a frame when an Effect registers or unregisters - #282

Merged
hunterbecton merged 1 commit into
mainfrom
t3/project-next-steps
Nov 7, 2026
Merged

hunterbecton merged 1 commit into
mainfrom
t3/project-next-steps

Conversation

@hunterbecton

Copy link
Copy Markdown
Member

Why

Registering or unregistering an Effect rebuilds the output material but draws nothing. On a parked scene, a changed Effect prop or a removed Effect left the old image on screen until something else asked for a frame.

What changes

useSceneRegistration now calls requestRender() after each registration and each unregistration. useResample and usePostProcessPass both go through it, so this covers every Effect, and PaletteMap's local workaround is gone. A running scene pays nothing, because requestRender() returns at once unless the scene is idle.

The new cleanup also runs when a whole scene unmounts, after the scheduler may be disposed. A parked-scene test and a FrameScheduler test confirm that this queues no frame.

Closes SHA-311

Registering and unregistering rebuild the output material and draw
nothing, so a parked scene kept the old image until something else asked
for a frame. useSceneRegistration now asks after each change, which
covers every Effect, and PaletteMap's local workaround goes.
Copilot AI balanced review requested due to automatic review settings November 7, 2026 02:54
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

React Doctor found no new issues. 🎉

Reviewed by React Doctor for commit 29d0fbe.

Copilot AI 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.

🟢 Approval recommended

No active review issues remain for the shared Effect registration redraw change.

No open issues 🎉

What changed in this PR

Fixes stale images on parked shader scenes by moving Effect redraw requests into the shared registration hook, covering both resample and post-process Effects.

Changes:

  • Requests a frame after Effect registration and unregistration, replacing PaletteMap’s local workaround.
  • Adds lifecycle-order and disposal regression tests, and updates scheduler mocks.
  • Documents the shared redraw behavior and adds a patch changeset.
File Description
packages/​shaders/​src/​runtime/​frame-scheduler/​frame-scheduler.test.ts Tests that render requests after disposal queue no frame.
packages/​shaders/​src/​react/​hooks/​use-scene-registration/​use-scene-registration.ts Requests redraws after registration and cleanup.
packages/​shaders/​src/​react/​hooks/​use-scene-registration/​use-scene-registration.test.tsx Tests redraw ordering on mount, unmount, and dependency changes.
packages/​shaders/​src/​react/​hooks/​use-resample/​use-resample.test.tsx Adds requestRender to the scheduler mock.
packages/​shaders/​src/​react/​hooks/​use-overlay-pass/​use-overlay-pass.test.tsx Updates scheduler mocks for shared redraw requests.
packages/​shaders/​src/​react/​hooks/​use-base-pass-uv/​use-base-pass-uv.test.tsx Adds requestRender to the scheduler mock.
packages/​shaders/​src/​react/​components/​shader-scene/​shader-scene.test.tsx Tests parked-scene teardown with an Effect mounted.
packages/​shaders/​src/​components/​palette-map/​shader.tsx Removes the redundant local redraw workaround.
docs/​agents/​tsl.md Documents redraw requests during Effect registration changes.
.changeset/​effect-registration-frame.md Records the parked-scene fix as a patch release.

Review effort: Balanced

@hunterbecton
hunterbecton merged commit ba95e2d into main Nov 7, 2026
12 checks passed
@hunterbecton
hunterbecton deleted the t3/project-next-steps branch November 7, 2026 03:18
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.

2 participants