Repository navigation
fix: guard canvas size and scroll offset - #107
Merged
Merged
Conversation
Reject a non-finite pixel ratio or layout length, and ignore non-finite scroll and zoom-range input so the time scale cannot stick on NaN. Co-authored-by: Joe Blau <joeblau@users.noreply.github.com>
cursor
Bot
force-pushed
the
cursor/canvas-scroll-guards-0692
branch
from
November 10, 2026 19:50
8355d28 to
727f94b
Compare
Merged
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.
Closes #93
Closes #94
Behavior
Checks sit on the calls that write layout and scroll state. The render loop is unchanged.
resizethrowchart-ts: invalid pixelRatio …unless the ratio is finite and> 0, the same shape of errortakeScreenshotalready uses.resizealso throwschart-ts: invalid chart width/height …unless both CSS sizes are finite and>= 0, and it does not change the canvas when it throws.resolveConfigandupdateConfigreject a non-finite or negativewidth,height,priceAxis.width, ortimeAxis.heightbefore the config is stored.0stays a legal size.scroll,scrollTo, andfitRange(scrollBy,scrollTo,zoomToRange) ignore a non-finite argument, matchingzoom.clampScrollresets a non-finite offset to0before clamping, so aNaNcannot stick across the next gesture.Tests
1909 tests passed. Coverage is 100% line, branch, and function.
bun run typecheck:tscandbun run check:invariantspassed.Benchmarks
node bench/suite/run.mjs --samples=7 --sizes=100000, Node 24, median ms/op. The two builds were timed back to back. These paths do not run duringsetData,appendData, or render.The differences are run-to-run noise. Minimums for the 5000-bar redraw were 5.94 ms before and 5.77 ms after.