Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors with chrome on Ubuntu 20.04 and some possible fixes #43

Open
robwent opened this issue Jul 8, 2024 · 7 comments
Open

Errors with chrome on Ubuntu 20.04 and some possible fixes #43

robwent opened this issue Jul 8, 2024 · 7 comments

Comments

@robwent
Copy link

robwent commented Jul 8, 2024

I got this working on my local Windows machine, but after uploading to my live site, I was getting an unhelpful Symfony error:

The process has been signalled with signal "6"

I installed all the mentioned packages but couldn't get past this.

I then downloaded a separate copy of Chrome to see if that was the issue, but I still got the same error.
Trying to run it on the command line, I got a permission error, so chowned the main chrome file to 755 and then got an error:

[2543468:2543468:0708/213831.722702:ERROR:ozone_platform_x11.cc(244)] Missing X server or $DISPLAY
[2543468:2543468:0708/213831.722895:ERROR:env.cc(258)] The platform failed to initialize.  Exiting.

I found some threads about Chrome not being able to find a default display and running printenv DISPLAY showed nothing.
I then found this thread puppeteer/puppeteer#8148 (comment)
Ran

apt-get install xvfb x11-apps x11-xkb-utils libx11-6 libx11-xcb1
Xvfb -ac :99 -screen 0 1280x1024x16 & export DISPLAY=:99

After that, running printenv DISPLAY outputs: :99

At that point, I could generate a PDF by using the copy of Chrome I uploaded, but not the one downloaded by the download command (I ran it separately on each machine originally).

Unfortunately, I can't remember where I downloaded Chrome from manually, but it doesn't seem to be an official version. The filename is ungoogled-chromium_126.0.6478.127_1.vaapi_linux.tar.xz

Hopefully, this might help someone else get it working.

@turbo124
Copy link
Collaborator

turbo124 commented Jul 8, 2024

@beganovich this is a widespread issue I think may be related to the newer version of snapped. I am also seeing that if attempting to use a dedicated path to a separate chrome binary, this is not being respected by snappdf

@robwent
Copy link
Author

robwent commented Jul 8, 2024

The path to binary is working for me as I have it set on the live site but not the local one.
$snappdf->setChromiumPath( '/my/path/chrome' );

I just tested command line and got the same signal "6" error, but if I set the --binary flag then it works.

I was previously using hosted_ninja for pdfs on another server, but switched that to snappdf today as the servers were a similar setup (that one is Ubuntu 22.04).
That one worked straight away without installing any new packages, but the binary was already downloaded. I didn't force a new download so it could be an older version.

On another note, I couldn't get any flags working like width & height, removing margins and making landscape.
I got that working by setting @page in CSS like dompdf:

@page {
            size: 11in 8.5in;
            margin: 0;
        }

@beganovich
Copy link
Owner

Thanks, guys, I'll tinker on this one soon.

@beganovich
Copy link
Owner

@robwent can you try adding 0755 to chrome_crashpad_handler too?

You can find it in vendor/beganovich/snappdf/versions and find folder where chrome is. There should be chrome_crashpad_handler too.

chmod 0755 chrome_crashpad_handler

@robwent
Copy link
Author

robwent commented Nov 14, 2024

Just a quick update on this. I had to move the site to a different server running Ubuntu 24.04 and the PDF generation stopped working. This time with an error about audio libraries.

/path/to/headless-chrome/ungoogled-chromium_130.0.6723.116-1_linux/chrome: symbol lookup error: /path/to/headless-chrome/ungoogled-chromium_130.0.6723.116-1_linux/chrome: undefined symbol: snd_device_name_get_hint, version ALSA_0.9

It was fixed by running sudo apt install libasound2t64.

The same version of Chrome that was running on the old server. It's possible 20.04 had something similar already installed, but I have no access to check it now.

@beganovich
Copy link
Owner

Thanks for update!

Please keep in mind that we've listed this in our README.

https://github.com/beganovich/snappdf?tab=readme-ov-file#headless-chrome-doesnt-launch-on-unix

@robwent
Copy link
Author

robwent commented Nov 14, 2024

Ahh, I ran all those commands but I got some errors about multiple packages.

I'm not sure what the difference is but I had to change libasound2 to libasound2t64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants