fix(EffectComposer): resize the composer when the pixel ratio changes - #381
Open
tonyblu331 wants to merge 1 commit into
Open
tonyblu331 wants to merge 1 commit into
tonyblu331 wants to merge 1 commit into
Conversation
The per-frame size check compared gl.getSize(), the CSS size, which doesn't change when only the pixel ratio does (setDpr, AdaptiveDpr, a dpr prop change, another display). composer.setSize() never ran, so the buffers and every pass kept the old drawing-buffer size. postprocessing sizes them from renderer.getDrawingBufferSize(), so include gl.getPixelRatio() in the check. setSize() still only runs on frames where something changed. Fixes pmndrs#280 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Sep 25, 2026
This branch has not been deployed
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.
Fixes #280.
<EffectComposer>comparesgl.getSize()every frame to decide when to callcomposer.setSize(). That's the CSS size, which doesn't change when only the pixel ratio does:setDpr,<AdaptiveDpr>, adprprop change, or moving to a display with another ratio. The composer's buffers and passes kept the old drawing-buffer size.postprocessing's
setSize()sizes the buffers and every pass fromrenderer.getDrawingBufferSize(), so this addsgl.getPixelRatio()to the same check.setSize()still only runs on frames where something changed. There's no new listener and no API change.Chromium, 480×320 canvas with N8AO,
setDpr(2)→setDpr(1):Tests: a
sizingblock inEffectComposer.test.tsxadvances frames by hand. Two tests are red without the fix (pixel ratio up, pixel ratio down), plus a guard that nothing resizes when nothing changed.pnpm test(183),eslint:ci,typecheckandbuildpass.🤖 Generated with Claude Code