yazi: Crash previewing SVG with large dimensions
What system are you running Yazi on?
Linux Wayland
What terminal are you running Yazi in?
kitty 0.36.4
yazi --debug output
Yazi
Version: 25.3.7 (1765aba 2025-03-30)
Debug : false
Triple : x86_64-unknown-linux-gnu (linux-x86_64)
Rustc : 1.85.1 (4eb16125 2025-03-15)
Ya
Version: 25.3.7 (1765aba 2025-03-30)
Emulator
TERM : Some("xterm-256color")
TERM_PROGRAM : None
TERM_PROGRAM_VERSION: None
Brand.from_env : None
Emulator.detect : Emulator { kind: Right(Unknown { kgp: false, sixel: false }), light: false, cell_size: None }
Adapter
Adapter.matches : Wayland
Dimension.available: WindowSize { rows: 51, columns: 237, width: 0, height: 0 }
Desktop
XDG_SESSION_TYPE : Some("wayland")
WAYLAND_DISPLAY : Some("wayland-1")
DISPLAY : Some(":0")
SWAYSOCK : Some("/run/user/1000/sway-ipc.1000.458567.sock")
HYPRLAND_INSTANCE_SIGNATURE: None
WAYFIRE_SOCKET : None
SSH
shared.in_ssh_connection: false
WSL
WSL: false
Variables
SHELL : Some("/bin/bash")
EDITOR : Some("nvim")
VISUAL : Some("nvim")
YAZI_FILE_ONE : None
YAZI_CONFIG_HOME: None
YAZI_ZOXIDE_OPTS: None
FZF_DEFAULT_OPTS: None
Text Opener
default : Some(OpenerRule { run: "${EDITOR:-vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })
block-create: Some(OpenerRule { run: "${EDITOR:-vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })
block-rename: Some(OpenerRule { run: "${EDITOR:-vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })
Multiplexers
TMUX : false
tmux version : tmux 3.5a
tmux build flags : enable-sixel=Unknown
ZELLIJ_SESSION_NAME: None
Zellij version : No such file or directory (os error 2)
Dependencies
file : 5.45
ueberzugpp : No such file or directory (os error 2)
ffmpeg/ffprobe: 7.0.2 / 7.0.2
pdftoppm : 24.08.0
magick : 7.1.1-41
fzf : 0.54.3
fd/fdfind : 10.1.0 / No such file or directory (os error 2)
rg : 14.1.1
chafa : 1.14.2
zoxide : No such file or directory (os error 2)
7zz/7z : No such file or directory (os error 2) / 16.02
jq : 1.7.1
Clipboard
wl-copy/paste: 2.2.1 / 2.2.1
xclip : 0.13
xsel : 1.2.1
Routine
`file -bL --mime-type`: text/plain
See https://yazi-rs.github.io/docs/plugins/overview#debugging on how to enable logging or debug runtime errors.
Describe 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)
- Save brick_system.svg to a local folder
- Monitor memory/disk usage (eg. using
btop) - Open yazi and try to preview the attached file
Anything else?
This is a partial duplicate of https://github.com/sxyazi/yazi/issues/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, setting MAGICK_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 causes systemd-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 in magick which doesn’t happen when run directly.
Screencast of disk usage
https://github.com/user-attachments/assets/14d48e04-4a0d-49b7-a57e-d34d30405803
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 over magick might be better (also for other reasons)… but that’s probably a feature request.
Checklist
- I tried the latest nightly build, and the issue is still reproducible
- I updated the debug information (
yazi --debug) input box to the nightly that I tried - I can reproduce it after disabling all custom configs/plugins (
mv ~/.config/yazi ~/.config/yazi-backup)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 22 (14 by maintainers)
Please try https://github.com/sxyazi/yazi/commit/b725b86be13ffc127094dbb981d667d3d7d8c64a
On Thu, Apr 3, 2025 at 4:21 PM KrIr17 @.***> wrote:
Oh I just realized that the performance improvement observed in https://github.com/sxyazi/yazi/issues/2562#issuecomment-2774109466 comes not from removing the density parameter but from the use of
-size 200x200instead of-resize 200x200. With resize I still end up with the OOM issue (and both Inkscape andrsvgperform similarly w.r.t memory). However, it looks like-sizeworks only with thersvgbackend, so theinkscapebackend still leads to an OOM.Some performance tests: (mmem is in KiB)
But with the size specified beforehand, a higher density isn’t necessary since
rsvgtakes care of that.Density Tests
SVG file:
Actually, not sure about this. I would expect it ‘falls back’ to inksape, but I can’t test it quickly (without recompiling
magickand uninstallingrsvg)That takes about 26 ms and 20 MB of RAM; with inkscape it’s a little over 6 seconds and >2 GBs.