MakieOrg / Makie.jl

Interactive data visualizations and plotting in Julia
https://docs.makie.org/stable
MIT License
2.4k stars 308 forks source link

`NO_CURRENT_CONTEX` error with GLMakie on WSL #4457

Open hexaeder opened 1 week ago

hexaeder commented 1 week ago

I am experiencing errors which are, unfortunately, quite hard to pin down/reproduce. My setup is an Ubuntu under WSL under Windows 11, on a Laptop with CUDA GPU. All on Julia 1.11-rc4. I use wslg as a wayland server to display the frames on the host.

Relatively frequently, when I try to open a new Figure, I get the following error:

julia> fig = Figure()
┌ Warning: error in renderloop
│   exception =
│    GLFWError (NO_CURRENT_CONTEXT): Cannot set swap interval without a current OpenGL or OpenGL ES context
│    Stacktrace:
│     [1] _ErrorCallbackWrapper
│       @ ~/.julia/packages/GLFW/wmoTL/src/callback.jl:43
│     [2] SwapInterval
│       @ ~/.julia/packages/GLFW/wmoTL/src/glfw3.jl:779 [inlined]
│     [3] renderloop
│       @ ~/.julia/packages/GLMakie/NAHlI/src/screen.jl:1009
│     [4] #72
│       @ ~/.julia/packages/GLMakie/NAHlI/src/screen.jl:870
└ @ GLMakie ~/.julia/packages/GLMakie/NAHlI/src/screen.jl:1019

Sometimes it also happens when I try to draw stuff to an existing figure. Unfortunately, it is not entirely clear to me when this happens exactly. I can open 1000 figures in a loop, but sometimes, I cannot even open a second one. Is this some known problem? Do you have any ideas on what I could provide to help debug this? Admittedly, my setup is probably not the most tested out there 😬

hexaeder commented 1 week ago

I might just found a reproducer which works for me at least. Copy pasting the following in a reply without startup file all at once

using Pkg
pkg"activate --temp"
pkg"add GLMakie"
using GLMakie
fig = Figure()
ax = LScene(fig[1,1])

results in the error below. Its not exactly the same, but it also mentiones the inactive OpenGL Context? I could not reproduce this problem under Julia 1.10.5 however.

ERROR: glGenTextures returned invalid id. OpenGL Context active?
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] glGenTextures()
    @ GLMakie.GLAbstraction ~/.julia/packages/GLMakie/NAHlI/src/GLAbstraction/GLExtendedFunctions.jl:132
  [3] GLMakie.GLAbstraction.Texture(data::Ptr{…}, dims::Tuple{…}; internalformat::UInt32, texturetype::UInt32, format::UInt32, mipmap::Bool, parameters::@Kwargs{…})
    @ GLMakie.GLAbstraction ~/.julia/packages/GLMakie/NAHlI/src/GLAbstraction/GLTexture.jl:94
  [4] Texture
    @ ~/.julia/packages/GLMakie/NAHlI/src/GLAbstraction/GLTexture.jl:85 [inlined]
  [5] Texture
    @ ~/.julia/packages/GLMakie/NAHlI/src/GLAbstraction/GLTexture.jl:131 [inlined]
  [6] #6
    @ ~/.julia/packages/GLMakie/NAHlI/src/gl_backend.jl:36 [inlined]
  [7] get!(default::GLMakie.var"#6#8"{Makie.TextureAtlas}, h::Dict{Any, Tuple{…}}, key::Tuple{Ptr{…}, GLFW.Window})
    @ Base ./dict.jl:458
  [8] get_texture!(atlas::Makie.TextureAtlas)
    @ GLMakie ~/.julia/packages/GLMakie/NAHlI/src/gl_backend.jl:35
  [9] (::GLMakie.var"#276#287"{GLMakie.Screen{…}, Scene, MakieCore.Text{…}})(gl_attributes::Dict{Symbol, Any})
    @ GLMakie ~/.julia/packages/GLMakie/NAHlI/src/drawing_primitives.jl:629
 [10] (::GLMakie.var"#214#224"{GLMakie.var"#276#287"{…}, GLMakie.Screen{…}, Scene, MakieCore.Text{…}})()
    @ GLMakie ~/.julia/packages/GLMakie/NAHlI/src/drawing_primitives.jl:337
 [11] get!(default::GLMakie.var"#214#224"{…}, h::Dict{…}, key::UInt64)
    @ Base ./dict.jl:458
 [12] cached_robj!(robj_func::GLMakie.var"#276#287"{…}, screen::GLMakie.Screen{…}, scene::Scene, plot::MakieCore.Text{…})
    @ GLMakie ~/.julia/packages/GLMakie/NAHlI/src/drawing_primitives.jl:235
 [13] draw_atomic(screen::GLMakie.Screen{GLFW.Window}, scene::Scene, plot::MakieCore.Text{Tuple{Vector{…}}})
    @ GLMakie ~/.julia/packages/GLMakie/NAHlI/src/drawing_primitives.jl:570
 [14] insert!(screen::GLMakie.Screen{GLFW.Window}, scene::Scene, x::Plot)
    @ GLMakie ~/.julia/packages/GLMakie/NAHlI/src/drawing_primitives.jl:353
 [15] #234
    @ ~/.julia/packages/GLMakie/NAHlI/src/drawing_primitives.jl:358 [inlined]
 [16] foreach(f::GLMakie.var"#234#235"{GLMakie.Screen{GLFW.Window}, Scene}, itr::Vector{Plot})
    @ Base ./abstractarray.jl:3190
 [17] insert!(screen::GLMakie.Screen{GLFW.Window}, scene::Scene, x::Plot)
    @ GLMakie ~/.julia/packages/GLMakie/NAHlI/src/drawing_primitives.jl:355
