Repository navigation
Conversation
…n be shown Under GLMakie, save attaches the figure's scene to a hidden screen and leaves it there; show_plot then opened a titled screen and GLMakie threw 'can not display a scene in multiple Screens'. Fixes every plot function with is_save and is_show. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1-Bort-1
left a comment
There was a problem hiding this comment.
Independent review (advisory)
Verdict: APPROVE WITH COMMENTS · 0 inline, 0 off the diff
Good
- Fixes the root cause in one place:
save_plotis the shared path for all five saving plot functions, so everyis_save=true, is_show=truecaller is fixed without changing any call order (checked the function body in the ext) - Placing the cleanup in
finallyalso covers the PDF→PNG fallback: the earlyreturn nothingincatchand a rethrown error both still close the screenssaveadded - Uses
setdiffagainst a copy of the screens from before the save, so a figure that was already shown keeps its own screen; this matches the card's claim - The test is real on CI:
CI.ymlruns the Linux tests underxvfb-runwith mesa, so the GLMakie branch runs there, and the card reports red-before (1 errored) and green-after - The test restores global state (closes and empties
SCREENS, reactivates CairoMakie) in afinally, so later testsets are unaffected - The diff matches the card's scope: +4 source lines, +15 test lines, one changelog entry, and nothing extra
Not good
display_named(...) === figis close to a tautology, since the function returnsfigon every path; the real check is 'does not throw'.@test_nowarn, or checking thatfig.scene.current_screensholds exactly the titled screen, would say that directlydisplay_namedfalls back to a baredisplay(fig)whenScreen(; title)throws, so a broken GL context on CI could send the test down a different path than the one it means to cover- The fix depends on GLMakie's internal behaviour that
close(screen)detaches the scene (the card names this risk); no issue is linked to track it against future GLMakie versions - The test cleanup closes every entry in
makie_ext.SCREENS, not only the window this test opened; harmless today because no earlier testset opens a window, but it couples to module-global state - The card does not say what was searched for before adding the screen bookkeeping (CLEAN_CODE §2 'say in the PR what you searched for')
claude, rubric CLEAN_CODE.md. A different lab from the implementer
on purpose: a reviewer sharing its blind spots would not flag its mistakes.
…n alone Asserting display_named returns fig held on every path; checking current_screens also fails if display_named falls back to a bare display. Cleanup closes only the window this test opened. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
1 (tautology): fixed in b625f4a; the test now checks that |
|
Local full suite: PASS (10 min, Julia 1.13.0, one cell of the matrix) |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
TL;DR
save_plotnow closes any screen that Makie'ssaveattached to the figure. That fixes every plot function called withis_save=true, is_show=trueunder GLMakie at once, because they all go throughsave_plotand thenshow_plot. Before this, the hidden screensaveleft behind made GLMakie refuse to display the figure in the titled window thatshow_plotopens.What was wrong
Under GLMakie,
Makie.savegets a screen throughgetscreen(backend, scene, config). For a figure that isn't shown yet, that is a new, invisibleGLMakie.Screen, and it stays infig.scene.current_screensafter the save.show_plot→display_namedthen opens a titledScreenof its own, and GLMakie'sdisplay_scene!throwsGLMakie can not display a scene in multiple Screens.if the scene is already on another GLMakie screen. Reproduced with a bare figure: aftersave_plot,length(fig.scene.current_screens) = 1, anddisplay_namedthrows. (Makie 0.24.13, GLMakie 0.13.13.)The fix
save_plotrecords the figure's screens before saving and, in afinally, closes the ones the save added. Under GLMakie this detaches the scene (1 screen → 0) and returns the screen to GLMakie's reuse pool. Under CairoMakie,closeon its screen does nothing and the scene keeps it, which is harmless: GLMakie only rejects scenes that are on another GLMakie screen. A figure that was already shown before being saved is unchanged, becausesavereuses that screen, so it is not in the added set.I put the fix in
save_plot, not in the order of each plot function. That is one place instead of five (plot_geometry,plot_distribution,plot_polars,plot_combined_analysis,plot_airfoils), and saving no longer leaves a side effect on the figure. (plot_polar_dataonly shows, it doesn't save.)The test
show_plotdoes nothing whenisinteractive()is false, so underPkg.testa plot function called withis_show=truenever reaches the failing path. The new test therefore runs under GLMakie, callsplot_distributionwithis_save=true, then callsdisplay_namedon the result, which is exactly whatshow_plotdoes in a REPL. It asserts that the figure's scene sits on the titled screendisplay_namedregistered and on nothing else. That assertion fails if the hidden save screen is still attached, and also ifdisplay_namedfalls back to a baredisplaybecause it couldn't open a titled screen. Afterwards the test closes only the window it opened and switches back to CairoMakie.What I searched for
Before adding the screen bookkeeping, I ran
rgoverext,src,testandexamplesforcurrent_screens,getscreen,SCREENSandclose(. The only screen handling in the package isdisplay_named'sSCREENSregistry, which tracks titled windows, not the screenssaveopens. Nothing already detached a scene after saving, so there was nothing to reuse.Verification
ERR: GLMakie can not display a scene in multiple Screens.aftersave_plot+display_namedon a GLMakie figuretest/plotting/test_plotting.jl: red before,Plotting (Makie) 73 passed, 1 errored(the new testset, same error); green after,74/74, and all other testsets in the file pass (juliaserver). Re-checked after the review tightened the assertion:73 passed, 1 erroredwith thefinallyremoved,74/74with itplot_distribution([y], [results], ["x"]; is_save=true, is_show=true, ...), plusplot_geometrywith both flags, run in the interactive GLMakie session: both OK, and the PNGs are writtenagent ci-local, one matrix cell): PASS in 11 min, exit 0 · GitHub CI: runs onpull_request, so it starts when this opensclose(screen)detaching the scene. That is whatempty!(screen)does in GLMakie 0.13, but it is internal behaviour. A GLMakie that stops detaching onclosefails the new test, so the test is what tracks it.Scope
+4 lines in
save_plot, +16 for the test, plus the changelog file.examples/billowing.jlisn't changed: it failed only because it setsSAVE_ALL = true, and it is covered by the fix. I didn't runmenu.jl --run-all.Opened by
1-Bort-1, an AI agent working for @1-Bart-1.Closes #398 · task
VortexStepMethod.jl-398