Skip to content

[R-pkg-devel] how to make "r-release-osx-x86_64-mavericks" machine support rgl 3D plots

5 messages · Duncan Murdoch, Dr Gregory Jefferis

#
Dear Duncan,
On 8 Oct 2015, at 22:10, Duncan Murdoch wrote:

            
[snip]
I tried following this suggestion, but this has the unintended (for me) 
consequence that it is no longer possible to get rgl snapshots e.g. in 
knitr when rgl.useNULL=TRUE? From what I can see writeWebGL works fine 
but snapshot3d does not and this is not quite what I was expecting 
(though it seems fair enough in retrospect).

Is there a workaround to get snapshots out of a RGL null display?

If not, I think I am back to square 1 in terms of trying to figure out 
how to suppress rgl *examples* (tests are easy) on CRAN.

With many thanks,

Greg.
R version 3.2.3 (2015-12-10)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.9.5 (Mavericks)

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] nat.nblast_1.6.1 catmaid_0.6      httr_1.0.0       nat_1.8.1        
rgl_0.95.1435    devtools_1.9.1

loaded via a namespace (and not attached):
  [1] Rcpp_0.12.2        formatR_1.2.1      plyr_1.8.3         
nabor_0.4.6        tools_3.2.3
  [6] nat.utils_0.5.1    digest_0.6.8       jsonlite_0.9.19    
memoise_0.2.1      filehash_2.3
[11] igraph_1.0.1       curl_0.9.4         yaml_2.1.13        spam_1.3-0 
         stringr_1.0.0
[16] knitr_1.11         dendroextras_0.2.1 grid_3.2.3         R6_2.1.1   
         rmarkdown_0.7
[21] magrittr_1.5       codetools_0.2-14   htmltools_0.2.6    
rsconnect_0.3.79   stringi_1.0-1





--
Gregory Jefferis, PhD
Division of Neurobiology
MRC Laboratory of Molecular Biology
Francis Crick Avenue
Cambridge Biomedical Campus
Cambridge, CB2 OQH, UK

http://www2.mrc-lmb.cam.ac.uk/group-leaders/h-to-m/g-jefferis
http://jefferislab.org
http://flybrain.stanford.edu
#
On 30/12/2015 3:54 PM, Dr Gregory Jefferis wrote:
No.  Theoretically it's possible to use a virtual frame buffer in X11 to 
hold the image, but I've got no experience with that myself.
You can test for a null device using rgl.useNULL().  If that is true, 
don't try to produce a snapshot.

Duncan Murdoch
#
On 30 Dec 2015, at 21:11, Duncan Murdoch wrote:

            
OK. Thanks for confirming.
I have used xvfb in some headless environments (including travis).
I wasn't being clear there. I want to have rgl example code (e.g. plot3d 
statements) in my documentation

* that's not enclosed in conditionals
* or \dontrun
* but that doesn't use a live rgl window during package check 
(especially on CRAN)
* ... unless I do something to request this.

The code is not actually making snapshots.

I think what I may try is changing my .onLoad to look something like 
this:

.onLoad <- function(libname, pkgname) {

   DEVTOOLS_CRAN=toupper(Sys.getenv("NOT_CRAN")) %in% c("FALSE","0", 
"NO")

   # this is a heuristic to determine if we are running on CRAN
   CRAN=toupper(Sys.getenv("_R_CHECK_INSTALL_DEPENDS_")) %in% c("TRUE", 
"YES", "1")

   if(!interactive() && is.null(getOption('rgl.useNULL')) && 
(DEVTOOLS_CRAN || CRAN)){
     options(rgl.useNULL=TRUE)
   }

}

Thanks again,

Greg.

--
Gregory Jefferis, PhD
Division of Neurobiology
MRC Laboratory of Molecular Biology
Francis Crick Avenue
Cambridge Biomedical Campus
Cambridge, CB2 OQH, UK

http://www2.mrc-lmb.cam.ac.uk/group-leaders/h-to-m/g-jefferis
http://jefferislab.org
http://flybrain.stanford.edu
#
On 30/12/2015 4:42 PM, Dr Gregory Jefferis wrote:
I'm not sure I understand why.  Why not write examples that produce rgl 
displays (or nothing with a null device)?  rgl itself has lots of these, 
and passes checks on most systems.  Currently it is supposed to detect 
display initialization failures and fall back to the null device, but I 
don't know if this works on the only CRAN system that seems to need it, 
the OSX system, because I haven't seen results of tests yet.
I would be careful about that -- the CRAN people want to run realistic 
tests, and they will likely object if you are trying to act differently 
on their system than on your users' systems.

Duncan Murdoch
#
Dear Duncan,
On 31 Dec 2015, at 0:28, Duncan Murdoch wrote:

            
My packages are used by a small community of neuroscientists with 
varying degrees of expertise in running /installing / compiling code. 
Not infrequently using these packages is the first time they use R. Most 
use macs. The mac binary version of the main nat package was out of date 
for about 6 months because it could not be built on the CRAN mac because 
of some kind of rgl problem on that machine (you probably know what that 
was - I presume it was difficult to fix!). This forces my users to use 
devtools for installation and also means that the install instructions 
for downstream packages depending on nat are insufficient because they 
assume that nat can be fetched from CRAN.

By running rgl with the null device on CRAN I still exercise the 
relevant code but insulate myself from this kind of issue.
[snip]
You're right that's something to be careful about. I guess I want to use 
the null device during check, not just on CRAN ? it's annoying to have 
X11 windows cropping up when coding. I'd argue, that this is actually 
less restrictive than skipping tests on CRAN ? which as far as I know 
is perfectly acceptable. The problem is that there are no simple 
mechanisms to skip example code (rather than tests) ? hence the 
approach of putting code to test/set rgl.useNULL status in .onLoad that 
you originally suggested.

Thanks again for advice/feedback.

Best wishes	,

Greg.

--
Gregory Jefferis, PhD
Division of Neurobiology
MRC Laboratory of Molecular Biology
Francis Crick Avenue
Cambridge Biomedical Campus
Cambridge, CB2 OQH, UK

http://www2.mrc-lmb.cam.ac.uk/group-leaders/h-to-m/g-jefferis
http://jefferislab.org
http://flybrain.stanford.edu