Skip to content

Commit

Permalink
Low hanging fruit for a bit better precompile (#4438)
Browse files Browse the repository at this point in the history
* low hanging fruit for a bit better precompile

* need to rely on latest Bonito to not hang while precompiling

* fix hangs for 1.10

* fix single plot update
  • Loading branch information
SimonDanisch authored Oct 3, 2024
1 parent 59456d3 commit 7a47bdc
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion WGLMakie/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion WGLMakie/src/display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions WGLMakie/src/precompiles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion WGLMakie/src/serialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/scenes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 7a47bdc

Please sign in to comment.