Repository navigation
Redraw the overlay once per expand or collapse, not up to five times - #357
Merged
Merged
Conversation
An expand redrew every persistent feature five times, a collapse four: - updateSVGLayout ends in applyZoomTransform, which redraws the axes and features, and the expand's measuring pass called it as well as the settling one; - applyExpandLayout then redrew both again explicitly; - the expand grows the container the ResizeObserver watches, and handleResize relaid out and redrew twice more though nothing had changed size. A 1 px correction the settling pass skipped (`> 1`) was left for it to apply. The measuring pass now only sizes (`sizeSVG`), takes any settled difference, and the one updateSVGLayout draws. handleResize relays out only when the gram's natural or render size moved, and no caller repeats a redraw updateSVGLayout has already made. The final sizes are unchanged. A player-expand test counts the marker redraws: 5 before, 1 after. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019erPajKv5JGH3Fj2Wt4i4x
Contributor
PR PreviewPreview deployment is ready! View Preview Last updated: 2026-11-20T12:08:28.480Z |
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.
Follow-up to #355/#356, where the extra redraw after an expand was the source of the CI race.
What was happening
Measured by counting marker elements added to the overlay:
Where the redraws came from:
updateSVGLayoutfinishes inapplyZoomTransform, which redraws the axes and every feature. The expand's measuring pass called it, and so did the settling pass.applyExpandLayoutthen redrew the axes and features again, explicitly.ResizeObserverwatches.handleResizethen laid out and redrew twice more, even though nothing had changed size. The settling pass skipped corrections of 1 px or less (> 1), leaving a 1 px correction (CI's 526 → 527) for the observer to apply.Changes
svgLayout.js:sizeSVGsizes the SVG, image and clip rects without drawing.updateSVGLayoutis nowsizeSVGplus the transform, so it is the one call that draws.ExpandToggle.js:updateSVGLayoutdraws, with no repeat redraw after it.viewport.js:handleResizelays out again only when the gram's natural or render size moved, and doesn't repeat the redraw.spectrogramImage.js: removed arenderAxesthatupdateSVGLayouthad just done.The final sizes are unchanged at every viewport tested: the same
renderWidthandrenderHeightas before.Tests
player-expand.spec.js: expanding and collapsing each add exactly one marker element. It fails on the old code with 5 and passes on the new.marker-labels.spec.js:312, which also fails locally onmainwithout this change, and passes on CI.Review notes
handleResizenow does nothing when the gram's size hasn't moved. That's right as long as only the natural and render dimensions decide the layout. If something else, such as the margins, ever comes to depend on the container's size, it needs to join that size check.Generated by Claude Code