Skip to content

Commit

Permalink
Stop the render loop before emptying the singleton window for reuse
Browse files Browse the repository at this point in the history
Reverts effects of previous commit since that caused an accumulation
of screens after each save, which balooned memory requirements.
Instead, just copy the one line from `close()` which has an effect
other than manipulating the window visibility state.
  • Loading branch information
jmert committed May 23, 2024
1 parent 589d38c commit 20f457b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions GLMakie/src/screen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ function singleton_screen(debugging::Bool)
if !isempty(SINGLETON_SCREEN)
@debug("reusing singleton screen")
screen = SINGLETON_SCREEN[1]
stop_renderloop!(screen; close_after_renderloop=false)
empty!(screen)
else
@debug("new singleton screen")
Expand Down Expand Up @@ -428,7 +429,7 @@ end

# Screen to save a png/jpeg to file or io
function Screen(scene::Scene, config::ScreenConfig, io::Union{Nothing, String, IO}, typ::MIME; visible=nothing, start_renderloop=false)
screen = screen_from_pool(config.debugging)
screen = singleton_screen(config.debugging)
!isnothing(visible) && (config.visible = visible)
apply_config!(screen, config; start_renderloop=start_renderloop)
display_scene!(screen, scene)
Expand All @@ -437,7 +438,7 @@ end

# Screen that is efficient for `colorbuffer(screen)`
function Screen(scene::Scene, config::ScreenConfig, ::Makie.ImageStorageFormat; start_renderloop=false)
screen = screen_from_pool(config.debugging)
screen = singleton_screen(config.debugging)
config.visible = false
apply_config!(screen, config; start_renderloop=start_renderloop)
display_scene!(screen, scene)
Expand Down

0 comments on commit 20f457b

Please sign in to comment.