[Xquartz-dev] Help requested debugging rgl under XQuartz

Duncan Murdoch murdoch.duncan at gmail.com
Mon Feb 22 07:13:43 PST 2021


I hope this is the right list for this request.

I'm the developer of the rgl package for R, which uses glX to produce 
displays in macOS and Linux.

It contains some kind of bug, which can be triggered (in both XQuartz 
2.7.11 and 2.8.0beta4) by the following script run in R in a terminal:

   library(rgl)  # Load the package; it opens and closes a glX window
                 # during initialization
   quartz()      # Open a regular R graphics window that works directly
                 # with Quartz
   open3d()      # Attempt to open a glX window

This produces the following errors:

  error: xp_attach_gl_context returned: 2
  Error in rgl.open(useNULL) : 'rgl.open' failed
  In addition: Warning message:
  In rgl.open(useNULL) : RGL: ERROR: can't bind glx context to window

The first line appears to be coming from XQuartz when the C++ code 
attempts to execute

   glXMakeCurrent(factory->xdisplay, xwindow, glxctx)

in the X11WindowImpl::beginGL function.  The other lines are coming from 
rgl or R.

I'm reasonably sure this is a bug in my code, because I can successfully 
run glxgears from R, and open x11() windows in R, but after lots of time 
debugging I can't figure out where the problem is.

Can anyone here suggest the kinds of issues that would lead to the 
"error: xp_attach_gl_context returned: 2" message, and ways to track 
down the underlying problem?

If anyone wants to try the code, it's probably best to use the update of 
rgl that's at

   www.murdoch-sutherland.com/temp/rgl_0.105.14.2.tar.gz

which fixes some bugs in the CRAN version.

Duncan Murdoch


More information about the Xquartz-dev mailing list