0

I am trying to run a rgl shiny app, it works well on my computer but crashes on www.shinyapps.io.

I suspect that the 1GB memory is not enough as the shinyapps.io log tells me Container event from container-8564782: oom (out of memory).

It is 6 triangle3d() relatively complex objects in one rglwidget(). A button create a new translation of these 6 objects and plot it in a new rgl object. I tried to put lit=FALSE in the object to save memory, but it still crashes (not always though). I also suspect that the rgl object is not erased from memory when creating a new one. So I tried rglwidget options (reuse=NA, webGLoptions = list(preserveDrawingBuffer = FALSE)), but deploying for testing is not very efficient...

  • Is there a way to test the app locally with the same 1GB memory?
  • Are there other obvious ways to save memory when using rgl/shiny?

Any pointer welcome!

https://colomb.shinyapps.io/RANDOMstage/ core of the code:

observe({ 
    input$randomise 
    #### Create a random position of each objects using translate3d, plot them using triangle3d.
    amessage = random_obj( objects= objects, position_tot =position_tot, messagesday=messagesday, colorpalette=palette("Okabe-Ito"))
    
    output$rglPlot <- renderRglwidget({
      
      createboden()
      
      view3d (theta = 0, phi = -88, zoom = 0.8, fov = 60)
      outputwidget = rglwidget(reuse=NA, webGLoptions = list(preserveDrawingBuffer = FALSE))
      
      
      outputwidget

    
    })
Julien Colomb
  • 508
  • 4
  • 20
  • "Is there a way to test the app locally with the same 1GB memory?" See https://stackoverflow.com/questions/1395229/increasing-or-decreasing-the-memory-available-to-r-processes – smartse Aug 31 '23 at 09:07
  • Please show reproducible code. We can't suggest improvements if we don't know what you did. – user2554330 Aug 31 '23 at 09:56
  • Thanks. the memory question is only answered for windows user, also not sure whether memory for R would mean memory for shiny. reproducible code is here difficult, I do not want to make the code public at this point (the objects are not mine to share), and the memory issue would not appear in a simplified example. – Julien Colomb Sep 01 '23 at 10:59

1 Answers1

0

A major issue was the size of the objects. As objects were STL objects read via readSTL(), I minimised the complexity of the object first using a third party software. (https://3dless.com, objects went from 6MB to 100 kB). It now uses much less memory and runs on the server.

Julien Colomb
  • 508
  • 4
  • 20