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

electron-pdf hangs indefinitevily on Linux #243

Open
Marco-Sulla opened this issue Apr 8, 2019 · 9 comments
Open

electron-pdf hangs indefinitevily on Linux #243

Marco-Sulla opened this issue Apr 8, 2019 · 9 comments

Comments

@Marco-Sulla
Copy link
Contributor

Marco-Sulla commented Apr 8, 2019

I tried to run electron-pdf http://fraserxu.me test.pdf, as suggested in the help, but it hangs indefinitively without any message. I tried gooogle.com too.

I also tried the solution in this comment. It works for http://fraserxu.me but not for my html file, that is full of SVGs (maybe this is the problem)?

OS: Lubuntu 18.04.2 (Linux 4.15.0-46-generic #49-Ubuntu SMP Wed Feb 6 09:33:07 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux)
Electron Version: 4.0.4

@codecounselor
Copy link
Collaborator

please include the exact command you are running. And try prepending DEBUG=electron* which might give you some indication where it is getting stuck.
You can also append --browserConfig '{"show":true}' to see the window and do any debugging.

@Marco-Sulla
Copy link
Contributor Author

Marco-Sulla commented Apr 8, 2019

DEBUG=electron* electron-pdf /home/marco/Desktop/fraser.html ~/Desktop/fraserxu.pdf
Mon, 08 Apr 2019 19:03:50 GMT electronpdf:debug: checking hung windows-> total windows: 1, hung windows: 0, threshold: 300000
Mon, 08 Apr 2019 19:04:20 GMT electronpdf:debug: checking hung windows-> total windows: 1, hung windows: 0, threshold: 300000
Mon, 08 Apr 2019 19:04:50 GMT electronpdf:debug: checking hung windows-> total windows: 1, hung windows: 0, threshold: 300000

--browserConfig '{"show":true}' gives me a blank page, and dev tools are empty.

Command electron-pdf /home/marco/Desktop/fraser.html ~/Desktop/fraserxu.pdf --browserConfig '{ "webPreferences": { "sandbox" : true } }' succeed.

PS: I retried with the page with SVGs, no problem with --browserConfig '{ "webPreferences": { "sandbox" : true } }'

@amaloy
Copy link

amaloy commented May 5, 2019

I don't know if this is helpful, but I put electron-pdf in a Docker container (https://github.com/amaloy/electron-pdf-docker) and had the same problem. I ended up editing cli.js:
https://github.com/amaloy/electron-pdf-docker/blob/master/entrypoint.sh#L4
It removes the 'ipc' bit.
Not that I know what my change does, I just know it worked for me. :)

@itsrachelfish
Copy link

I'm having the same issue on Debian with a HTML file that contains SVGs.

@mikkorantalainen
Copy link

I see total hang, too.

Steps to reproduce:

$ mkdir /tmp/test001
$ cd /tmp/test001
$ npm install electron-pdf
$ node_modules/.bin/electron-pdf https://slashdot.org/ out.pdf

The process hangs, no CPU usage nor disk I/O.

System info:

$ lsb_release -d
Description: Ubuntu 18.04.5 LTS

$ npm --version
6.14.8

$ apt policy nodejs
nodejs:
Installed: 12.20.0-1nodesource1
Candidate: 12.20.0-1nodesource1
Version table:
*** 12.20.0-1nodesource1 500
500 https://deb.nodesource.com/node_12.x bionic/main amd64 Packages
100 /var/lib/dpkg/status

All real browsers (Chrome, Chromium, Firefox etc) do work so this shouldn't be caused by any missing libraries or unsupported features.

Hnagzhi added a commit to Hnagzhi/django-electron-pdf that referenced this issue Dec 22, 2020
Apparently, electron-pdf does only output any result when --browserConfig '{ "webPreferences": { "sandbox" : true } } is passed. See fraserxu/electron-pdf#243
Hnagzhi added a commit to Hnagzhi/django-electron-pdf that referenced this issue Dec 22, 2020
Apparently, electron-pdf does only output any result when --browserConfig '{ "webPreferences": { "sandbox" : true } } is passed. See fraserxu/electron-pdf#243
@brpaz
Copy link

brpaz commented Jan 6, 2021

Same happens to me on Fedora.

I only have this warning:

Fontconfig warning: "/usr/share/fontconfig/conf.avail/05-reset-dirs-sample.conf", line 6: unknown element "reset-dirs"

After that, nothing.

@jorismak
Copy link

jorismak commented Jul 9, 2021

Same here (Ubuntu 20.04 LTS AFAIK),

Tried with show: true and with adding webPreferences: { "sandbox" : true } to it.
DEBUG var is set, SENTRY_DSN is set,

One url is working fine (it's a big 'report', so it takes a while to render. You see electron process taking a lot of CPU for some minutes, then a second electron process starts taking CPU and in the CLI I see a debug JSON object being printed... and then the PDF saves and everything clears up).

But the same url with different parameters (render the same report for another country) is not working, but 'hanging around'.
The electron process is taking a lot of CPU, I'm looking at the Xwindow and I see the page being rendered, and the scrollbar growing and growing. But after that, nothing. The CPU usage goes away, the page in the Xwindow turns completely white with only the menu bar showing, and nothing happens.

After a while, the hung-window timeout kicks in and kills the window, but electron still hangs around. Increasing the hung-window timeout just makes this time longer, but no PDF is ever created (not even a 0-byte file).
The debug-json object I see printed in a working page also does not appear.

It appears for certain URLs the page renders, but electron-pdf never goes to the 'print as PDF' stage.

@mikkorantalainen
Copy link

This problem is probably caused by electron/electron#27605

The only known workaround is not to print anything containing an <iframe> element.

@jorismak
Copy link

I discovered that it appears electron is crashing. It shows with a 'trap int3' in the dmesg output.

The same page but rendered chunk by chunk is working fine, so in the end we render it in smaller parts and combine them together with qpdf.

Setting ELECTRONPDF_RENDERER_MAX_MEMORY to any amount smaller than 2gb seems to 'fix' it.
I say 'fix' in quotes, because it stops the electron process from crashing. But the render-to-PDF time seems to increase exponentially with it, and we had render times of over 12 minutes.

It seems that, independent of the ELECTRONPDF_RENDERER_MAX_MEMORY setting, electron just crashes when it uses more than 2gb of memory. Restricting it so it doesn't use that much memory fixes the crash, but makes the render times way to long to be practical / usable.

@Marco-Sulla Marco-Sulla changed the title electron-pdf hangs indefinitevily on Lubuntu electron-pdf hangs indefinitevily on Linux Jul 14, 2021
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

7 participants