wicked_pdf icon indicating copy to clipboard operation
wicked_pdf copied to clipboard

freezes

Open cj opened this issue 12 years ago • 32 comments

Hi,

So I'm using the current master head and have this code:

  def show
    respond_with claim do |format|
      format.pdf do
        render pdf: claim.number.gsub(/[^0-9a-z]/i, '_'), layout: 'print.html'
      end
    end
  end

and once it gets to here:

"***************\"/usr/local/bin/wkhtmltopdf\" -q        - - ***************"

It just freezes. When I kill the server with ctrl + c it then renders the pdf.... any ideas on what's going wrong?

Many thanks

p.s. I'm using the latest home brew version /usr/local/Cellar/wkhtmltopdf/0.11.0_rc1

cj avatar May 01 '12 21:05 cj

So I found out something very strange, it's showing the wkhtmltopdf bin icon in the dock and when I click on it then it completes generating the pdf. I'm using mac osx 10.7.3....

cj avatar May 02 '12 14:05 cj

I can verify the exact same behaviour with OS X 10.7.4.

bradjmiller avatar May 15 '12 18:05 bradjmiller

I encounter this issue with OS X 10.7.4 and 0.10.0 rc2 (but strangely brew said I install 0.11.0_rc1, but the command line version is 0.10)

Only after you the process icon on the "dock" will it quickly render and exit.

mech avatar May 16 '12 06:05 mech

+1 on 10.7.4 and /usr/local/Cellar/wkhtmltopdf/0.11.0_rc1/bin/wkhtmltopdf.

cdmwebs avatar May 21 '12 14:05 cdmwebs

This issue isn't specific to wicked_pdf, I'm having the same problem with PDFKit. The problem didn't appear until I installed 0.11.0_rc1 via homebrew. I stumbled on this ticket while trying to track down whether or not this was an issue with the wkhtmltopdf binary that comes with homebrew.

beerlington avatar May 22 '12 21:05 beerlington

I see this issue as well. which wkhtmltopdf shows /usr/local/bin/wkhtmltopdf which is a link to ../Cellar/wkhtmltopdf/0.11.0_rc1/bin/wkhtmltopdf. However, I see the 0.10 when I run wkhtmltopdf --version.

djhopper01 avatar May 23 '12 15:05 djhopper01

Hi,

The problem comes from wkhtmltopdf. It has been reported at http://code.google.com/p/wkhtmltopdf/issues/detail?id=141. I also used OSX 10.7.4 and wkhtmltopdf 0.11.rc1.

By waiting a solution, I moved back to 0.9.9 and it works.

inkstak avatar Jun 03 '12 17:06 inkstak

Currently running OSX 10.7.4 and wkhtmltopdf 0.9.9 and this isn't working for me. wkhtmltopdf bin icon appears in my dock but clicking it or exiting it does nothing and Firefox just outputs a "Connection was reset" error after approx 10 seconds.

peteroome avatar Jun 26 '12 09:06 peteroome

Same problem. OSX 10.7.4, wkhtmltopdf 0.10.0 rc2 (installed by homebrew).

dsnipe avatar Jun 27 '12 11:06 dsnipe

I got this working in the end. Rolling back to version 0.9.9 fixed the problem for me.

I also had to be careful as i was using Unicorn with a process timeout of 30s. I had some PDF's (before optimisation) which were taking longer than 30s to generate so i was getting timeout errors, as you'd expect.

If you're not sure about how to rollback to an older package version using Homebrew, i did a writeup here: Homebrew and installing old package versions.

peteroome avatar Jun 27 '12 17:06 peteroome

Same problem here. Tried so many different options. Such a simple task, so many problems with dependencies and native extensions..

giedriusr avatar Sep 24 '12 12:09 giedriusr

I'm on OS 10.6.8, same issue. Solved by rolling back wkhtmltopdf to 0.9.9. Now the wkhtmltopdf shell just pops up and disappears, leaving a beautiful pdf in the browser. Here's full steps, for newbs:

Step 1: uninstall wkhtmltopdf $ brew uninstall wkhtmltopdf Uninstalling /usr/local/Cellar/wkhtmltopdf/0.11.0_rc1...

Step 2: find version 0.9.9 $ brew versions wkhtmltopdf 0.11.0_rc1 git checkout aa80fbc /usr/local/Library/Formula/wkhtmltopdf.rb 0.9.9 git checkout 6e2d550 /usr/local/Library/Formula/wkhtmltopdf.rb

Step 3: Copy and paste the git checkout command (everything from git over to the right): $ git checkout 6e2d550 /usr/local/Library/Formula/wkhtmltopdf.rb

Step 4: reinstall $ brew install wkhtmltopdf

The last output line should say something like /usr/local/Cellar/wkhtmltopdf/0.9.9: 6 files, 424K, built in 15 seconds

Dreyfuzz avatar Oct 01 '12 03:10 Dreyfuzz

Before step 3 you have to cd to /usr/local/Library/Formula/ otherwise you will get a fatal: '/usr/local/Library/Formula/wkhtmltopdf.rb' is outside repository error.

