With CairoMakie or GLMakie, we can switch between different plots with left/right arrow, but when the backend is set to WGLMakie, this function seems broken?
Usage example could be that, especially with 3d plots, rotating/panning is easier with WGLMakie since itβs in the same vscode window and not in a separate glfw window as in GLMakie, and CairoMakie does not allow rotating 3d plots interactively
Thereβs a not much documented function in Bonito.jl that keeps the session open:
"""
set_cleanup_time!(time_in_hrs::Real)
Sets the time that sessions remain open after the browser tab is closed.
This allows reconnecting to the same session.
Only works for Websocket connection inside VSCode right now,
and will display the same App again from first display.
State that isn't stored in Observables inside that app is lost.
"""
function set_cleanup_time!(time_in_hrs::Real)
set_cleanup_time!(CLEANUP_POLICY[], time_in_hrs)
end
You can use that to leave the sessions of the last plotpanes open and switch between them⦠Let me know if it works!
1 Like
Thanks for the tip! Except for some warning it seems to work,
β Warning: error while processing received msg
β exception =
β Plot initialized multiple times?
β Stacktrace:
β [1] error(s::String)
β @ Base ./error.jl:35
β [2] (::WGLMakie.var"#4#5"{WGLMakie.Screen, Scene})(initialized::Bool)
β @ WGLMakie ~/.julia/packages/WGLMakie/AhDKR/src/display.jl:96
β [3] #invokelatest#2
β @ ./essentials.jl:1055 [inlined]
β [4] invokelatest
β @ ./essentials.jl:1052 [inlined]
β [5] update_nocycle!(obs::Observable{Any}, value::Any)
β @ Bonito ~/.julia/packages/Bonito/vh4Oz/src/rendering/observables.jl:42
β [6] #invokelatest#2
β @ ./essentials.jl:1055 [inlined]
β [7] invokelatest
β @ ./essentials.jl:1052 [inlined]
β [8] process_message(session::Bonito.Session{Bonito.WebSocketConnection}, bytes::Vector{UInt8})
β @ Bonito ~/.julia/packages/Bonito/vh4Oz/src/serialization/protocol.jl:36
β [9] (::Bonito.var"#1#2"{Bonito.Session{Bonito.WebSocketConnection}, Channel{Vector{UInt8}}})()
β @ Bonito ~/.julia/packages/Bonito/vh4Oz/src/types.jl:251
β @ Bonito ~/.julia/packages/Bonito/vh4Oz/src/types.jl:253
seems to come from
# Make sure it's a new Channel, since we may re-use the screen.
screen.plot_initialized = Channel{Any}(1)
screen.session = session
Makie.push_screen!(scene, screen)
canvas, on_init = three_display(screen, session, scene)
screen.canvas = canvas
on(session, on_init) do initialized
if isready(screen.plot_initialized)
# plot_initialized contains already an item
# This should not happen, but lets check anyways, so it errors and doesn't hang forever
error("Plot initialized multiple times?")
end
if initialized == true
put!(screen.plot_initialized, true)
mark_as_displayed!(screen, scene)
else
# Will be an error from WGLMakie.js
put!(screen.plot_initialized, initialized)
end
return
end