fix(text): clear canvas texture when text set to empty string#49
Merged
Conversation
Setting a canvas text node's text to '' produced no imageData but left the previously-rendered texture assigned, so CoreNode.updateIsRenderable re-marked the node renderable on the next frame and the old text lingered. Clear the stale texture in the empty-text branch. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
txManager is a read-only property on Stage; assigning it post-construction broke the build. Pass it through the mock constructor instead. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The displayed quad count is driven by the async renderUpdate event and only settles once all image textures / SDF layouts have loaded and the count text (itself made of quads) converges. Snapshotting after a fixed 200ms captured a nondeterministic mid-load frame, so the rendered node count varied between runs. Wait for the renderer 'idle' event before each snapshot to capture the stable final state. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
Fixes the bug where setting a canvas text node's
textto''does not clear the previously rendered text (lightning-js/renderer#773).When text becomes empty, the Canvas text renderer returns no
imageData.CoreTextNode.handleRenderResultonly calledsetRenderable(false)but left the stale (e.g. "Hello") texture assigned to the node. On the next frame,CoreNode.updateIsRenderable()seestexture !== null && textureLoaded === trueand re-marks the node renderable — so the old text reappears.The SDF path was already correct (it nulls
_cachedLayoutandrenderQuadsearly-returns); only the Canvas path was affected.Changes
src/core/CoreTextNode.ts: clearthis.texture = nullin the empty-text Canvas branch so the stale texture is unloaded and the node correctly becomes non-renderable.src/core/CoreTextNode.test.ts: regression test — render "Hello", then set empty, assert texture is cleared and node is not renderable.Test plan
pnpm exec vitest run— 233 tests passing, including the new regression test🤖 Generated with Claude Code