-
Notifications
You must be signed in to change notification settings - Fork 526
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
Crash previewing SVG with large dimensions #2562
Comments
Hey @krir17, I noticed that you did not correctly follow the issue template. Please ensure that:
Issues with |
Actually, it is, because it tells Could you please test: |
That takes about 26 ms and 20 MB of RAM; with inkscape it's a little over 6 seconds and >2 GBs. |
It looks like for some reason, ImageMagick is not complying At the moment, it is unclear how to properly limit the memory usage of ImageMagick during SVG rendering, I think a temporary fix would be to remove I plan to explore alternative options to ImageMagick in the future, and currently, |
Please try #2564 |
Thanks - that does fix it for this file, but still fails when it encounters this inane file: image_10k.svg --- (Edit: Actually, it's probably not Inkscape's fault either: |
Yes, I plan to explore using other tools as a replacement for ImageMagick.
I think a better short term fix might be to get magick to use rsvg even
if Inkscape is present
I don't think Yazi has a way to force ImageMagick to use `rsvg` — I haven't
found such a parameter. If you know how to do this, please let me know, and
I'll be happy to add it to `svg.lua`.
…On Thu, Apr 3, 2025 at 1:04 PM KrIr17 ***@***.***> wrote:
Please try #2564 <#2564>
Thanks - that does fix it for this file, but still fails when it
encounters this inane file: image_10k.svg
<https://github.com/user-attachments/assets/58fb0051-cf73-44aa-b56e-ad0faf9f3958>
--- rsvg in this case bails out before doing anything while Inkscape
churns out a huge SVG file anyway. I think a better short term fix might be
to get magick to use rsvg even if Inkscape is present? Although if the
intention is to move to a different renderer, this should be fine for now.
—
Reply to this email directly, view it on GitHub
<#2562 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEFWFIFRS2ONU5YHUGM2LTD2XS6OLAVCNFSM6AAAAAB2KGEUUKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONZUGUYDIMBRGA>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
[image: krir17]*krir17* left a comment (sxyazi/yazi#2562)
<#2562 (comment)>
Please try #2564 <#2564>
Thanks - that does fix it for this file, but still fails when it
encounters this inane file: image_10k.svg
<https://github.com/user-attachments/assets/58fb0051-cf73-44aa-b56e-ad0faf9f3958>
--- rsvg in this case bails out before doing anything while Inkscape
churns out a huge SVG file anyway. I think a better short term fix might be
to get magick to use rsvg even if Inkscape is present? Although if the
intention is to move to a different renderer, this should be fine for now.
—
Reply to this email directly, view it on GitHub
<#2562 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEFWFIFRS2ONU5YHUGM2LTD2XS6OLAVCNFSM6AAAAAB2KGEUUKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONZUGUYDIMBRGA>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
Copying from @ze0987's comment:
|
Is there any documentation regarding this behavior? - How can I verify that
ImageMagick is using `rsvg`?
My ImageMagick build doesn't have `--with-rsvg`, and `rsvg` isn't installed
on my OS, yet the command still works, which seems to indicate that it's
not taking effect. Then I replaced `rsvg` with another arbitrary string
`abcd`, it still worked:
```
magick abcd:brick_sys.svg -flatten -resize 200x200 -auto-orient out.jpg
```
…On Thu, Apr 3, 2025 at 1:38 PM KrIr17 ***@***.***> wrote:
ImageMagick to use rsvg — I haven't found such a parameter
Copying from @ze0987 <https://github.com/ze0987>'s comment:
magick rsvg:brick_sys.svg -flatten -resize 200x200 -auto-orient out.jpg
doesn't seem to use Inkscape (the filename is prepended with rsvg:).
—
Reply to this email directly, view it on GitHub
<#2562 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEFWFIDKRSASIFKSKOW5MHT2XTCPBAVCNFSM6AAAAAB2KGEUUKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONZUGU2DKNBUGI>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
[image: krir17]*krir17* left a comment (sxyazi/yazi#2562)
<#2562 (comment)>
ImageMagick to use rsvg — I haven't found such a parameter
Copying from @ze0987 <https://github.com/ze0987>'s comment:
magick rsvg:brick_sys.svg -flatten -resize 200x200 -auto-orient out.jpg
doesn't seem to use Inkscape (the filename is prepended with rsvg:).
—
Reply to this email directly, view it on GitHub
<#2562 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEFWFIDKRSASIFKSKOW5MHT2XTCPBAVCNFSM6AAAAAB2KGEUUKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONZUGU2DKNBUGI>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
Unfortunately I couldn't find a definitive soruce, except for: https://stackoverflow.com/a/46586730 and maybe https://usage.imagemagick.org/files/ For a quick test, creating an
does suggest that it uses |
That's a clever demonstration, awesome!
I have two more questions:
1. If you specify `rsvg:` but haven't installed rsvg and only have inkscape
installed, what will its behavior be? Will it fall back to ImageMagick's
default SVG backend or to inkscape?
2. After forcing ImageMagick to use rsvg via `rsvg:`, does the `-density
200` option still lead to an OOM? How do different `-density` parameters
perform with the rsvg backend?
…On Thu, Apr 3, 2025 at 2:59 PM KrIr17 ***@***.***> wrote:
Unfortunately I couldn't find a definitive soruce, except for:
https://stackoverflow.com/a/46586730 and maybe
https://usage.imagemagick.org/files/
For a quick test, creating an inkscape executable in my local directory,
with just echo "Inkscape is Running" and running the following commands
***@***.*** test_yazi]$ PATH=$(pwd):$PATH magick rsvg:new.svg out.jpg
***@***.*** test_yazi]$ PATH=$(pwd):$PATH magick new.svg out.jpg
Inkscape is running
***@***.*** test_yazi]$ PATH=$(pwd):$PATH magick wtvr:new.svg out.jpg
Inkscape is running
does suggest that it uses inkscape unless the rsvg delegate is specified
—
Reply to this email directly, view it on GitHub
<#2562 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEFWFIDYKP4GQVRR6IOVWDT2XTL6NAVCNFSM6AAAAAB2KGEUUKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONZUGY3TGOBSGE>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
[image: krir17]*krir17* left a comment (sxyazi/yazi#2562)
<#2562 (comment)>
Unfortunately I couldn't find a definitive soruce, except for:
https://stackoverflow.com/a/46586730 and maybe
https://usage.imagemagick.org/files/
For a quick test, creating an inkscape executable in my local directory,
with just echo "Inkscape is Running" and running the following commands
***@***.*** test_yazi]$ PATH=$(pwd):$PATH magick rsvg:new.svg out.jpg
***@***.*** test_yazi]$ PATH=$(pwd):$PATH magick new.svg out.jpg
Inkscape is running
***@***.*** test_yazi]$ PATH=$(pwd):$PATH magick wtvr:new.svg out.jpg
Inkscape is running
does suggest that it uses inkscape unless the rsvg delegate is specified
—
Reply to this email directly, view it on GitHub
<#2562 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEFWFIDYKP4GQVRR6IOVWDT2XTL6NAVCNFSM6AAAAAB2KGEUUKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONZUGY3TGOBSGE>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
Oh I just realized that the performance improvement observed in #2562 (comment) comes not from removing the density parameter but from the use of Some performance tests: (mmem is in KiB)
But with the size specified beforehand, a higher density isn't necessary since Density Tests
Actually, not sure about this. I would expect it 'falls back' to inksape, but I can't test it quickly (without recompiling |
Please try
b725b86
…On Thu, Apr 3, 2025 at 4:21 PM KrIr17 ***@***.***> wrote:
After forcing ImageMagick to use rsvg via rsvg:, does the -density 200
option still lead to an OOM? How do different -density parameters
perform with the rsvg backend?
Oh I just realized that the performance improvement observed in #2562
(comment)
<#2562 (comment)>
comes not from removing the density parameter but from the use of -size
200x200 instead of -resize 200x200. With resize I still end up with the
OOM issue (and both Inkscape and rsvg perform similarly w.r.t memory).
However, it looks like -size works only with the rsvg backend, so the
inkscape backend still leads to an OOM.
Some performance tests:
***@***.*** test_yazi]$ /usr/bin/time magick -size 200x200 rsvg:brick_sys.svg -density 200 -flatten out.jpg
0:00.02 real, 0.01 user, 0.01 sys, 0 amem, 19052 mmem
***@***.*** test_yazi]$ /usr/bin/time magick -size 200x200 rsvg:image_10k.svg -density 200 -flatten out.jpg
0:00.03 real, 0.01 user, 0.01 sys, 0 amem, 19684 mmem
***@***.*** test_yazi]$ /usr/bin/time magick -size 200x200 brick_sys.svg -density 200 -flatten out.jpg
0:10.29 real, 15.91 user, 8.43 sys, 0 amem, 3139204 mmem
***@***.*** test_yazi]$ /usr/bin/time magick -size 200x200 image_10k.svg -density 200 -flatten out.jpg
Command terminated by signal 9 (killed before OOM)
1:19.26 real, 41.30 user, 36.32 sys, 0 amem, 1178300 mmem
But with the size specified beforehand, a higher density isn't be
necessary since rsvg takes care of that.
Density Tests
SVG file: circleBug.svg (view on web)
<https://github.com/user-attachments/assets/f43b5a21-9e74-4c9a-b144-057fbc2b50b3>
magick -size 200x200 rsvg:circleBug.svg -flatten out.jpg
out_sized.jpg (view on web)
<https://github.com/user-attachments/assets/ea1fd94a-addc-47cc-b47b-a218d3ce4ba3>
magick rsvg:circleBug.svg -flatten -resize 200x200 out_resized.jpg
out_resized.jpg (view on web)
<https://github.com/user-attachments/assets/f66d2f24-3859-4614-9319-b948260ca148>
If you specify rsvg: but haven't installed rsvg and only have inkscape
installed, what will its behavior be? Will it fall back to ImageMagick's
default SVG backend or to inkscape?
Actually, not sure about this. I would expect it 'falls back' to inksape,
but I can't test it quickly (without recompiling magick and uninstalling
rsvg)
—
Reply to this email directly, view it on GitHub
<#2562 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEFWFIB5Q5T4RCMWR6QTULL2XTVO5AVCNFSM6AAAAAB2KGEUUKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONZUHA2TSMRXGQ>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
[image: krir17]*krir17* left a comment (sxyazi/yazi#2562)
<#2562 (comment)>
After forcing ImageMagick to use rsvg via rsvg:, does the -density 200
option still lead to an OOM? How do different -density parameters
perform with the rsvg backend?
Oh I just realized that the performance improvement observed in #2562
(comment)
<#2562 (comment)>
comes not from removing the density parameter but from the use of -size
200x200 instead of -resize 200x200. With resize I still end up with the
OOM issue (and both Inkscape and rsvg perform similarly w.r.t memory).
However, it looks like -size works only with the rsvg backend, so the
inkscape backend still leads to an OOM.
Some performance tests:
***@***.*** test_yazi]$ /usr/bin/time magick -size 200x200 rsvg:brick_sys.svg -density 200 -flatten out.jpg
0:00.02 real, 0.01 user, 0.01 sys, 0 amem, 19052 mmem
***@***.*** test_yazi]$ /usr/bin/time magick -size 200x200 rsvg:image_10k.svg -density 200 -flatten out.jpg
0:00.03 real, 0.01 user, 0.01 sys, 0 amem, 19684 mmem
***@***.*** test_yazi]$ /usr/bin/time magick -size 200x200 brick_sys.svg -density 200 -flatten out.jpg
0:10.29 real, 15.91 user, 8.43 sys, 0 amem, 3139204 mmem
***@***.*** test_yazi]$ /usr/bin/time magick -size 200x200 image_10k.svg -density 200 -flatten out.jpg
Command terminated by signal 9 (killed before OOM)
1:19.26 real, 41.30 user, 36.32 sys, 0 amem, 1178300 mmem
But with the size specified beforehand, a higher density isn't be
necessary since rsvg takes care of that.
Density Tests
SVG file: circleBug.svg (view on web)
<https://github.com/user-attachments/assets/f43b5a21-9e74-4c9a-b144-057fbc2b50b3>
magick -size 200x200 rsvg:circleBug.svg -flatten out.jpg
out_sized.jpg (view on web)
<https://github.com/user-attachments/assets/ea1fd94a-addc-47cc-b47b-a218d3ce4ba3>
magick rsvg:circleBug.svg -flatten -resize 200x200 out_resized.jpg
out_resized.jpg (view on web)
<https://github.com/user-attachments/assets/f66d2f24-3859-4614-9319-b948260ca148>
If you specify rsvg: but haven't installed rsvg and only have inkscape
installed, what will its behavior be? Will it fall back to ImageMagick's
default SVG backend or to inkscape?
Actually, not sure about this. I would expect it 'falls back' to inksape,
but I can't test it quickly (without recompiling magick and uninstalling
rsvg)
—
Reply to this email directly, view it on GitHub
<#2562 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEFWFIB5Q5T4RCMWR6QTULL2XTVO5AVCNFSM6AAAAAB2KGEUUKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONZUHA2TSMRXGQ>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
Exactly. With |
I checked it out and it doesn't look good. Source file:
imagemagick w/o rsvg w/ inkscape installed:
imagemagick w/ rsvg w/ inkscape installed:
|
Does this mean that if `rsvg:` is set but the user doesn't have rsvg
installed, it'll fall back to Inkscape?
…On Sun, Apr 6, 2025 at 9:51 PM ze0987 ***@***.***> wrote:
I would expect it 'falls back' to inksape, but I can't test it quickly
(without recompiling magick and uninstalling rsvg)
I checked it out and it doesn't look good.
Source file:
poster.svg
File Size: 475 kB
Image Size: 10000x10000
imagemagick w/o rsvg w/ inkscape installed:
magick -size 600x900 rsvg:poster.svg -strip -quality 75 thumbnail.jpg
Time: 1m10,122s
RAM: 2.755 GB
Thumbnail File Size: 1309 kB
Thumbnail Image Size: 10000x10000
imagemagick w/ rsvg w/ inkscape installed:
magick -size 600x900 rsvg:poster.svg -strip -quality 75 thumbnail.jpg
Time: 0m0,157s
RAM: 43.76 MB
Thumbnail File Size: 20 kB
Tumbnail Image Size: 600x600
—
Reply to this email directly, view it on GitHub
<#2562 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEFWFIDGX3J3UVRPVE5MNYT2YEWNLAVCNFSM6AAAAAB2KGEUUKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOOBRGQZTINZYGI>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
[image: ze0987]*ze0987* left a comment (sxyazi/yazi#2562)
<#2562 (comment)>
I would expect it 'falls back' to inksape, but I can't test it quickly
(without recompiling magick and uninstalling rsvg)
I checked it out and it doesn't look good.
Source file:
poster.svg
File Size: 475 kB
Image Size: 10000x10000
imagemagick w/o rsvg w/ inkscape installed:
magick -size 600x900 rsvg:poster.svg -strip -quality 75 thumbnail.jpg
Time: 1m10,122s
RAM: 2.755 GB
Thumbnail File Size: 1309 kB
Thumbnail Image Size: 10000x10000
imagemagick w/ rsvg w/ inkscape installed:
magick -size 600x900 rsvg:poster.svg -strip -quality 75 thumbnail.jpg
Time: 0m0,157s
RAM: 43.76 MB
Thumbnail File Size: 20 kB
Tumbnail Image Size: 600x600
—
Reply to this email directly, view it on GitHub
<#2562 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEFWFIDGX3J3UVRPVE5MNYT2YEWNLAVCNFSM6AAAAAB2KGEUUKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOOBRGQZTINZYGI>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
Yes, of course. |
That's really a headache, I think the only way to completely resolve this
is to give up on ImageMagick and look for an alternative, I'll get to work
on it in the next few days.
…On Sun, Apr 6, 2025 at 10:49 PM ze0987 ***@***.***> wrote:
Yes, of course.
—
Reply to this email directly, view it on GitHub
<#2562 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEFWFIG6DF76B2ZXBOBSGQT2YE5JHAVCNFSM6AAAAAB2KGEUUKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOOBRGQ3DANZTG4>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
[image: ze0987]*ze0987* left a comment (sxyazi/yazi#2562)
<#2562 (comment)>
Yes, of course.
—
Reply to this email directly, view it on GitHub
<#2562 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEFWFIG6DF76B2ZXBOBSGQT2YE5JHAVCNFSM6AAAAAB2KGEUUKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOOBRGQ3DANZTG4>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
To clarify. “imagemagick w/ rsvg” meant |
Please try #2581 |
What system are you running Yazi on?
Linux Wayland
What terminal are you running Yazi in?
kitty 0.36.4
yazi --debug
outputDescribe the bug
While previewing a large (in dimensions, the file size can be tiny) SVG, (1) memory usage grows rapidly and (2) the
/
directory starts becoming filled, causing the system to crash. With all preloaders and previewers disabled, no crash occurs.Minimal reproducer
(Note that this might crash the entire and system and potentially cause data loss)
btop
)Anything else?
This is a partial duplicate of #2345. The memory issue is obviously on IM's side:
magick -density 200 brick_system.svg -flatten -resize 200x200 -auto-orient out.jpg
takes ~13 GB of RAM on my system. Interestingly, settingMAGICK_MEMORY_LIMIT=10000
has no effect on this - and as a result, setting image_alloc doesn't help either. In both cases,magick
produces a broken JPEG file but 'works'.When
yazi
previews the file, something causessystemd-coredump
to write >0.5 GBs (!) of core dumps to/
every second (see attached video), crashing the entire session in ~10-20 seconds. This might be due to a crash inmagick
which doesn't happen when run directly.Screencast of disk usage
yaziClip.mp4
TBH I expect none of this to be yazi's fault - and the attached SVG file is a bit extreme (although it is a info-stripped version of a real SVG file) - but it would be nice to prevent users from inadvertently running into this. I think using
rsvg-convert
overmagick
might be better (also for other reasons)... but that's probably a feature request.Checklist
yazi --debug
) input box to the nightly that I triedmv ~/.config/yazi ~/.config/yazi-backup
)The text was updated successfully, but these errors were encountered: