Rewrite EffectComposer's pass lifecycle for correctness and cost - #364
Open
kvvasuu wants to merge 1 commit into
Open
Rewrite EffectComposer's pass lifecycle for correctness and cost#364kvvasuu wants to merge 1 commit into
kvvasuu wants to merge 1 commit into
Conversation
Passes are now derived from the r3f scene graph and only rebuilt when the resolved node list actually changes, not on every render. Fixes real GPU-resource bugs found along the way: composer-level prop changes (multisampling etc.) could dispose effects still in use by the new composer, discarded EffectPass wrappers leaked their own material and kept a stale change listener on the effect they wrapped, and a user's own EffectPass rendered as a child could be mistaken for one we generated.
kvvasuu
force-pushed
the
pr2/effect-composer
branch
from
August 5, 2026 20:30
a3986a9 to
965b7fb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Second PR in the stack (base:
pr1/foundation).Rewrites
EffectComposer's internal pass lifecycle - the public props/contract are unchanged.Passes are now only rebuil when the resolved node list actually changed - not on every unrelated React render. Uses a two-effect "gate + rebuild" split: a cheap
useLayoutEffectwith no dependency array detects whether the node list changed and bumps a version counter only if so; a seconduseLayoutEffectkeyed on that version does the actual (expensive) rebuild. A single effect with a manually-skipped body was tried first and found to be broken - React always runs the previous render's cleanup regardless of what the next invocation's body decides, so "skipping" still let stale passes get removed without being re-added.