Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WGLMakie error displaying Figure in VSCode inline context #3751

Open
kbarros opened this issue Mar 31, 2024 · 5 comments · May be fixed by #3754
Open

WGLMakie error displaying Figure in VSCode inline context #3751

kbarros opened this issue Mar 31, 2024 · 5 comments · May be fixed by #3754
Labels

Comments

@kbarros
Copy link
Contributor

kbarros commented Mar 31, 2024

When executing the following code within VSCode,

using WGLMakie

# Each of these commands is fine
fig = Figure()
ax = Axis(fig[1, 1])
fig

# This correctly draws the scatter plot
scatter!(ax, [(1,0), (1,1)])

# For VSCode inline plot, the first error appears here
fig

Displaying fig in the final line throws the error All field types need to be isbits.

Full stack trace
Display Error: ERROR: All field types need to be isbits. Found: Bonito.Session{Bonito.SubConnection} with (Bonito.SessionStatus, Float64, Union{Nothing, Bonito.Session}, Dict{String, Bonito.Session{Bonito.SubConnection}}, String, Bonito.SubConnection, Bonito.AbstractAssetServer, Vector{Bonito.SerializedMessage}, Vector{Bonito.JSCode}, Channel{Bool}, Function, Base.RefValue{Union{Nothing, Bonito.JSException}}, Observable{Union{Nothing, Dict{String, Any}}}, Observable{Bool}, Vector{Observables.ObserverFunction}, Dict{String, Any}, Int64, Int64, Base.RefValue{Function}, Bonito.OrderedSet{Bonito.Asset}, String, Bool, ReentrantLock, Base.RefValue{Any}, Dict{Hyperscript.Node{Hyperscript.HTMLSVG}, Set{Bonito.CSS}})
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] convert_uniform(context::WGLMakie.WebGL, x::Bonito.Session{Bonito.SubConnection})
    @ ShaderAbstractions ~/.julia/packages/ShaderAbstractions/20WwW/src/uniforms.jl:98
  [3] (::ShaderAbstractions.var"#21#22"{WGLMakie.WebGL})(x::Bonito.Session{Bonito.SubConnection})
    @ ShaderAbstractions ~/.julia/packages/ShaderAbstractions/20WwW/src/uniforms.jl:57
  [4] #map#13
    @ ~/.julia/packages/Observables/YdEbO/src/Observables.jl:570 [inlined]
  [5] map
    @ ~/.julia/packages/Observables/YdEbO/src/Observables.jl:568 [inlined]
  [6] convert_uniform(context::WGLMakie.WebGL, x::Observable{Bonito.Session{Bonito.SubConnection}})
    @ ShaderAbstractions ~/.julia/packages/ShaderAbstractions/20WwW/src/uniforms.jl:95
  [7] (::ShaderAbstractions.var"#27#29"{WGLMakie.WebGL, Dict{Symbol, Any}, Dict{Symbol, Any}})(io::IOBuffer)
    @ ShaderAbstractions ~/.julia/packages/ShaderAbstractions/20WwW/src/program.jl:107
  [8] sprint(::Function; context::Nothing, sizehint::Int64)
    @ Base ./strings/io.jl:114
  [9] sprint
    @ ./strings/io.jl:107 [inlined]
 [10] Program
    @ ~/.julia/packages/ShaderAbstractions/20WwW/src/program.jl:103 [inlined]
 [11] ShaderAbstractions.InstancedProgram(context::WGLMakie.WebGL, vertshader::String, fragshader::String, instance::GeometryBasics.Mesh{2, Float32, GeometryBasics.TriangleP{2, Float32, GeometryBasics.PointWithUV{2, Float32}}, GeometryBasics.FaceView{GeometryBasics.TriangleP{2, Float32, GeometryBasics.PointWithUV{2, Float32}}, GeometryBasics.PointWithUV{2, Float32}, GeometryBasics.NgonFace{3, GeometryBasics.OffsetInteger{-1, UInt32}}, StructArrays.StructVector{GeometryBasics.PointWithUV{2, Float32}, @NamedTuple{position::Vector{Point{2, Float32}}, uv::Vector{Vec{2, Float32}}}, Int64}, Vector{GeometryBasics.NgonFace{3, GeometryBasics.OffsetInteger{-1, UInt32}}}}}, per_instance::ShaderAbstractions.VertexArray{@NamedTuple{pos::Point{2, Float32}}, StructArrays.StructVector{@NamedTuple{pos::Point{2, Float32}}, @NamedTuple{pos::ShaderAbstractions.Buffer{Point{2, Float32}, Vector{Point{2, Float32}}}}, CartesianIndex{1}}}, uniforms::Dict{Symbol, Any})
    @ ShaderAbstractions ~/.julia/packages/ShaderAbstractions/20WwW/src/program.jl:58
 [12] scatter_shader(scene::Scene, attributes::Dict{Symbol, Observable}, plot::Scatter{Tuple{Vector{Point{2, Float32}}}})
    @ WGLMakie ~/.julia/dev/Makie/WGLMakie/src/particles.jl:211
 [13] create_shader(scene::Scene, plot::Scatter{Tuple{Vector{Point{2, Float32}}}})
    @ WGLMakie ~/.julia/dev/Makie/WGLMakie/src/particles.jl:231
 [14] serialize_three(scene::Scene, plot::AbstractPlot)
    @ WGLMakie ~/.julia/dev/Makie/WGLMakie/src/serialization.jl:327
 [15] serialize_plots(scene::Scene, plots::Vector{AbstractPlot}, result::Vector{Any})
    @ WGLMakie ~/.julia/dev/Makie/WGLMakie/src/serialization.jl:316
 [16] serialize_plots
    @ ~/.julia/dev/Makie/WGLMakie/src/serialization.jl:312 [inlined]
 [17] serialize_scene(scene::Scene)
    @ WGLMakie ~/.julia/dev/Makie/WGLMakie/src/serialization.jl:296
 [18] (::WGLMakie.var"#45#50")(child::Scene)
    @ WGLMakie ~/.julia/dev/Makie/WGLMakie/src/serialization.jl:290
 [19] iterate(::Base.Generator{Vector{Scene}, WGLMakie.var"#45#50"})
    @ Base ./generator.jl:47
 [20] _collect(c::Vector{Scene}, itr::Base.Generator{Vector{Scene}, WGLMakie.var"#45#50"}, ::Base.EltypeUnknown, isz::Base.HasShape{1})
    @ Base ./array.jl:854
 [21] collect_similar(cont::Vector{Scene}, itr::Base.Generator{Vector{Scene}, WGLMakie.var"#45#50"})
    @ Base ./array.jl:763
 [22] map(f::Function, A::Vector{Scene})
    @ Base ./abstractarray.jl:3285
 [23] serialize_scene(scene::Scene)
    @ WGLMakie ~/.julia/dev/Makie/WGLMakie/src/serialization.jl:290
