-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Writing SVG causes librsvg panic #41
Comments
When I modify |
Okay, modifying <svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 512 512">
<clipPath id="a">
<circle cx="256" cy="256" r="256" />
</clipPath>
<g clip-path="url(#a)">
<path fill="#0052b4" d="M0 0h512v512H0z" />
<path fill="#eee"
d="m154 300 14 30 32-8-14 30 25 20-32 7 1 33-26-21-26 21 1-33-33-7 26-20-14-30 32 8zm222-27h47l-38 27 15-44 14 44zm7-162 7 15 16-4-7 15 12 10-15 3v17l-13-11-13 11v-17l-15-3 12-10-7-15 16 4zm57 67 7 15 16-4-7 15 12 10-15 3v16l-13-10-13 11v-17l-15-3 12-10-7-15 16 4zm-122 22 7 15 16-4-7 15 12 10-15 3v16l-13-10-13 11v-17l-15-3 12-10-7-15 16 4zm65 156 7 15 16-4-7 15 12 10-15 3v17l-13-11-13 11v-17l-15-3 12-10-7-15 16 4zM0 0v32l32 32L0 96v160h32l32-32 32 32h32v-83l83 83h45l-8-16 8-15v-14l-83-83h83V96l-32-32 32-32V0H96L64 32 32 0Z" />
<path fill="#d80027" d="M32 0v32H0v64h32v160h64V96h160V32H96V0Zm96 128 128 128v-31l-97-97z" />
</g>
</svg> All of the flags in this set are structured the same way, so I think I can pre-process them to work for my purposes! If |
Thanks! I can reproduce this on MacOS 13. Maybe there is an issue with our build of librsvg. |
Can you test if the problem is gone with the latest build: install.packages('rsvg', repos = 'https://ropensci.r-universe.dev') Update: hmm for me rsvg_svg no longer crashes, but rsvg_svg() does not give useful output either. Not quite sure why this svg won't roundtrip properly. |
Mmmm, I can reproduce the result you're getting with an essentially empty SVG on the development version! Actually, I'm getting that empty SVG even if I include my previous workaround (substituting the |
Seems like this could be related to Kozea/CairoSVG#214 EDIT: alas, adding attributes to the |
Yeah there must be an issue with our static builds of the rsvg stack. Using the rsvg command line seems to work: brew install librsvg
curl -OL https://raw.githubusercontent.com/HatScripts/circle-flags/gh-pages/flags/au.svg
rsvg-convert au.svg -f svg > out.svg I noticed the output svg contains an embedded png image, so that is perhaps where things go wrong in our static librsvg. |
Hmm I see the same problem now on Windows after updating librsvg to 2.57.0. Not sure how to fix this, it seems to be a problem with recent versions of librsvg that only appears when when compiled statically :/ |
I tried with librsvg 2.52 and 2.54 but they both crash as well. We could downgrade to 2.50 which seems to work for this example but who knows what side effects that has. |
OK some progress: this problem seems triggered by the "new" scaling methods that in our C code is conditional on So I think this is related to #36 and we need to try what is suggested here: #29 (comment) |
This code needs some rewriting, but I think the immediate issue is fixed. Can you try the latest version from https://ropensci.r-universe.dev/rsvg ? |
This should be released on rsvg 2.6.0, which is just released on CRAN. I hope this resolves your problems, but if you do find any issues, please open a new issue. Thanks for reporting this. |
Can confirm these are successfully processing ion rsvg 2.6.0! (Apologies for the delay getting back to you too!). The masks aren't rendering correctly yet, but that could be a separate problem with
EDIT: I'll file a separate issue for this second par! |
As part of some refactoring of {ggflags}, I'm trying to run flag SVGs from
HatScripts/circle-flags
throughrsvg::rsvg_svg
to ensure they'r Cairo-compatible.However, running that function with any flag in the set causes a panic that kills my R session:
I also get this if I manually specify an output width and height:
I don't have any problems with other export functions:
I can also successfully run this example code from the package docs:
So I'm thinking there's something about these input SVGs that librsvg doesn't like exporting!
Here's what
au.svg
looks like (I've applied a formatter to it but otherwise left it untouched):I'm on macOS Sonoma 14.0 on an M1 Mac, with R 4.2.1 and rsvg 2.5.0 linking to librsvg 2.56.0.
The text was updated successfully, but these errors were encountered: