[R-SIG-Mac] Workaround for crash due to rgl and base graphics conflict

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Tue Aug 4 22:51:28 CEST 2020


I seem to have a workaround for the rgl-related crash.  If I insert a 
one second delay after the first quartz() device is opened but before 
anything is plotted, then I don't see the crash.  This script does that 
if the RGL_SLOW_DEV environment variable is non-empty:



if (nchar(Sys.getenv("RGL_SLOW_DEV")))
   options(device = local({
     olddev <- getOption("device")
     function(...) {
       olddev(...)
       Sys.sleep(1)
       options(device = olddev)
     }
   }))

library(rgl)
plot(1:10)


The last two lines are the code to trigger a crash.  I'm seeing pretty 
regular crashes if I source this without RGL_SLOW_DEV being set, but 
setting it seems to make things work.  I tried reducing the delay to 0.1 
seconds and it didn't work.

I'd hypothesize that what's happening is that some part of the 
initialization of the quartz() window is asynchronous with the main R 
thread, and in Catalina something about rgl makes it so slow that the 
window isn't ready when R starts plotting there.  But I don't know the 
quartz() device code, so this might not be right at all.

Duncan Murdoch



More information about the R-SIG-Mac mailing list