[R-pkg-devel] Catching console messages from libGL

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Mon Feb 17 20:56:31 CET 2020


I'm working on the initialization code for rgl, especially for the case 
when it is running remotely and the user is connecting using X11.

On some machines, this fails:  I now understand that's because the local 
machine needs to enable "indirect GLX" (IGLX) for it to succeed, and by 
default most current machines have IGLX disabled.  (It can be a security 
risk to enable it.)

Failure looks like this (with the current CRAN version of rgl 0.100.47, 
and the remote system running Ubuntu, my local system running MacOS):

 > library(rgl)
 > open3d()
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
X Error of failed request:  GLXBadContext
   Major opcode of failed request:  149 (GLX)
   Minor opcode of failed request:  6 (X_GLXIsDirect)
   Serial number of failed request:  42
   Current serial number in output stream:  41

I end up booted right out of R.  I now know how to fix that, and will 
upload an update to CRAN in due course.

On MacOS I can enable IGLX by running

   defaults write org.macosforge.xquartz.X11 enable_iglx -bool true

and restarting XQuartz.  When I do that, I see this (same setup as before):

 > library(rgl)
 > open3d()
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
glX
   1

Now I want to suppress those two libGL messages, and I'm having trouble 
figuring out how to do it.  If I redirect stderr when I start R, they 
are redirected:  but if I do it after starting R, they aren't:

 > library(rgl)
 > capture.output(open3d(), type = "message")
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
glX
   1
character(0)

(capture.output with type = "output" gets c("glX", "1"), but leaves the 
libGL messages printing to the console.  sink() behaves similarly.)

So how do I capture stderr (or, off topic here, how do I get libGL to be 
quiet)?

Duncan Murdoch



More information about the R-package-devel mailing list