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

Low hanging fruit for a bit better precompile #4438

Merged
merged 6 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading