Repository navigation
MNT: remove inkscape from testing in favour of resvg - #32666
Conversation
bdb047c to
c9fdd9c
Compare
|
attn @iccir |
tacaswell
left a comment
There was a problem hiding this comment.
Might be worth re-generating that one SVG (I assume that this is due to us truncating floating point numbers, the checked in version having lots of digits, and then us rounding and the renderer rounding are coming out slightly differently).
iccir
left a comment
There was a problem hiding this comment.
I am approving this as I have a longstanding belief that "an always-on warning light is dangerous". I believe that a flakey or always-failing test makes people ignore that test.
That said, I have concerns and questions:
- It was mentioned a few meetings back that users open our SVGs in Inkscape and then make modifications. With this change, are we no longer testing a common use case?
- What exactly are we trying to test here? Should we be testing our generated SVGs against both references PNGs as well as reference SVGs?
- What happens if we start using an SVG feature which resvg doesn't support - will we catch that in test? If resvg doesn't render a filter, we might end up testing a blank image against another blank image. Note that the same is true with Inkscape today or any other SVG engine - they all support slightly different subsets of the standard.
I think I'd rather see us keep Inkscape on Linux (if it is reliable there) and also use resvg on platforms where Inkscape isn't support. Additionally, I'd like to see some kind of testing against a browser-based SVG renderer (I'm was working on a PR that used the macOS WebKit renderer, but I can abandon that if people want).
All that said: the priority should be making the lights green. Self-merge ok. Or @tacaswell can merge as needed.
|
The goal in to make sure our svg are stable over time, that is the same code now generates an svg that render the same as that code generated in the past. To that end, any svg renderer we can use to get to raster we can compare our checked in SVG to a new SVG is sufficient (as we mentioned, we should trust that the renderer is infact a functional SVG renderer at is not going to just render everything as We have in the past held the line that if we are generating valid SVG to the spec and an renderer is getting it wrong we expect the renderer to fix it self ( I'm 50/50 on if we still want to pick of the mac browser based version as well. On one hand, it does not add a lot over already having a Python package that handles it. On the other hand, it does add some diversity to the tests so if we do find blind spots in the renderers then presumably it will be different bugs so. I'm at "likely useful but not urgent". |
I too am 50/50 :) I'd be 100% in favor if there were a simple command-line tool on macOS that could invoke the renderer, or if Apple provided a simple "render this SVG as a PNG" API. Unfortunately, it involves sending everything over to another Python process which loads a C extension, spins up the app run loop, and makes a WKWebView. That sends everything over to another process inside the WebKit sandbox. Wheeee! |
|
I don't think this was a "make the lights green" attempt. The goal was to get rid of a huge dependency that by itself does way more than what we need. I think historically it was the free way to translate svg but I guess these new packages have come along that do it without the GUI overhead Google claims resvg-py and friends are 1-2.5 mb whereas Inkscape is 300-600 mb. It also thinks resvg will be much faster and wouldn't be spilling up Inkscape in tests. Finally it is a conda/pip install. For sure I have no idea if we try to use svg extensions that are only possible in Inkscape. I would tend to say we should not do that and our svg should be standard compliant. Certainly if we allow such special cases they are not currently tested I'm not sure I follow the idea that someone may produce blank reference images. Someone should definitely visually inspect every reference image before it is committed! |
I did this a bit yesterday - I copied every .svg from tests to /tmp/svgs, then ran: from pathlib import Path
import resvg_py
directory = Path("/tmp/svgs")
for svg in directory.glob("*.svg"):
try:
png = svg.with_suffix(".png")
b = resvg_py.svg_to_bytes(svg_path=str(svg), dpi=72.0)
png.write_bytes(b)
except Exception as e:
print(f"Error processing {svg}: {e}")I then compared the results in using macOS WebKit and resvg. I didn't see any differences. |
|
Oopps sorry for the lengthy explanation after it had already been discussed and merged. Typing too slow on my phone! |
|
This was anomalously fast to go in 🤣 |
Actually, I do follow this concern now. I hadn't realized that we check in the svg but the svg->png converter runs on both the reference and the test image. I'm not sure what to do about that, and the same concern existed with Inkscape. |



This drops Inkscape as a test requirement, and uses
resvg-pyhttps://pypi.org/project/resvg_py/. This is conda- and pip-installable and doesn't require a GUI and installing something the size of Inkscape.AI use: yes AI did the typing for me. I checked the CI jobs and the one image test difference by eye (see below).
I don't feel strongly about this, but given the issues with CI on the Macs its seems a win.