--- the last 6 lines are repeated 1 more time ---
 [30] three_display(screen::WGLMakie.Screen, session::Bonito.Session{Bonito.WebSocketConnection}, scene::Scene)
    @ WGLMakie ~/.julia/dev/Makie/WGLMakie/src/three_plot.jl:32
 [31] render_with_init(screen::WGLMakie.Screen, session::Bonito.Session{Bonito.WebSocketConnection}, scene::Scene)
    @ WGLMakie ~/.julia/dev/Makie/WGLMakie/src/display.jl:76
 [32] #12
    @ ~/.julia/dev/Makie/WGLMakie/src/display.jl:173 [inlined]
 [33] (::Bonito.var"#8#14"{WGLMakie.var"#12#13"{WGLMakie.Screen, Scene}})(session::Bonito.Session{Bonito.WebSocketConnection}, request::HTTP.Messages.Request)
    @ Bonito ~/.julia/packages/Bonito/AipWx/src/types.jl:326
 [34] #invokelatest#2
    @ ./essentials.jl:892 [inlined]
 [35] invokelatest
    @ ./essentials.jl:889 [inlined]
 [36] rendered_dom(session::Bonito.Session{Bonito.WebSocketConnection}, app::Bonito.App, target::HTTP.Messages.Request)
    @ Bonito ~/.julia/packages/Bonito/AipWx/src/app.jl:40
 [37] rendered_dom
    @ ~/.julia/packages/Bonito/AipWx/src/app.jl:38 [inlined]
 [38] session_dom(session::Bonito.Session{Bonito.WebSocketConnection}, app::Bonito.App; init::Bool, html_document::Bool)
    @ Bonito ~/.julia/packages/Bonito/AipWx/src/session.jl:298
 [39] session_dom(session::Bonito.Session{Bonito.WebSocketConnection}, app::Bonito.App)
    @ Bonito ~/.julia/packages/Bonito/AipWx/src/session.jl:297
 [40] show(io::IOBuffer, m::MIME{Symbol("text/html")}, app::Bonito.App)
    @ Bonito ~/.julia/packages/Bonito/AipWx/src/display.jl:79
 [41] show(io::IOBuffer, ::MIME{Symbol("juliavscode/html")}, app::Bonito.App)
    @ Bonito ~/.julia/packages/Bonito/AipWx/src/display.jl:116
 [42] backend_show(screen::WGLMakie.Screen, io::IOBuffer, m::MIME{Symbol("juliavscode/html")}, scene::Scene)
    @ WGLMakie ~/.julia/dev/Makie/WGLMakie/src/display.jl:175
 [43] show(io::IOBuffer, m::MIME{Symbol("juliavscode/html")}, figlike::Figure)
    @ Makie ~/.julia/dev/Makie/src/display.jl:259
 [44] __binrepr(m::MIME{Symbol("juliavscode/html")}, x::Figure, context::Nothing)
    @ Base.Multimedia ./multimedia.jl:171
 [45] _textrepr
    @ ./multimedia.jl:163 [inlined]
 [46] repr(m::MIME{Symbol("juliavscode/html")}, x::Figure)
    @ Base.Multimedia ./multimedia.jl:159
 [47] display(d::VSCodeServer.InlineDisplay, m::MIME{Symbol("juliavscode/html")}, x::Any)
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.75.2/scripts/packages/VSCodeServer/src/display.jl:68
 [48] display(d::VSCodeServer.InlineDisplay, mime::String, x::Any)
    @ Base.Multimedia ./multimedia.jl:228
 [49] display(d::VSCodeServer.InlineDisplay, x::Any)
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.75.2/scripts/packages/VSCodeServer/src/display.jl:207
 [50] display(x::Any)
    @ Base.Multimedia ./multimedia.jl:340
 [51] display(figlike::Figure; backend::Module, inline::MakieCore.Automatic, update::Bool, screen_config::@Kwargs{})
    @ Makie ~/.julia/dev/Makie/src/display.jl:150
 [52] display(figlike::Figure)
    @ Makie ~/.julia/dev/Makie/src/display.jl:130
 [53] (::VSCodeServer.var"#68#73")()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.75.2/scripts/packages/VSCodeServer/src/eval.jl:237
 [54] with_no_default_display(f::VSCodeServer.var"#68#73"; allow_inline::Bool)
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.75.2/scripts/packages/VSCodeServer/src/display.jl:43
 [55] with_no_default_display
    @ ~/.vscode/extensions/julialang.language-julia-1.75.2/scripts/packages/VSCodeServer/src/display.jl:37 [inlined]
 [56] (::VSCodeServer.var"#67#72"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.75.2/scripts/packages/VSCodeServer/src/eval.jl:237
 [57] withpath(f::VSCodeServer.var"#67#72"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams}, path::String)
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.75.2/scripts/packages/VSCodeServer/src/repl.jl:274
 [58] (::VSCodeServer.var"#66#71"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.75.2/scripts/packages/VSCodeServer/src/eval.jl:179
 [59] hideprompt(f::VSCodeServer.var"#66#71"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.75.2/scripts/packages/VSCodeServer/src/repl.jl:38
 [60] (::VSCodeServer.var"#65#70"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.75.2/scripts/packages/VSCodeServer/src/eval.jl:150
 [61] with_logstate(f::Function, logstate::Any)
    @ Base.CoreLogging ./logging.jl:515
 [62] with_logger
    @ ./logging.jl:627 [inlined]
 [63] (::VSCodeServer.var"#64#69"{VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.75.2/scripts/packages/VSCodeServer/src/eval.jl:255
 [64] #invokelatest#2
    @ ./essentials.jl:892 [inlined]
 [65] invokelatest(::Any)
    @ Base ./essentials.jl:889

I do not observe any problem running the same code from the REPL, which launches a web browser display.

@kbarros kbarros added the bug label Mar 31, 2024
@asinghvi17
Copy link
Member

It looks like the Bonito.Session found its way into a plot or scene attribute somehow? Simon would know more.

What happens if you do:

fig = Figure()
rand(RGBf, 10, 10) # do something different
fig

?

@kbarros
Copy link
Contributor Author

kbarros commented Mar 31, 2024

No error for rand(RGBf, 10, 10). This seems to narrow it down to the scatter! command?

@asinghvi17
Copy link
Member

This error only comes up with scatter, and not with e.g. heatmap or lines.

@asinghvi17
Copy link
Member

The error is probably somewhere here

function scatter_shader(scene::Scene, attributes, plot)
# Potentially per instance attributes

@asinghvi17
Copy link
Member

asinghvi17 commented Mar 31, 2024

Aha! There is a key wgl_session in the uniform dict created here.

julia> Infiltrator.safehouse.uniform_dict[:__wgl_session]
Observable(Session{Bonito.SubConnection}:
  id: 9858a685-6c0f-44e7-8de8-4136c55ac247
  parent: Bonito.Session{Bonito.WebSocketConnection}
  connection: open
  isready: true
  asset_server: Bonito.ChildAssetServer
  queued messages: 0
)

which I suspect is the cause of your problem.

asinghvi17 added a commit that referenced this issue Mar 31, 2024
The inclusion of this attribute caused the Bonito session to be passed as a uniform, causing an error in ShaderAbstractions when it tried to test for `isbits` code.

Fixes #3751
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants