Vscode, plots.jl and plotly()

Running latest vscode julia extension 1.65.2 with julia 1.10, the following code will run in the (vscode) julia terminal, with the plot appearing in the web browser, but, if run in the vscode editor, it does not plot in the vscode plot pane. Instead, I get a message in the plot pane that “WebGL is not supported by your browser”

f(x,y) = -(3*(1-x)^2 * exp(-(x^2) - (y+1)^2)
    - 6*(x/5 - x^3 - y^5) * exp(-x^2 - y^2)
    - 1/3 * exp(-(x+1)^2 - y^2))
 
##
# let's explore it:
using Plots
plotly() # this backend makes nice 3d plots
x = range(-4, step=0.1, stop=4)
y = x
surface(x, y, (x,y)->f(x,y),c=:viridis)
xlabel!("x")
ylabel!("y")

Hello mcreel

Yes, I have the same problem.
What I can say is that it used to work, but I don’t know why it doesn’t work anymore.
for me, it’s PlotlyJS that shows this exact behavior, but it worked before

If anyone can help me, that would be great, otherwise we should learn to trace using Mackie.

Naceur

This is browser related.

@mcreel Do you use Safari on macOS? If so: which versions?

To check if your browser supports WebGL: https://get.webgl.org

2 Likes

This code runs fine from the REPL, and the plot appears in Google Chrome. So, there is no browser problem.

However, if the code is run from VScode’s edit pane, the plot does not appear in the plot pane, and the error message that I mentioned appears instead. In the past, the plot did appear in the plot pane.

1 Like

This works fine on my reference deployment using the jupyterlab/julia/pubtools image:


OS: Debian 12 (bookworm), Architecture: x86_64
code-server v4.20.0 (aka Code v1.85.1)
Code Julia extension v1.66.2
Julia v1.10.0

(IJulia v1.24.2)
Plots v1.39.0


You may try yourself at https://demo.jupyter.b-data.ch. Login with GitHub account.

2 Likes

Oops, sorry for the noise. It seems that I had removed Plotly as a dep from the project, and forgot to add it back in. So, problem solved.

2 Likes

I will test this

Thanks !

Bizarrely enough, I am seeing the problem again, without having made any changes to my Julia or VScode setups.

1 Like

Yep!

That’s the problem!

I don’t have this problem on my HP laptop, but it happens on my desktop computer, which is some kind of game console I have. That isn’t made by a company, someone put together a GeForce with an AMD processor and sold it.
I’m really starting not to trust this kind of device for my humble research work anymore :unamused: maybe it has something to do with that Nvidia being for games only?

I don’t know if this is a problem with the VScode extension, with Plots.jl, or with the plotly() backend as used by Plots.jl. If Someone knows, I can file a proper bug report in the correct place.

To summarize, the code at the end of this message works correctly from the Julia REPL, but it does not produce a plot in the VScode plot pane. Instead, in the plot pane, the message “WebGL is not supported by your browser” is shown. In the past, the code produced a surface plot in the plot pane.

Versions are
julia> versioninfo()
Julia Version 1.10.0
Commit 3120989f39b (2023-12-25 18:01 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 8 × Intel(R) Core™ i5-10210U CPU @ 1.60GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, skylake)
Threads: 1 on 8 virtual cores

The packages in the Project.toml are:
(plotly) pkg> st
Status ~/Desktop/plotly/Project.toml
[58dd65bb] Plotly v0.4.1
[91a5bcdd] Plots v1.39.

VScode julia extension 1.66.2

using Pkg
Pkg.activate(@__DIR__)

f(x,y) = -(3*(1-x)^2 * exp(-(x^2) - (y+1)^2)
    - 6*(x/5 - x^3 - y^5) * exp(-x^2 - y^2)
    - 1/3 * exp(-(x+1)^2 - y^2))
 
##
# let's explore it:
using Plots
plotly() # this backend makes nice 3d plots
x = range(-4, step=0.1, stop=4)
y = x
surface(x, y, (x,y)->f(x,y),c=:viridis)
xlabel!("x")
ylabel!("y")

Just fine on Jupyter or JupyterLab as s explained by @benz0li
When it comes to Vscode :
the @benz0li small code works fine on a machine like Dell or HP, but not anymore with my anonymous box using GeForce and AMD processor

I do not know why !

Nice day to all

Naceur

I’m also using Debian, testing, with the same Julia, VScode and julia extension for Vscode, and same Plots. I don’t know the role of IJulia in this, though, I don’t use it.

IJulia is only important for Juypter noteboks, not when using code-server v4.20.0 (aka Code v1.85.1) with the Code Julia extension v1.66.2.

So, code-server displays plots in the browser, I take it?

Yes. But VS Code is a web application, too.
:information_source: Built with HTML5, JavaScript, and other Web technologies, using Chromium for presentation.

The problem I’m seeing is when using the installable version of VScode, which uses the plot pane. I would like to solve the problem on that setup, because it is what most of my students use. Actually, they will mostly be using Windows, and I’m not sure if the problem occurs on Windows.