Skip to content

Commit cc89b0e

Browse files
committed
turns out '--enable-webgl' is required to export webgl on headless ubuntu
1 parent 0d618a1 commit cc89b0e

3 files changed

Lines changed: 11 additions & 9 deletions

File tree

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ RUN R -e "install.packages('roxygen2')"
9696

9797
# configure for visual testing
9898
ENV VDIFFR=true
99-
ENV VDIFFR_ARGS="--disable-gpu"
10099
EXPOSE 3838
101100
COPY ./ /home/plotly
102101

R/orca.R

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,18 @@
2626
#' @param debug Starts app in debug mode and turn on verbose logs on stdout.
2727
#' @param safe Turns on safe mode: where figures likely to make browser window
2828
#' hang during image generating are skipped.
29+
#' @param more_args additional arguments to pass along to system command. This is useful
30+
#' for specifying display and/or electron options, such as `--enable-webgl` or `--disable-gpu`.
31+
#' @param ... additional arguments passed along to `processx::run()`
2932
#' @export
3033
#' @author Carson Sievert
3134
#' @md
3235
#' @rdname orca
3336
#' @examples
3437
#'
3538
#' \dontrun{
39+
#' # NOTE: in a headless environment, you may need to set `more_args="--enable-webgl"`
40+
#' # to export webgl correctly
3641
#' p <- plot_ly(z = ~volcano) %>% add_surface()
3742
#' orca(p, "surface-plot.svg")
3843
#'
@@ -59,7 +64,7 @@
5964
orca <- function(p, file = "plot.png", format = tools::file_ext(file),
6065
scale = NULL, width = NULL, height = NULL, mathjax = FALSE,
6166
parallel_limit = NULL, verbose = FALSE, debug = FALSE,
62-
safe = FALSE) {
67+
safe = FALSE, more_args = NULL, ...) {
6368

6469
orca_available()
6570

@@ -79,7 +84,8 @@ orca <- function(p, file = "plot.png", format = tools::file_ext(file),
7984
"--plotlyjs", plotlyjs_file,
8085
if (debug) "--debug",
8186
if (verbose) "--verbose",
82-
if (safe) "--safe-mode"
87+
if (safe) "--safe-mode",
88+
more_args
8389
)
8490

8591
if (!is.null(scale)) args <- c(args, "--scale", scale)
@@ -91,7 +97,7 @@ orca <- function(p, file = "plot.png", format = tools::file_ext(file),
9197

9298
# TODO: point to local topojson? Should this only work if plot_geo(standalone = TRUE)?
9399
try_library("processx", "orca")
94-
invisible(processx::run("orca", args, echo = TRUE, spinner = TRUE))
100+
invisible(processx::run("orca", args, echo = TRUE, spinner = TRUE, ...))
95101
}
96102

97103
#' Orca image export server
@@ -102,8 +108,6 @@ orca <- function(p, file = "plot.png", format = tools::file_ext(file),
102108
#' @param window_max_number Sets maximum number of browser windows the server can keep open at a given time.
103109
#' @param request_limit Sets a request limit that makes orca exit when reached.
104110
#' @param quiet Suppress all logging info.
105-
#' @param more_args additional arguments to pass along to system command. This is mainly useful
106-
#' for specifying electron options, such as `--disable-gpu`.
107111
#' @param ... arguments passed along to `processx::process$new()`.
108112
#'
109113
#' @section Methods:

tests/testthat/helper-vdiffr.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ enable_vdiffr <- as.logical(Sys.getenv("VDIFFR", FALSE))
44
# start up the image server and let vdiffr's svg writing method know about it
55
if (enable_vdiffr) {
66

7-
args <- Sys.getenv("VDIFFR_ARGS", NA)
8-
args <- if (is.na(args)) NULL else args
9-
orcaServer <- orca_serve(more_args = args)
7+
# init image server with webgl enabled
8+
orcaServer <- orca_serve(more_args = "--enable-webgl")
109

1110
# define logic for writing svg in vdiffr
1211
write_svg.plotly <- function(p, file, title, user_fonts = NULL) {

0 commit comments

Comments
 (0)