ropensci / magick

Magic, madness, heaven, sin
https://docs.ropensci.org/magick
Other
456 stars 63 forks source link

error when hosted at shinyapps.io #311

Open dcaud opened 3 years ago

dcaud commented 3 years ago

I'm getting the error below when trying to write a multi-page pdf using image_write_pdf().

Error in magick_image_map: R: cache resources exhausted `' @ error/cache.c/OpenPixelCache/4083

Here's a code snippet that is likely where the cache is exceeded:

a.series.of.about.15.images %>% image_write(
          tempfile(pattern = "pdftemp", fileext = '.pdf'),
          density = 300,
          format = 'pdf'
        )

This stackoverflow answer suggests that I edit policy.xml, but I can't do that on shinyapps.io.

Is there any way that your magick package for R can be modified to prevent needing to edit policy.xml. I ask because this is the 2nd similar issue I've had and getting Rstudio to change those server files takes weeks...and they may not do it. I'm worried that if I get this error fixed then another will pop up!

Thanks!

dcaud commented 3 years ago

A little more context:

This error does not appear when I run this on my local Mac or on a linux server with policy xml changed to:

 <policy domain="resource" name="memory" value="4GiB"/>
  <policy domain="resource" name="map" value="6GiB"/>
  <policy domain="resource" name="width" value="116KP"/>
  <policy domain="resource" name="height" value="116KP"/>
  <!-- <policy domain="resource" name="list-length" value="128"/> -->
  <policy domain="resource" name="area" value="1128MB"/>
  <policy domain="resource" name="disk" value="4GiB"/>
marcjwilliams1 commented 3 years ago

I'm also getting this error when using a docker image. Did anyone find a workaround?

jhelvy commented 2 years ago

Here to say I have the same issue. The problem is exclusive to the app being hosted on shinaapps.io. When I run my app locally, I never have this problem.

dcaud commented 2 years ago

Likely is a memory problem, @jhelvy. Do you have the 8GB version selected on shinyapps.io? Also, a re-install of the app may be required, b/c shinyapps.io updated the magick policies a few month ago -- those only get applied to re-installed apps, I think.

@marcjwilliams1 Removing the policy.xml file may help. Or increasing the values of the resources.

jhelvy commented 2 years ago

Yes I'm at 8GB. I can re-install to see if that helps.

I made a related post in the RStudio community in case someone there has a solution.

dcaud commented 2 years ago

For more, see here: https://github.com/rstudio/shinyapps-package-dependencies/issues/320