1

In RStudio the following code will display a 3D plot in a shiny app and also in a separate RGL device. Everything works as expected when axes are not displayed.

When axes are displayed and when I try to move the 3D object, all the 3D points vanish in the shiny viewer (but all is fine in the separate RGL window, suggesting a problem with shiny).

This strange behavior occurs only when I run this code on a remote machine using a VNC connection via SSH, or just when I forward X11 over SSH. The code works well on my local machine, running the exact same versions of R (3.4.1), Rstudio (1.1.383), RGL (0.98.22) and Shiny (1.0.4).

Is there some kind of low level (X11/OpenGL-related?) parameter I could tweak in RStudio/Shiny to fix this ?

options(rgl.useNULL = FALSE)  # this is intentional

library(rgl)   # 0.98.22
library(shiny) # 1.0.4

app = shinyApp(
  ui = bootstrapPage(checkboxInput("axes", "axes"),
                     rglwidgetOutput("rglPlot")),
  server = function(input, output) {
    output$rglPlot <- renderRglwidget({
      try(rgl.close(), silent = TRUE)
      if (input$axes) axes3d()          
      points3d(rnorm(100),rnorm(100),rnorm(100))
      rglwidget()
    })
  }
)

enter image description here

EDIT & ANSWER

I happens the remote machine, despite having the same version of R and R packages, did not have the same version of Linux the mesa 3D library (it's an AWS-based Linux AMI, locked at the 2017.03 version)

The fix was to run :

yum install mesa-libGL-devel-17.1.5-2.41.amzn1.x86_64 
Olivier Delrieu
  • 742
  • 6
  • 16
  • Do you get the problem just executing `rglwidget()` in the console? What versions of the packages are you using? – user2554330 Jan 05 '18 at 11:24
  • `rglwidget()` works well in the console. This problem seems to be related to HTML WebGL rendering over VNC. The problem happens also with `demo("simpleShinyRgl")` : as soon as I move the object, the red dots vanish. My current workaround is to use a shiny server on the remote machine. – Olivier Delrieu Jan 05 '18 at 12:29
  • It seems unlikely that VNC would be the problem: you're seeing the axes, so some stuff is getting through. It's more likely a problem with the Shiny/rgl interaction. – user2554330 Jan 06 '18 at 11:59
  • I can sort of reproduce this. I don't see the same symptoms as you, but things don't work properly. It appears that the scene is not being updated properly. For example, if I change the number of points being plotted, I don't see that happening in the display. (I see points, not axis; you might need to play with their scale.) I also see problems with that demo. It seems not so easy to debug... – user2554330 Jan 06 '18 at 12:11
  • Could you try the latest version? There was a bug in Shiny initialization which should now be fixed. https://stackoverflow.com/questions/37142762/how-do-i-install-the-latest-version-of-rgl – user2554330 Jan 06 '18 at 13:03
  • Many thanks. Same problem with rgl 0.99.6 and shiny 1.0.5. There may be other relevant differences between my local and remote machines (such as X11 versions) : I'll keep investigating. You're right about VNC: it happens also with a direct X11 connection over SSH. – Olivier Delrieu Jan 07 '18 at 13:50
  • It works on my local machine, does not on the remote machine we use in our production environment, but it does work on a remote machine we use for development. The production machine is based on EC2 AWS linux 2017.03 (Ireland ami-ebd02392), the development machine is based on AWS linux 2017.09 (Ireland ami-acd005d5). Our AMIs have been 'locked' to specific package versions to make our environment stable. What could be the packages involved in this I could try to update? – Olivier Delrieu Jan 07 '18 at 21:33
  • You definitely will need rgl 0.99.6. I'm using shiny 1.0.5, but I suspect older versions would work too. – user2554330 Jan 07 '18 at 21:44
  • Sorry, I meant other _linux_ packages. ( rgl 0.99.6 and shiny 1.0.5 in our production environment have the same problem ). For example rgl is using `mesa-libGLU-devel, tk-devel and tcl-devel` I believe. – Olivier Delrieu Jan 07 '18 at 22:27
  • Found the culprit !!! `yum update mesa*` on our production platform makes the app work. I'll try to be more accurate (tomorrow) and get you the hopefully single mesa package at fault, so that you can trace this better if you still experience it. – Olivier Delrieu Jan 07 '18 at 22:55
  • I don't think the `rgl` package needs the Tcl/Tk stuff, but it depends to a huge extent on `mesa*` when doing displays within R, and I imagine the WebGL stuff used by Shiny also depends on it. – user2554330 Jan 07 '18 at 23:09

0 Answers0