I can't get rgl to save snapshots or gifs

68 Views Asked by At

I can't figure out what is missing to run rgl smoothly. My code and output:

pacman::p_load("rgl", "scales", "magick","webshot2")
rgl::plot3d(1:20, 1:20, 1:20)
snapshot3d("~/snap.png", fmt = "png")
movie3d(spin3d(axis=c(0,0,1), rpm=), duration=2, movie="3D-SPIN", verbose=TRUE, type="gif",fps = 2)

Output:

> pacman::p_load("rgl", "scales", "magick","webshot2")
> rgl::plot3d(1:20, 1:20, 1:20)
> snapshot3d("~/snap.png", fmt = "png")
Error : Chromote: timed out waiting for event Page.loadEventFired
Warning: webshot2::webshot() failed; trying rgl.snapshot()Warning: this build of rgl does not support snapshots
> movie3d(spin3d(axis=c(0,0,1), rpm=), duration=2, movie="3D-SPIN", verbose=TRUE, type="gif",fps = 2)
Error : Chromote: timed out waiting for event Page.loadEventFired
Error : Chromote: timed out waiting for event Page.loadEventFired: this build of rgl does not support snapshotsWriting '3D-SPIN001.png'
Error : Chromote: timed out waiting for event Page.loadEventFired: this build of rgl does not support snapshotsWriting '3D-SPIN002.png'
Error : Chromote: timed out waiting for event Page.loadEventFired: this build of rgl does not support snapshotsWriting '3D-SPIN003.png'
Error : Chromote: timed out waiting for event Page.loadEventFired: this build of rgl does not support snapshotsWriting '3D-SPIN004.png'
Warning: webshot2::webshot() failed; trying rgl.snapshot()Warning: this build of rgl does not support snapshots

Session Info:

R version 4.3.2 (2023-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.2.1

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

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

time zone: Asia/Tokyo
tzcode source: internal

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

other attached packages:
 [1] plot3Drgl_1.0.4       plot3D_1.4            webshot2_0.1.1        magick_2.8.2          installr_0.23.4       scales_1.2.1         
 [7] rgl_1.2.8             plotly_4.10.3         SeuratDisk_0.0.0.9020 remotes_2.4.2         GenomicRanges_1.52.0  GenomeInfoDb_1.36.1  
[13] IRanges_2.34.1        S4Vectors_0.38.1      BiocGenerics_0.46.0   Signac_1.12.0         Seurat_5.0.1          SeuratObject_5.0.1   
[19] sp_2.0-0              lubridate_1.9.3       forcats_1.0.0         stringr_1.5.1         dplyr_1.1.2           purrr_1.0.2          
[25] readr_2.1.4           tidyr_1.3.0           tibble_3.2.1          ggplot2_3.4.2         tidyverse_2.0.0       devtools_2.4.5       
[31] usethis_2.2.2   

I installed google chrome. The rglWebGL loads the plot in the html widget, but all the saved png or gif files are solid black/empty. I am not sure exactly what is wrong/missing, and I have tried fiddling with variety of things but nothing changed yet.

Thanks for any help

1

There are 1 best solutions below

3
On

From these messages:

Error : Chromote: timed out waiting for event Page.loadEventFired
Warning: webshot2::webshot() failed; trying rgl.snapshot()Warning: this build of rgl does not support snapshots

there appear to be two problems. First, it tries to use the webshot2::webshot() function to take an image, and that fails. Then it falls back to trying to create the image itself by copying from XQuartz on your screen, and that fails too, because rgl is running without OpenGL support.

If you could run rgl with OpenGL support that could fix the second failure. You might need to install XQuartz if you don't already have it installed, and then you should be able to see the plot3d() result pop up in a separate window, and the PNG files would be copies of what you have on screen.

I don't know why webshot2::webshot() is failing. You might try installing the development version from Github; use

remotes::install_github("rstudio/webshot2")

to do that. I can't tell what version of chromote you are using; 0.1.2 is the current release, so updating to that might help if you have an older one.