--- the above 3 lines are repeated 3 more times ---
 [27] #invokelatest#2
    @ ./essentials.jl:1054 [inlined]
 [28] invokelatest
    @ ./essentials.jl:1051 [inlined]
 [29] push!(scene::Scene, plot::Plot)
    @ Makie ~/.julia/packages/Makie/YkotL/src/scenes.jl:483
 [30] plot!(scene::Scene, plot::Plot{Makie.axis3d, Tuple{Tuple{Tuple{…}, Tuple{…}, Tuple{…}}}})
    @ Makie ~/.julia/packages/Makie/YkotL/src/interfaces.jl:413
 [31] _create_plot!(::Function, ::Dict{Symbol, Any}, ::Scene, ::Attributes, ::Vararg{Any})
    @ Makie ~/.julia/packages/Makie/YkotL/src/figureplotting.jl:391
 [32] axis3d!(::Scene, ::Vararg{Any}; kw::@Kwargs{ticks::@NamedTuple{…}})
    @ Makie ~/.julia/packages/MakieCore/NeQjl/src/recipes.jl:189
 [33] axis3d!
    @ ~/.julia/packages/MakieCore/NeQjl/src/recipes.jl:189 [inlined]
 [34] #axis3d!#504
    @ ~/.julia/packages/Makie/YkotL/src/basic_recipes/axis.jl:347 [inlined]
 [35] axis3d!
    @ ~/.julia/packages/Makie/YkotL/src/basic_recipes/axis.jl:346 [inlined]
 [36] (::Makie.var"#2288#2291"{LScene, Scene})(show_axis::Bool)
    @ Makie ~/.julia/packages/Makie/YkotL/src/makielayout/blocks/scene.jl:32
 [37] #invokelatest#2
    @ ./essentials.jl:1054 [inlined]
 [38] invokelatest
    @ ./essentials.jl:1051 [inlined]
 [39] notify
    @ ~/.julia/packages/Observables/YdEbO/src/Observables.jl:206 [inlined]
 [40] initialize_block!(ls::LScene; scenekw::@NamedTuple{})
    @ Makie ~/.julia/packages/Makie/YkotL/src/makielayout/blocks/scene.jl:44
 [41] initialize_block!(ls::LScene)
    @ Makie ~/.julia/packages/Makie/YkotL/src/makielayout/blocks/scene.jl:8
 [42] _block(T::Type{…}, fig_or_scene::Figure, args::Vector{…}, kwdict::Dict{…}, bbox::Nothing; kwdict_complete::Bool)
    @ Makie ~/.julia/packages/Makie/YkotL/src/makielayout/blocks.jl:371
 [43] _block
    @ ~/.julia/packages/Makie/YkotL/src/makielayout/blocks.jl:291 [inlined]
 [44] _block(::Type{LScene}, ::Figure; bbox::Nothing, kwargs::@Kwargs{})
    @ Makie ~/.julia/packages/Makie/YkotL/src/makielayout/blocks.jl:259
 [45] _block(::Type{LScene}, ::Figure)
    @ Makie ~/.julia/packages/Makie/YkotL/src/makielayout/blocks.jl:258
 [46] _block(::Type{LScene}, ::GridPosition; kwargs::@Kwargs{})
    @ Makie ~/.julia/packages/Makie/YkotL/src/makielayout/blocks.jl:253
 [47] _block
    @ ~/.julia/packages/Makie/YkotL/src/makielayout/blocks.jl:246 [inlined]
 [48] #_#1506
    @ ~/.julia/packages/Makie/YkotL/src/makielayout/blocks.jl:237 [inlined]
 [49] LScene(args::GridPosition)
    @ Makie ~/.julia/packages/Makie/YkotL/src/makielayout/blocks.jl:236
 [50] top-level scope
    @ REPL[6]:1
Some type information was truncated. Use `show(err)` to see complete types.