GraphiteEditor / Graphite

2D vector & raster editor that melds traditional layers & tools with a modern node-based, non-destructive, procedural workflow.
https://graphite.rs
Apache License 2.0
9.4k stars 453 forks source link

Alt-drag duplication makes snapping freeze the editor for seconds/minutes/hours #2017

Open Keavon opened 1 month ago

Keavon commented 1 month ago

Type a bunch of text with the text tool, like a sizable paragraph, across multiple lines. Hold Alt and drag with the Select tool, in order to duplicate the text layer. (I also tested this while holding Shift to constrain it to horizontal or vertical movement when duplicate-dragging, I'm not sure if that part is relevant.) This freezes the editor for many seconds or minutes.

capture

As we can see, this originates in fn snap_drag. That function has a loop for point in candidates that calls fn constrained_snap. The code in here has several more layers of loops.

0HyperCube commented 1 month ago

@Keavon this doesn't freeze the editor for hours unless you have millions of points.

0HyperCube commented 1 month ago

If you don't want the snapping to be run, simply disable the snapping. This will alleviate your performance concerns.

The fact is that the snapping function tries to snap each point in the dragging path. Snapping each point requires some iteration in order to find where it snaps to.