Incorrect circle radius behavior for document with tiny scale (huge viewBox extents)
Summary:
I have a document containing a circle. I think the actual radius of the circle is 3.985 cm, but Inkscape shows a radius value of 0.000 cm. When I try changing the radius of the circle, the new value is ignored and a huge value (1000000.000 cm) is chosen instead.
The issue occurs specifically in this document, which was originally generated by the SVG plot function in pcbnew 6.0.11 (the KiCad PCB Editor). I performed some edits to the SVG document with Inkscape and hit this issue on one circle in particular. This is a cut-down test case, with all objects other than the circle deleted.
My guess is that the large viewBox extents (0 0 297002200 210007200
) that
pcbnew chose for the root <svg>
element are triggering this issue. It seems
like pcbnew chose these viewBox extents for the convenience of using nanometer
values when writing the document, and letting the viewBox
and
width
/height
attributes scale the object sizes and positions to the right
real distance units. The document is probably valid, but I'm not an SVG
expert; I don't know if the specification warns against or forbids huge values.
There's no indication to Inkscape users that there's anything unusual with the document scaling through normal editing. All the object sizes and positions look fine. You have to check the Document Properties or read the SVG file to notice this issue (or run into this Inkscape issue).
Steps to reproduce:
- Open attached test document in Inkscape.
- Press the "5" key to zoom to the page.
- Click the circle.
- Click the Ellipse/Arc Tool left-side toolbar button.
- In the tool-specific toolbar, under "Change:", change the values of Rx and Ry from 0.000 cm to 2 cm, then press Enter.
Also: if I draw a new circle in this document and try setting the radius values the same way, the same symptoms occur.
What happened?
- The circle Rx and Ry values are initially shown as 0.000 cm (before changing them).
- The circle becomes too big to view on the screen after setting the Rx and Ry values.
- The Rx and Ry values are now both set to 1000000.000 cm.
This is also printed to standard error:
** (org.inkscape.Inkscape:11626): WARNING **: 13:48:09.675: Error parsing curve: lib2geom exception: assertion failed: B.isFinite() (../../../../../../src/3rdparty/2geom/src/2geom/sbasis-to-bezier.cpp:499)
On an older version of Inkscape shipped by Debian (inkscape
package version 1.2.2-2+b1
), it crashes with the message:
Inkscape encountered an internal error and will close now. Automatic backups of unsaved documents were done to the following locations:
...
A similar lib2geom error is printed standard error:
terminate called after throwing an instance of 'Geom::Exception'
what(): lib2geom exception: assertion failed: B.isFinite() (./src/2geom/sbasis-to-bezier.cpp:485)
Emergency save activated!
Emergency save document locations:
[... omitted ...].svg
Emergency save completed. Inkscape will close now.
If you can reproduce this crash, please file a bug at https://inkscape.org/report
with a detailed description of the steps leading to the crash, so we can fix it.
I'm only mentioning the crash and the older version for completeness, and to help anyone searching the web for these symptoms accompanied by a crash.
What should have happened?
- The radius of the circle should have initially been 3.985 cm.
- The on-screen size of circle should be 2 cm (relative to the on-screen scales and other objects) after setting the Rx and Ry values, and should fit on screen for this (roughly) A4-sized document.
- The Rx and Ry values should stay at 2.000 cm after setting them.
Workaround
The issue seems to follow the document. For a simple document like this one with just one layer, I can adjust the viewBox extents to work around the bug:
- Select all objects and cut to the clipboard.
- Open Document Properties.
- Choose a reasonable Scale value. It was previously set to 0.000001 cm per user unit in this document, so I chose 1 cm per user unit.
- Paste In Place to restore the objects.
Or, more simply:
- Select all objects and copy to the clipboard.
- Create a new document.
- Paste In Place to transfer the objects.
Version info
Inkscape 1.3.2 (091e20e, 2023-11-25)
GLib version: 2.64.6
GTK version: 3.24.20
glibmm version: 2.64.2
gtkmm version: 3.24.2
libxml2 version: 2.9.10
libxslt version: 1.1.34
Cairo version: 1.18.0
Pango version: 1.44.7
HarfBuzz version: 2.6.4
OS version: Debian GNU/Linux 12 (bookworm)
Thanks for looking into this!