orca icon indicating copy to clipboard operation
orca copied to clipboard

error when exporting scatter3d image with orca under Xvfb

Open Marcin-Tabaka opened this issue 7 years ago • 6 comments

I am trying to export scatter3d plot using orca under xvfb. 2D scatter plots are exported correctly. The error occurs only for 3d scatter plots. I will appreciate any help.

library(plotly)

p <- plot_ly(x = 1:10, y = 1:10, color = 1:10)
b <- plotly_build(p)$x[c("data", "layout")]
json <- plotly:::to_JSON(b)

write(json, file="test_1.json")

p <- plot_ly(x = 1:10, y = 1:10, z=1:10, color = 1:10)
b <- plotly_build(p)$x[c("data", "layout")]
json <- plotly:::to_JSON(b)

write(json, file="test_2.json")
test@bc6ecceb987e:~$ orca graph test_1.json -o test_1.png
test@bc6ecceb987e:~$ orca graph test_2.json -o test_2.png

done with code 1 in 154.64 ms - failed or incomplete task(s)
test@bc6ecceb987e:~$ cat `which orca`
#!/bin/bash
xvfb-run  /usr/bin/orca "$@"

Marcin-Tabaka avatar Sep 04 '18 19:09 Marcin-Tabaka

I suspect you're using orca in a headless environment.

You could try using

https://github.com/plotly/orca/blob/d50563f4d6dbc20c4a5a37e15c9465f90e97a37a/deployment/run_server#L29

as we do in our image server.

If that still doesn't work, could tell us a bit more about how you're running orca? Thank you.

etpinard avatar Sep 04 '18 20:09 etpinard

Yes, I am trying to run it as a docker image. I have the following lines in a Dockerfile:

RUN apt-get update --fix-missing \
	 && apt-get install -y \
	    ca-certificates \
    	    libglib2.0-0 \
	    libxext6 \
	    libsm6  \
	    libxrender1 \
	    libxml2-dev \
            libglu1-mesa-dev \
            freeglut3-dev \
            mesa-common-dev \
            libxext-dev \
            libxrender-dev \
            libxtst-dev \
            libxss1 \
            libgconf-2-4 \
            libnss3 \
            libasound2 \
            x11vnc \
            xvfb \
            xauth \
            xfonts-base \
             libxt-dev
RUN conda install -c plotly plotly-orca
RUN cp /usr/local/bin/orca /usr/bin/orca
RUN echo '#!/bin/bash\nxvfb-run  /usr/bin/orca "$@" ' > /usr/local/bin/orca && \ 
         chmod +x /usr/local/bin/orca

This works for 2d plots but fails for 3d. I don't know how to run xvfb as a server as you suggested. Any ideas how to modify Dockerfile to get it working? Thank you.

Marcin-Tabaka avatar Sep 05 '18 18:09 Marcin-Tabaka

@Marcin-Tabaka I ran into the same issue and adding --enable-webgl fixed it for me

cpsievert avatar Oct 04 '18 00:10 cpsievert

Interesting. Thanks for posting @cpsievert !

Maybe we should add that flag along side this one:

https://github.com/plotly/orca/blob/a0e7314a784802b4824b359aeff891e0d40be184/src/util/init-app.js#L10

etpinard avatar Oct 04 '18 01:10 etpinard

@Marcin-Tabaka was adding --enable-webgl (like @cpsievert proposed in https://github.com/plotly/orca/issues/127#issuecomment-426847504) enough to solve your problems?

etpinard avatar Dec 28 '18 19:12 etpinard

Coming here from #97. if I'm using the flag correctly, --enable-webgl does not get around the error for me (Linux 5.10.3-arch1-1) but using the 1.1.1 app image does! 1.3.1 appimage errors in the same way.

plotly::orca also works from R, but only with processx::run and not with system.

My current work around is to mv the 1.1.1 Appimage to ~/bin/orca with $HOME/bin first in $PATH

glxgears
302 frames in 5.0 seconds = 60.397 FPS

which orca
/home/foranw/.local/bin/orca

orca --version
1.3.1

orca graph '{ "data": [{"y": [1,2,1]}] }' --enable-webgl -o /tmp/test_orca.png
[284617:0105/090736.711049:ERROR:buffer_manager.cc(488)] [.DisplayCompositor]GL ERROR :GL_INVALID_OPERATION : glBufferData: <- error from previous GL command

 ./orca-1.1.1-x86_64.AppImage graph '{ "data": [{"y": [1,2,1]}] }' -o /tmp/test_orca.png
# success!

 ./orca-1.3.1.AppImage graph '{ "data": [{"y": [1,2,1]}] }' -o /tmp/test_orca.png
[292859:0105/101120.487253:ERROR:buffer_manager.cc(488)] [.DisplayCompositor]GL ERROR :GL_INVALID_OPERATION : glBufferData: <- error from previous GL command

plotly::orca from R produces a plot without error:

library(plotly)
orca(plot_ly(y = c(1, 2, 1), type="scatter", mode="markers"), "testme.png")

I edited the orca R function to print the command it runs (processx::run). Works in R but not in bash. I cannot find what's different between the two environments!

processx::run("orca", c("graph", "/tmp/RtmptwshDC/file4652a73d344dc.json", "-o", "testme.png", "--format", "png", "--plotlyjs", "/home/foranw/R/x86_64-pc-linux-gnu-library/4.0/plotly/htmlwidgets/lib/plotlyjs/plotly-latest.min.js"), echo=T, spinner=T)
$status
[1] 0

$stdout
[1] ""

$stderr
[1] ""

$timeout
[1] FALSE

Using system in R gives the same error as in bash

 system("orca graph /tmp/RtmptwshDC/file4652a73d344dc.json -o testme.png --format png --plotlyjs /home/foranw/R/x86_64-pc-linux-gnu-library/4.0/plotly/htmlwidgets/lib/plotlyjs/plotly-latest.min.js ")
[290703:0105/100155.566517:ERROR:buffer_manager.cc(488)] [.DisplayCompositor]GL ERROR :GL_INVALID_OPERATION : glBufferData: <- error from previous GL command

WillForan avatar Jan 05 '21 14:01 WillForan