diff --git a/WGLMakie/Project.toml b/WGLMakie/Project.toml index e7b384f7586..02e8b8238c5 100644 --- a/WGLMakie/Project.toml +++ b/WGLMakie/Project.toml @@ -20,7 +20,7 @@ ShaderAbstractions = "65257c39-d410-5151-9873-9b3e5be5013e" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" [compat] -Bonito = "3.2.0" +Bonito = "3.2.1" Colors = "0.11, 0.12" FileIO = "1.1" FreeTypeAbstraction = "0.10" diff --git a/WGLMakie/src/display.jl b/WGLMakie/src/display.jl index 4fe03a5c7f5..a6070ebeb4b 100644 --- a/WGLMakie/src/display.jl +++ b/WGLMakie/src/display.jl @@ -333,7 +333,7 @@ function insert_scene!(session::Session, screen::Screen, scene::Scene) end function insert_plot!(session::Session, scene::Scene, @nospecialize(plot::Plot)) - plot_data = serialize_plots(scene, [plot]) + plot_data = serialize_plots(scene, Plot[plot]) plot_sub = Session(session) Bonito.init_session(plot_sub) plot.__wgl_session = plot_sub diff --git a/WGLMakie/src/precompiles.jl b/WGLMakie/src/precompiles.jl index b6be76a9107..a4837686cf6 100644 --- a/WGLMakie/src/precompiles.jl +++ b/WGLMakie/src/precompiles.jl @@ -14,6 +14,10 @@ macro compile(block) Bonito.jsrender(session, figlike) s = serialize_scene(scene) Bonito.SerializedMessage(session, Dict(:data => s)) + session = Session() + app = App(()-> DOM.div(figlike)) + dom = Bonito.session_dom(session, app) + show(IOBuffer(), Bonito.Hyperscript.Pretty(dom)) close(session) return nothing end @@ -30,6 +34,16 @@ let Makie.CURRENT_FIGURE[] = nothing Observables.clear(TEXTURE_ATLAS) TEXTURE_ATLAS[] = Float32[] + # This should happen in atexit in Bonito, but on Julia versions below v1.11 + # atexit isn't called + for (task, (task, close_ref)) in Bonito.SERVER_CLEANUP_TASKS + close_ref[] = false + end + Bonito.CURRENT_SESSION[] = nothing + if !isnothing(Bonito.GLOBAL_SERVER[]) + close(Bonito.GLOBAL_SERVER[]) + end + Bonito.GLOBAL_SERVER[] = nothing nothing end end diff --git a/WGLMakie/src/serialization.jl b/WGLMakie/src/serialization.jl index 32e87bea64a..e2c62b012f6 100644 --- a/WGLMakie/src/serialization.jl +++ b/WGLMakie/src/serialization.jl @@ -314,7 +314,7 @@ function serialize_scene(scene::Scene) return serialized end -function serialize_plots(scene::Scene, @nospecialize(plots::Vector{T}), result=[]) where {T<:AbstractPlot} +function serialize_plots(scene::Scene, plots::Vector{Plot}, result=[]) for plot in plots # if no plots inserted, this truely is an atomic if isempty(plot.plots) diff --git a/src/scenes.jl b/src/scenes.jl index 4a9359f7681..00e21cd500f 100644 --- a/src/scenes.jl +++ b/src/scenes.jl @@ -72,7 +72,7 @@ mutable struct Scene <: AbstractScene float32convert::Union{Nothing, Float32Convert} "The plots contained in the Scene." - plots::Vector{AbstractPlot} + plots::Vector{Plot} theme::Attributes