aledalgrande avatar Oct 15 '12 14:10 aledalgrande

Same problem here: OSX 10.7.5 and newest wkhtmltopdf from homebrew. The solution to roll back to 0.9.9 works fine for me.

dsci avatar Oct 18 '12 13:10 dsci

Thanks for the dialog. I have documented the correct installation of 0.9.9 here: http://stackoverflow.com/questions/12517640/why-does-pdfkit-wkhtmltopdf-hang-but-renders-pdf-as-expected-when-rails-app-is-k/14043085#14043085

scarver2 avatar Dec 26 '12 16:12 scarver2

I've just migrated to 10.8.3 and now, wkhtmltopdf is showing up in the Dock when converting PDF... is there a way to stop this Dock 'appearance'?

gamov avatar Mar 18 '13 08:03 gamov

If it goes away once the PDF is rendered, don't worry about it. It's just showing that the script is running on your machine. It won't happen in production.

Dreyfuzz avatar Apr 02 '13 23:04 Dreyfuzz

installing 0.9.9 worked for me,

is it possible that it's been two major releases since the last working version?

is this issue happening only to MAC users?

DonGiulio avatar Jan 24 '14 11:01 DonGiulio

As far as I've ever heard, this only affects OSX builds of wkhtmtopdf binaries. Most production systems run Linux or Windows, that do not suffer this strange behavior, and it is one of the reasons I have recommended in the past for people to stick with 0.9.6. I plan to investigate more this weekend, as that is quite old now, and a few major releases behind.

unixmonkey avatar Jan 25 '14 16:01 unixmonkey

For information, this seems to be fixed with last binary package from here http://wkhtmltopdf.org/downloads.html I just installed 0.12.1 (carbon edition) and it worked

dbourguignon avatar Jul 18 '14 07:07 dbourguignon

Well not so bright: I still have some PDF not working. Apparently it hangs for larger files like this : https://gist.github.com/dbourguignon/59668a75c739ced50eb4 with big CSS data But using command line on this file work well.

dbourguignon avatar Jul 18 '14 08:07 dbourguignon

~~wkhtmltopdf 0.12.2.1 with wicked_pdf 0.9.9 or 0.11.0 on OS X 10.10.1 got same problem.~~

See my next comment.

JuanitoFatas avatar Mar 27 '15 03:03 JuanitoFatas

For people who use Puma. You need at least 2 process worker. With only 1 worker it will freeze. Change to 2 workers worked for me. The number of process workers can be set in config/puma.rb.

JuanitoFatas avatar Mar 27 '15 03:03 JuanitoFatas

@JuanitoFatas I hang when using 'rails s' to serve my app on Mac. Any idea if this is related / is there a way to increase # of workers using the default rails s?

grantgeorge avatar May 23 '15 16:05 grantgeorge

Hi People I was struggling to make it work but I was having constant freezes, all as described in previous messages here. I am Cent OS 6.6 64bits, with latest binary 0.12.2.1 downloaded from http://wkhtmltopdf.org/downloads.html . I am new to this project, but when I heard lots of complain I thought that it would not be possible to use it.

Luckily after reading these posts and thanks to @beerlington saying that he had problem after installing the 0.11.0_rc1 I installed a previous version 0.10.0_rc2 which is now working fine with no freezes. I also noticed that even charts generated by flot improved quality with same settings I was using before.

It seems that problem occurred with version 0.11.0_rc1 and it is common to every platform.

Despite this, after all is working now smoothly, I can say it is a great project.

renatofb avatar Jul 11 '15 04:07 renatofb

It freezes with version 0.10.0 rc2.

TheFox avatar Feb 04 '16 22:02 TheFox

just comment below line if you face issues again (from application.rb).

config.middleware.use WickedPdf::Middleware

nagrgk avatar Apr 18 '16 23:04 nagrgk

The wkhtmltopdf (0.12.4 on MacOS) binary hangs if the following conditions are met:

  • wicked_pdf is used as middleware in a Rails app.
  • There are external resources (JS, CSS, images etc) used by the view.
  • The server is bound to localhost or 127.0.0.1

Funny enough, when I run the dumped wkhtmltopdf command in a separate terminal, the PDF is generated without any problem.

Here's a workaround: External resources must not be fetched from localhost. When I serve local development through a remote proxy which tunnels the request back to my locally running server, everything works just fine. (I haven't tried localtunnel, you might want to have a go.)

So the question seems to be: Why can wkhtmltopdf fetch resources from localhost when run in a full interactive shell, but fails to do so when run by wicked_pdf as middleware?

svoop avatar Dec 06 '17 15:12 svoop

@svoop The middleware is a lot dumber bout how it fetches resources. It catches the HTML as rendered before it gets served, and swaps out relative URLs with absolute ones here.

Otherwise, you'd have to customize every page to use wicked_pdf_* helpers, which is very un-middleware-like, in my opinion.

unixmonkey avatar Dec 06 '17 19:12 unixmonkey

Works for me with 127.0.0.1:3000 instead of localhost:3000

chorstikus avatar Jan 30 '18 16:01 chorstikus