pwmt / zathura

Document viewer
https://pwmt.org/projects/zathura
zlib License
1.88k stars 129 forks source link

Large PDF (ARMv8 reference manual) renders black pages with mupdf backend #365

Open sebastinas opened 1 year ago

sebastinas commented 1 year ago

On GitLab by @ddevault on Dec 15, 2022, 19:42


You may acquire this PDF (12,000 pages) here:

https://developer.arm.com/documentation/ddi0487/latest

sebastinas commented 1 year ago

On GitLab by @valoq on Jan 1, 2023, 01:56


Also reproducible with the poppler backend.

Opening the file in evince with the same poppler version works fine

While zathura just shows a black window when opening the file with zathura-pdf-poppler I could sometimes get the file to show by changing the window size. But even then the application was very slow in response to navigation.

When opening the file with zathura-pdf-mupdf, I also got the following errors multiple times:

warning: cannot load object (152728 0 R) into cache
error: calloc (1 x 80 bytes) failed
...
warning: cannot load object (152757 0 R) into cache
error: calloc (16 x 8 bytes) failed
warning: cannot load object (152757 0 R) into cache
error: malloc of 128 bytes failed
...
warning: cannot load object (33456 0 R) into cache
error: calloc (4104 x 1 bytes) failed
error: aborting process from uncaught error!

Note that the file opens correctly in Mupdf as well

sebastinas commented 1 year ago

On GitLab by @andipersti on Apr 29, 2023, 18:11


I think I've tracked down the problem to a limitation of the cairo library GTK uses for drawing the widgets.

Zathura basically concatenates all pages of a document into a single big image (in case of the ARM manual the resulting image is about 12.000.000 pixels high in the default zoom level) and uses a sliding window for showing the current view. Now during the GTK drawing process in gtk_widget_draw_internal that "clip box" is calculated with cairo_rectangle which uses _cairo_fixed_from_double for converting the coordinates into the internal fixed-point representation. And this conversion overflows for values bigger than 8.300.000. So the "clip box" will be empty and as a consequence gdk_cairo_get_clip_rectangle will return nothing (i.e. an empty box) and the widget won't be drawn.

See also issues 265 and 252 on the cairo bug tracker.

sebastinas commented 2 months ago

On GitLab by @AlexRevo on Apr 13, 2024, 12:43


Ran into what seems like this issue, too: if I zoom out enough, the document renders, but at this point the text is too small to be readable.

Document link: https://www.japonski-pomocnik.pl/wordDictionary/dictionary.pdf (8990 pages).