bitcrowd / chromic_pdf

Convenient HTML to PDF/A rendering library for Elixir based on Chrome & Ghostscript
Apache License 2.0
419 stars 37 forks source link

Possibly incompatible with Ghostscript 9.56.1 #153

Closed maltoe closed 2 years ago

maltoe commented 2 years ago

See https://elixirforum.com/t/chromicpdf-pdf-generator/29473/41

** (RuntimeError)   /usr/local/bin/gs exited with status 1!

GPL Ghostscript 9.56.1: Unrecoverable error, exit code 1

    (chromic_pdf 1.2.0) lib/chromic_pdf/utils.ex:53: ChromicPDF.Utils.system_cmd!/3

Haven't confirmed it yet.

andreasknoepfle commented 2 years ago

Can confirm this happens on Ghostscript update:

 GPL Ghostscript 9.56.1: Unrecoverable error, exit code 1
andreasknoepfle commented 2 years ago

https://www.ghostscript.com/doc/current/History9.htm#Version9.56.0

Maybe this:

In this (9.56.0) release, the new PDF interpreter is now ENABLED by default in Ghostscript, but the old PDF interpreter can be used as a fallback by specifying -dNEWPDF=false. We've provided this so users that encounter issues with the new interpreter can keep working while we iron out those issues, the option will not be available in the long term.

The other two incompatible changes are not really something that should affect us:

(9.55.0) Changes to the device API. This will affect developers and maintainers of Ghostscript devices. Firstly, and most importantly, the way device-specific "procs" are specified has been rewritten to make it (we think!) clearer and less confusing. See The Interface between Ghostscript and Device Drivers and The Great Device Rework Of 2021 for more details.

(9.55.0) The command line options -sGraphicsICCProfile=, -dGraphicsIntent=#, -dGraphicsBlackPt=#, -dGraphicsKPreserve=# have been changed to -sVectorICCProfile=, -dVectorIntent=#, -dVectorBlackPt=#, -dVectorKPreserve=#.

andreasknoepfle commented 2 years ago

It seems to have to do with quoted paths that we pass along to ghostscript. Will work on a fix for this.

andreasknoepfle commented 2 years ago

Fixed in #154

andreasknoepfle commented 2 years ago

There seems to be more problems with ghostscript 9.56.1. Now we see exit status 139. But it seems to be inconsistently happening.

    ** (RuntimeError)   /usr/bin/gs exited with status 139!
        (chromic_pdf 1.2.1) lib/chromic_pdf/utils.ex:53: ChromicPDF.Utils.system_cmd!/3
        (chromic_pdf 1.2.1) lib/chromic_pdf/pdfa/ghostscript_worker.ex:77: ChromicPDF.GhostscriptWorker.pdfinfo/1
        (chromic_pdf 1.2.1) lib/chromic_pdf/pdfa/ghostscript_worker.ex:44: ChromicPDF.GhostscriptWorker.create_pdfa_def_ps!/3
        (chromic_pdf 1.2.1) lib/chromic_pdf/pdfa/ghostscript_worker.ex:29: ChromicPDF.GhostscriptWorker.convert/3
        (chromic_pdf 1.2.1) lib/chromic_pdf/pdfa/ghostscript_pool.ex:35: anonymous fn/5 in ChromicPDF.GhostscriptPool.convert/4
        (nimble_pool 0.2.6) lib/nimble_pool.ex:349: NimblePool.checkout!/4
        (chromic_pdf 1.2.1) lib/chromic_pdf/api.ex:88: anonymous fn/4 in ChromicPDF.API.do_convert_to_pdfa/4
        (chromic_pdf 1.2.1) lib/chromic_pdf/api/telemetry.ex:8: anonymous fn/2 in ChromicPDF.Telemetry.with_telemetry/3
        (telemetry 0.4.3) /builds/1/db/dima/everyworks/_deps/telemetry/src/telemetry.erl:272: :telemetry.span/3
        (chromic_pdf 1.2.1) lib/chromic_pdf/utils.ex:27: ChromicPDF.Utils.with_tmp_dir/1
andreasknoepfle commented 2 years ago

Released in 1.2.2.

xaviRodri commented 11 months ago

Hey there! Are we still getting this problems with 10.02.1 (2023-11-01) ?? I just checked and haven't got any errors.. If you agree, I would suggest to remove the maybe_disable_new_interpreter/0 func and use the new interpreter. OR at least to make it optional so people can use it.

Also mentioning this 🔝 as I'm receiving a lot of these warnings:

**** Warning: You are using the legacy PDF interpreter (-dNEWPDF=false) which is now deprecated and unsupported
maltoe commented 11 months ago

@xaviRodri agree, would be good to ditch it. Looking at the release notes of 10.02.0 it even seems that the old interpreter has been entirely removed already, so the switch is likely without effect.

Are you offering to implement this? :hugs: I think we should be good if we remove the flag for >= 10.02, but we should perhaps also add a test image to make sure? Perhaps an alpine-3.18 based one.

xaviRodri commented 11 months ago

Thanks for the quick response @maltoe !! Sure yeah I can take it 👍 Will post a PR and we can check it together to see if everything is in place before merging 👀

maltoe commented 11 months ago

@xaviRodri Heads up, the docker setup is a bit fragile; best to start with a separate PR just adding that image, and the feature PR afterwards

xaviRodri commented 11 months ago

@maltoe look like this has been done before I could 😅 Sorry but I was away from keyboard 🙏 Then there's nothing left for me to do right?

xaviRodri commented 11 months ago

@maltoe just realised that in here you added the version 10.2, but latest it's actually 10.02 according to https://ghostscript.com/releases/gsdnld.html

Should we make it 10.0 maybe? Haven't had time to see if it would be what we need here

maltoe commented 11 months ago

@xaviRodri yes, but I'm comparing the version components as integers, so 2 and 02 should be the same. Not sure why ghostscript insists on having 2-digit minor versions :shrug:

https://github.com/bitcrowd/chromic_pdf/blob/fc4407d2d590a509ea60d7698377f4223687a536/lib/chromic_pdf/utils.ex#L137-L144

With regards to dropping it to 10.0: Sure, I'm all for limiting this hack to the exact versions where we need it, but we should make sure it works before doing so. We could start by trying 10.1 perhaps as we already have testing infrastructure in place with that version.

xaviRodri commented 10 months ago

@maltoe happy new year! 🎊

I've reported the semver violation to GS people, so let's see if they fix it.. In the meanwhile, I will check if we could use 10.0.0 as the "good" version. Because after that one comes 10.01.0 and then we have the same problem 🙂