Commit b54d7b5
fix(arrows): fix crash isolating degenerate curved arrows (tldraw#8176)
In order to prevent crashes when isolating curved arrows with degenerate
geometry, this PR hardens the arrow binding update logic to handle cases
where rebend geometry becomes invalid.
When a curved arrow's geometry becomes degenerate (e.g., during shape
deletion), the strict intersection assert could fire and the terminal
update could write `NaN` values. This PR removes the strict assert,
guards against zero-length direction vectors, and skips bend
recomputation when inputs are non-finite. Arrow terminal updates now
fall back to stored `arrow.props.start/end` when computed points are
invalid.
Fixes tldraw#8174.
### Change type
- [x] `bugfix`
### Test plan
1. Create two adjacent shapes and draw a bent (curved) arrow between
them
2. Delete the arrow — should not crash
3. Verify curved arrows still render and update correctly during normal
editing
- [x] Unit tests
### API changes
- Added `Vec.IsFinite()` static method for checking if a vector has
finite coordinates
### Release notes
- Fix crash when isolating curved arrows with degenerate binding
geometry
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Touches arrow binding/geometry update logic that runs during edits and
deletions; added guards reduce crash risk but could subtly change bend
recomputation behavior in edge cases.
>
> **Overview**
> Fixes a crash path in curved arrow binding updates by making
`updateArrowTerminal` resilient to degenerate geometry during
isolation/deletion.
>
> Terminal point updates now *fallback to `arrow.props.start/end`* when
computed points are non-finite, bend recomputation is skipped for
zero-length directions or non-finite arc inputs, and the strict
intersection assertion is replaced with best-effort intersection
selection. Adds `Vec.IsFinite()` to the public editor API and a
regression test covering deletion of a bent arrow bound between two
adjacent shapes.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
5fdfda1. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent fdd3bf3 commit b54d7b5
4 files changed
Lines changed: 109 additions & 12 deletions
File tree
- packages
- editor
- src/lib/primitives
- tldraw/src
- lib/bindings/arrow
- test/commands
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5005 | 5005 | | |
5006 | 5006 | | |
5007 | 5007 | | |
| 5008 | + | |
| 5009 | + | |
5008 | 5010 | | |
5009 | 5011 | | |
5010 | 5012 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
476 | 476 | | |
477 | 477 | | |
478 | 478 | | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
479 | 483 | | |
480 | 484 | | |
481 | 485 | | |
| |||
Lines changed: 52 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | 20 | | |
22 | 21 | | |
23 | 22 | | |
| |||
235 | 234 | | |
236 | 235 | | |
237 | 236 | | |
238 | | - | |
239 | | - | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
240 | 245 | | |
241 | 246 | | |
242 | 247 | | |
| |||
251 | 256 | | |
252 | 257 | | |
253 | 258 | | |
254 | | - | |
255 | | - | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
256 | 265 | | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
257 | 274 | | |
258 | 275 | | |
259 | 276 | | |
260 | | - | |
| 277 | + | |
261 | 278 | | |
262 | 279 | | |
263 | 280 | | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
264 | 293 | | |
265 | 294 | | |
266 | 295 | | |
267 | 296 | | |
268 | | - | |
| 297 | + | |
269 | 298 | | |
270 | 299 | | |
271 | 300 | | |
272 | 301 | | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
278 | 311 | | |
279 | 312 | | |
280 | 313 | | |
| |||
283 | 316 | | |
284 | 317 | | |
285 | 318 | | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
106 | 157 | | |
107 | 158 | | |
108 | 159 | | |
| |||
0 commit comments