jhelvy / renderthis

An R package for building xaringan slides into multiple outputs, including html, pdf, png, gif, pptx, and mp4.
https://jhelvy.github.io/renderthis
Other
173 stars 12 forks source link

Time out error #43

Open albert-ying opened 2 years ago

albert-ying commented 2 years ago

Hi, when building to pdf from HTML, I got these errors

xaringanBuilder::build_pdf('xxx.html', complex_slides = T, partial_slides = T)
Error: Chromote: timed out waiting for response to command Target.createTarget

And sometimes

Error: Chromote: timed out waiting for event Page.loadEventFired

I'm wondering what may cause this and how may I prevent it?

Thank you!

albert-ying commented 2 years ago

I just tested. Same code works fine for a smaller HTML slides. Maybe it is due to the slide is too big and took a while to process, which is longer than the timed out limit and been killed? If so how do I adjust for the timed out limit?

jhelvy commented 2 years ago

Interesting problem, I haven't run into this before. Is there an html slide deck that you could link to so we could try and reproduce this error?

albert-ying commented 2 years ago

Not sure whether it is related, but I adjusted the size of some figures in the slides, now I don't see the error. I just opened a new issue #44 which might related to this

gadenbuie commented 2 years ago

The image size is likely the root cause of the problem -- I'd be interested to hear how large the image was before you reduced the size.

This does bring up that both pagedown::chrome_print() and chromote allow us to configure the timeout when waiting for the page load and we could expose this cleanly in build_pdf().

We'd add the wait arg to chrome_print() here (the default is 2) https://github.com/jhelvy/xaringanBuilder/blob/235c8c41d9e720fa48171fa8567839d2e042660d/R/pdf.R#L99-L102

And <ChromoteSession>$Page$loadEventFired() has a timeout_ argument (not sure what the specific default value is there), which we'd want to set here https://github.com/jhelvy/xaringanBuilder/blob/235c8c41d9e720fa48171fa8567839d2e042660d/R/pdf.R#L123-L124

albert-ying commented 2 years ago

I used to have ~30 pictures, each ~ 5Mb. I also noticed that sometimes by setting self-contain: true, the timeout error could be avoided. Probably because it take a long time to load pictures. It would be nice to be able to set the timeout limit as an argument from build_* functions in the future! Thank you so much!

gadenbuie commented 2 years ago

Ah that makes sense. 150MB of images isn't gigantic but it is fairly large. Check out the issue and linked Twitter thread in #26, there are some tips there about reducing the image size without losing quality!