Forum Bugs

Prince intermittently hangs for minutes

jerkob
We are having an issue where Prince will sometimes take several minutes to render a PDF. The problem is frequent, but inconsistent. We are generating PDFs by building HTML via PHP and then using the PHP wrapper to do string_to_passthru. What is so perplexing is that the exact same PDF will switch between coming up near instantly and hanging for minutes. So I can repeatedly refresh one of our URLs that outputs a PDF (i.e. http://example.com/pdf) and half the time it will generate in a second or so, and the other half it will take minutes. This seemed to start right around the time we upgraded to Prince 8.0, but I have since downgraded to Prince 7.1 and the problem is still happening. We are running Prince on an Xserve running OS X Server 10.6.7.
mikeday
Does the HTML passed to Prince refer to any images, style sheets, or fonts, that are accessed over HTTP? This can introduce unpredictable delays in the conversion process. If not, can you try enabling logging by calling setLog() and check the timestamps that show up in the log file? It may also be helpful to enable debugging by adding --debug to the Prince command-line.
jerkob
mikeday wrote:
Does the HTML passed to Prince refer to any images, style sheets, or fonts, that are accessed over HTTP? This can introduce unpredictable delays in the conversion process. If not, can you try enabling logging by calling setLog() and check the timestamps that show up in the log file? It may also be helpful to enable debugging by adding --debug to the Prince command-line.


We will look into these today. We do include some images that are accessed over http, but the Prince delays are far longer than normal web unpredictability. The unpredictable delays you reference - do you mean this in the general sense of "accessing web resources is unpredictable", or specifically that Prince has a unique issue where it can experience unusual delays when accessing web resources? Because any of the resources we are including I can access over the web over and over again and the variance in request time will be very small.

Another question, we are accessing our resources using URLs, but technically they live on the same box as Prince is running, so we could specify them using filesystem paths instead, I would think. Do you think that is worth pursuing?
mikeday
Accessing them directly using file paths should be more reliable in general. If they are on the same machine, then network latency should not be an issue. However, you can sometimes get unusual behaviour if Prince is called from a PHP page, which requests resources over HTTP from the same server. Sometimes servers have a maximum number of connections, and this can deadlock, as it cannot finish the first request until the second request succeeds, but the second request will be delayed until the first request succeeds. Awkward.
jerkob
mikeday wrote:
Accessing them directly using file paths should be more reliable in general. If they are on the same machine, then network latency should not be an issue. However, you can sometimes get unusual behaviour if Prince is called from a PHP page, which requests resources over HTTP from the same server. Sometimes servers have a maximum number of connections, and this can deadlock, as it cannot finish the first request until the second request succeeds, but the second request will be delayed until the first request succeeds. Awkward.


Thank you for this! After some testing we are pretty confident that the issue is this deadlock situation that you reference. For now we are changing to filepaths rather than URLs for our resources. Thanks for your help!