Closed xlucn closed 10 months ago
this has happened to me as well, when previewing a large pdf using lf, my window manager just froze
Hi, thanks for reporting this. This is happening because Chafa delegates to ImageMagick when there's no internal loader to handle the file format. ImageMagick gets very enthusiastic and sometimes trips on its own shoelaces.
The problem is fixed in master and will go away in the next release -- see #157.
In the meantime, you should be able to curb problematic formats in ImageMagick's configuration. On my distro, this lives in /etc/ImageMagick-7/
. The best way is to list it in the security policy file:
magick -list format
.policy.xml
), e.g:
<policy domain="coder" rights="none" pattern="DJVU" />
<policy domain="coder" rights="none" pattern="PDF" />
The default configuration varies between Linux distros; mine already has PDF on the do-not-load list, and it looks like DjVu support is not built in at all.
thanks, I look forward to the next release!
I just released version 1.14.0, where ImageMagick is no longer an option. That should fix the issue (but it will no longer produce previews for DjVu and PDF; maybe one day it will be possible to do so safely).
Summary: Since chafa seems to try to display as many file formats as possible, sometimes it might just be inappropriate and should be prevented or optimized.
Example: One such case is DjVu files, many-page djvu documents to be accurate.
In my exact case, I have set in my lf preview script to use chafa to preview any file of image/* type. Unfortunately, DjVu files are "image/vnd.djvu" type. However, I think the argument applies to more general use cases as well.
When I use chafa to (pre)view a several-hundred-page djvu document, it consumes all the available memory and the system just hangs.
Discussion: Maybe chafa should at least check for potential memory consumption.
Maybe also optimize the preview, such as only preview the first page, which I believe will never cost many GBs of memory. This possibly applies to PDFs as well, which currently is very slow (a few seconds) to display.