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

Simon Urbanek @|mon@urb@nek @end|ng |rom R-project@org
Wed Aug 5 02:02:48 CEST 2020


Duncan,

how is quartz() related to rgl? I thought that now you only supported X11 which wouldn't involve quartz. In general, Cocoa windows are asynchronous, i.e. when the quartz device is created the window may not exist yet, but I'm not sure why that would affect rgl (quartz device draws to off-screen buffer so it doesn't mind if the windows doesn't exist yet). For the X11 device there could be significant delay with X11 (not related to quartz) if you don't have X11 running yet as users have typically DISPLAY set to a socket which will first start XQuartz if it's not up yet.

Cheers,
Simon



> On 5/08/2020, at 8:51 AM, Duncan Murdoch <murdoch.duncan using gmail.com> wrote:
> 
> 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
> 
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac



More information about the R-SIG-Mac mailing list