From 176d7de4debb141aee6e3fb02d118b54b7c0f1f2 Mon Sep 17 00:00:00 2001 From: Justin Willmert Date: Wed, 22 May 2024 12:17:17 -0500 Subject: [PATCH 1/2] `empty!` the GLMakie screen for reuse instead of `close`ing and reopening MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes a problem observed on Linux (across at least a couple of different desktop environments) with windows flashing away and coming back in a different place (can be a different monitor!) when reusing the shared singleton screen. Also, wait for renderloop task to stop before restoring `close_after_renderloop` value. Without this, one can observe that the singleton window is fully closed and reopened by applying the following patch: ```diff diff --git a/GLMakie/src/screen.jl b/GLMakie/src/screen.jl index ff8b69fdc..e18b8ba6b 100644 --- a/GLMakie/src/screen.jl +++ b/GLMakie/src/screen.jl @@ -839,6 +839,7 @@ function pause_renderloop!(screen::Screen) end function stop_renderloop!(screen::Screen; close_after_renderloop=screen.close_after_renderloop) + yield() # don't double close when stopping renderloop c = screen.close_after_renderloop screen.close_after_renderloop = close_after_renderloop @@ -974,7 +975,7 @@ function renderloop(screen) end if screen.close_after_renderloop try - @debug("Closing screen after quiting renderloop!") + @info("Closing screen after quiting renderloop!") close(screen) catch e @warn "error closing screen" exception=(e, Base.catch_backtrace()) ``` which aims to force the renderloop's task to run via the call to `yield()` so that the task is sleeping during the rest of the function call. (The logging change just makes the particular action easier to find than enabling debug-level logging.) Opening a plot and replotting at the REPL, I observe both the window quickly close and reappear and the log message being printed by the end of the renderloop: ```julia-repl julia> using GLMakie Precompiling GLMakie Info Given GLMakie was explicitly requested, output will be shown live [ Info: Closing screen after quiting renderloop! [ Info: Closing screen after quiting renderloop! [ Info: Closing screen after quiting renderloop! [ Info: Closing screen after quiting renderloop! [ Info: Closing screen after quiting renderloop! [ Info: Closing screen after quiting renderloop! [ Info: Closing screen after quiting renderloop! [ Info: Closing screen after quiting renderloop! [ Info: Closing screen after quiting renderloop! [ Info: Closing screen after quiting renderloop! [ Info: Closing screen after quiting renderloop! [ Info: Closing screen after quiting renderloop! [ Info: Closing screen after quiting renderloop! [ Info: Closing screen after quiting renderloop! [ Info: Closing screen after quiting renderloop! [ Info: Closing screen after quiting renderloop! [ Info: Closing screen after quiting renderloop! [ Info: Closing screen after quiting renderloop! [ Info: Closing screen after quiting renderloop! [ Info: Closing screen after quiting renderloop! [ Info: Closing screen after quiting renderloop! [ Info: Closing screen after quiting renderloop! [ Info: Closing screen after quiting renderloop! [ Info: Closing screen after quiting renderloop! [ Info: Closing screen after quiting renderloop! 1 dependency successfully precompiled in 21 seconds. 303 already precompiled. 1 dependency had output during precompilation: ┌ GLMakie │ [Output was shown above] └ julia> scatter([1, 6]) julia> scatter([1, 6]) [ Info: Closing screen after quiting renderloop! ``` With the changes in this commit, all of the log message disappear, including from the precompile process. --- GLMakie/src/screen.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/GLMakie/src/screen.jl b/GLMakie/src/screen.jl index cec428db86a..483c44a86ac 100644 --- a/GLMakie/src/screen.jl +++ b/GLMakie/src/screen.jl @@ -345,7 +345,8 @@ function singleton_screen(debugging::Bool) if !isempty(SINGLETON_SCREEN) @debug("reusing singleton screen") screen = SINGLETON_SCREEN[1] - close(screen; reuse=false) + stop_renderloop!(screen; close_after_renderloop=false) + empty!(screen) else @debug("new singleton screen") # reuse=false, because we "manually" re-use the singleton screen! @@ -841,8 +842,6 @@ function stop_renderloop!(screen::Screen; close_after_renderloop=screen.close_af c = screen.close_after_renderloop screen.close_after_renderloop = close_after_renderloop screen.stop_renderloop[] = true - screen.close_after_renderloop = c - # stop_renderloop! may be called inside renderloop as part of close # in which case we should not wait for the task to finish (deadlock) if Base.current_task() != screen.rendertask @@ -851,6 +850,7 @@ function stop_renderloop!(screen::Screen; close_after_renderloop=screen.close_af screen.rendertask = nothing end # else, we can't do that much in the rendertask itself + screen.close_after_renderloop = c return end From 6d6d17d4c8b84cad455099ca30c102e9466d8921 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 16 Dec 2024 11:07:13 +0100 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bdfe0a97768..ac22f8ed7a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ - Added `transform_marker` attribute to meshscatter and changed the default behavior to not transform marker/mesh vertices [#4606](https://github.com/MakieOrg/Makie.jl/pull/4606) - Fixed some issues with meshscatter not correctly transforming with transform functions and float32 rescaling [#4606](https://github.com/MakieOrg/Makie.jl/pull/4606) - Fixed `poly` pipeline for 3D and/or Float64 polygons that begin from an empty vector [#4615](https://github.com/MakieOrg/Makie.jl/pull/4615). +- empty! GLMakie screen instead of closing, fixing issue with resetted window position [#3881](https://github.com/MakieOrg/Makie.jl/pull/3881) ## [0.21.18] - 2024-12-12