jimmejardine / qiqqa-open-source

The open-sourced version of the award-winning Qiqqa research management tool for Windows
GNU General Public License v3.0
366 stars 60 forks source link

tracking MuPDF error 703870: rendering annotations #346

Closed GerHobbelt closed 2 years ago

GerHobbelt commented 2 years ago

https://bugs.ghostscript.com/show_bug.cgi?id=703870

GerHobbelt commented 2 years ago

See https://bugs.ghostscript.com/show_bug.cgi?id=703870#c3 :: turns out it's my own damn fault. 😰

Issue resolved in bleeding edge mupdf submodule.

GerHobbelt commented 2 years ago

Culprit commit: https://github.com/GerHobbelt/mupdf/commit/165d4088305fefc4880acf6f5535254cd8b83d5c

The goal of this work was to find out if (and how) I could get MuPDF to render any pages within a given time frame and, without barfing a hairball via fz_throw(), if such is not possible, to at least render something, even though it will be 'corrupt'. The goal here is to first check this and make it possible, so I will know where to patch the code properly later on when I want this behaviour: interruptable and/or time-limited renders which give a warning without crashing through a C# .NET interface layer thanks to setjmp/longjmp in fz_try/fz_throw/fz_catch.

To that end, this HACKY CODE HACK has been done:

Conclusion:

Also do realize that the ranking of these costly calls is such that in that level 1,2,3 list, nothing shows up on the radar when you haven't killed the topmost still-active item, so focusing on improving the PDF parser performance would be utterly ludicrous.

This entire drama started at 30+ minutes (instrumented debug build, aborted!!!) and was brought down to ~ 10 seconds in the end, while luck would have it that the disabled / skipped code did not very noticably damage the rendered output of THIS PDF. Of course, YMMV. Those groupings and blending modes aren't in there for no reason!

This commit represents the end state of this story / hack.

P.S.: I found out by code inspection that there's a cookie->abort flag, which might be useful for my second goal: interruptable => abortable page renderings! However, do note that fiddling with that flag will cause an error to be fz_throw()n -- flip that flag in mupdf while running the app in the debugger and you're get an alert box and blank screen!

This HACKY code change is [yes, commit message is clipped off, regrettably]