deselecting a long path extremely slow (many minutes)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Inkscape |
Confirmed
|
Medium
|
Unassigned |
Bug Description
Deselecting a path with more than 10,000 nodes takes minutes (without any visual feedback). Selecting the path takes a fraction of a second or very few seconds (with visual feedback). This even when drawing the entire svg only takes a fraction of a second.
inkscape 0.92.2-1build1 on Ubuntu 17.10 (artful)
How to reproduce:
- Download the SVG from https:/
- Open the file. Rendering is sub-second.
- Unlock layer "_coastline"
- Click inside the image and then double-click to select the path (24k nodes). This takes about 2 seconds on my machine, painted top-down, so there is visual feedback. Also, two seconds for 24k nodes is perfectly acceptable.
- Click outside the image to deselect the path. This takes over 4 minutes (!) on my machine. During this, there is no visual feedback and Gnome even "helpfully" asks whether to kill the process (which I did the first few times, until I became patient enough)
Further operations will take about the same time again. So deselecting long paths should be avoided at all costs.
Further information:
Selecting Russia in layer "_countries" (15k nodes) is sub-second; deselecting it takes just over 1 minute. So it seems that an n^3 algorithm is used for the deselection redraw, as 1:4 ~ (15k:24k)^3. This also correlates with the fact that deselection of paths with 1k or 2k nodes is immediate.
My first assumption was that a redraw is triggered for each of the marker squares, which would explain n^2 runtime.
Remedy:
Possible solutions might include:
- Find an algorithm with lower complexity.
- When deselecting paths with more than 1k (or 10k) nodes, redraw the entire bounding box of the path instead of only the node markers.
- When deselecting long paths, split the path into smaller paths (whether this works depends on the actual redraw procedure used)
- Measure the time it took for the first draw (or last full redraw) of the SVG. When deselecting takes longer than this time, do a full redraw instead.
This might be related to bug #1624072.
I understand this is a rare case. But when you have to work with these files, working gets all but impossible. For a user, it is baffling that selection should take around a second while deselection could take multiple minutes without any hint whether Inkscape will ever return from that 100% CPU consumption.