[R] rgl snapshot on headless server

Duncan Murdoch murdoch.duncan at gmail.com
Tue Sep 10 18:38:31 CEST 2013


On 10/09/2013 10:58 AM, Andreas Maunz wrote:
> Hi all,
>
> I have a shiny app, in which I want to use rgl's snapshot function. I am
> running Xvfb on my server so that rgl works. I start my shiny app as
> follows:
>
> echo "Checking for Xvfb..."
> pgrep -U username Xvfb > /dev/null 2>&1
>
> if [ "$?" -gt 0 ]; then
>    echo "Starting Xvfb..."
>    Xvfb :7 -screen 0 1280x1024x24 &
>    sleep 2
> fi
>
> echo "...starting shiny"
> export DISPLAY=":7"; R --no-save --no-restore -e "library('shiny');
> runApp('/path/to/app', port=8101)"
>
> In the app, I do plot3d(), generate webGL and send the results to the
> browser. But the rgl.snapshot or rgl.postscript functionality do not work,
> i.e. they produce black or empty images. I assume this is due to Xvfb. Any
> chance I can create snapshots?

rgl.snapshot requires the X server to maintain a frame buffer that it 
can read.   It looks as though something is going wrong with yours.  I 
don't use a system with Xvfb, so I can't really help, but you could try 
Googling to see if that turns anything up.

rgl.postscript shouldn't need the X server, but it is limited in what it 
can display.

Duncan Murdoch



More information about the R-help mailing list