fix(arrows): clamp boundary anchors to avoid degenerate intersections#8130
Merged
fix(arrows): clamp boundary anchors to avoid degenerate intersections#8130
Conversation
Arrow endpoints flicker when normalizedAnchor coordinates are exactly 0 or 1 (shape edges/corners). At these values, the downstream intersection math hits degeneracies: coincident rays along edges, shared polygon vertices between adjacent edges, and tangent arc circles. The intersection toggles between found/not-found across frames, causing visible oscillation. Fix by clamping normalizedAnchor from [0, 1] to [0.001, 0.999] during terminal computation in getArrowTerminalInArrowSpace. The stored binding is never modified — the nudge only exists ephemerally so the intersection math never sees an exact boundary value. The 0.001 offset is 0.2px on a 200px shape, visually imperceptible.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
5 Skipped Deployments
|
kaneel
reviewed
Mar 2, 2026
Contributor
kaneel
left a comment
There was a problem hiding this comment.
I can't even pretend I understand the math but looking at it, and also trying to paste one of my "buggy mermaid flowcharts" within the example preview that contains your fix, it seems to be working for me!
steveruizok
reviewed
Mar 3, 2026
| // If the parent is the bound shape, then it's always treated as precise. | ||
| const shouldUsePreciseAnchor = binding.props.isPrecise || forceImprecise | ||
| const normalizedAnchor = shouldUsePreciseAnchor | ||
| ? // Keep exact bindings untouched; only sanitize imprecise/precise anchors to avoid |
Collaborator
There was a problem hiding this comment.
the normalized difference here is negligible... unless I'm missing something, I'd normalize everything
Contributor
Author
There was a problem hiding this comment.
yep sounds good. made the change
Member
|
best PR title i've seen in a while |
steveruizok
approved these changes
Mar 4, 2026
Collaborator
|
send it |
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 #8125
dune-bug-fixed.mp4
Arrow endpoints flicker when
normalizedAnchorcoordinates are exactly 0 or 1 (shape edges/corners). At these exact values, the intersection math becomes numerically unstable — small floating-point errors cause intersections to toggle between found and not-found across frames.Solution: if arrow is precise or forceImprecise, clamp each anchor coordinate from [0, 1] to [0.001, 0.999]. This clamping happens inside
getArrowTerminalInArrowSpace, which runs every time the arrow info is recomputed (i.e. whenever the arrow or its bound shapes change). The binding record in the store is never modified — the nudge only exists ephemerally during computation, so the intersection math never sees an exact boundary value.Change type
bugfixTest plan
{x: 0, y: 0},{x: 0.5, y: 0})Release notes
Note
Medium Risk
Touches core arrow terminal computation; clamping precise anchors near 0/1 can subtly shift endpoints (up to ~0.1% of shape size) and may affect arrow rendering/attachment in edge cases.
Overview
Prevents arrow endpoint flicker when a bound terminal’s
normalizedAnchorlands exactly on a shape edge/corner by clamping precise anchors away from0/1duringgetArrowTerminalInArrowSpacecomputations.Adds a small epsilon-based
clampNormalizedAnchorhelper and refactors the terminal point calculation to use the clamped anchor without mutating stored binding data.Written by Cursor Bugbot for commit f4ecde2. This will update automatically on new commits. Configure here.