Repository navigation
Description
Follow-up to #18444. That issue fixed the routes the forum reporter actually hit; a
code review of the fix turned up four more instances of the same family, all
pre-existing and deliberately left out of that PR to keep it reviewable.
The shared root cause is unchanged: PaneManager's zoom bookkeeping
(maximizedWindow_ / maximizedTab_, and the column-zoom widths
widgetSizePriorToZoom_ / leftWidgetSizePriorToZoom_ / sidebarSizePriorToZoom_)
is only cleared by restoreLayout(), so anything else that re-lays-out the panes
leaves it live. While it is live, the WindowEnsureVisibleEvent handler re-zooms
whichever pane raises itself next.
1. showSidebar's zoom guard covers pane zoom but not column zoom
PaneManager.showSidebar now ends an active pane zoom when sidebar visibility
changes, but checks only maximizedWindow_ != null. endZoomIfActive
(PaneManager.java:749-751) documents that there are three trackers:
maximizedWindow_ != null || maximizedTab_ != null || getZoomedColumn() != null
Column zoom (zoomColumn, reachable from View > Panes > Zoom Left/Right Column and
Zoom Sidebar) is untouched by the guard.
Reproduction, two clicks:
- View > Panes > Zoom Sidebar. This sets
right_and every left column to 1px. - Click the sidebar header's close button (
setSidebarPref(false)->showSidebar(false)).
The guard does not fire. MainSplitPanel.removeSidebarWidget (line 470) only removes
the sidebar and calls forceLayout() -- it has no redistribution counterpart to
setSidebarWidget's. center_ absorbs the freed width and the right column stays at
1px, so Environment / Plots / Help are gone. Because the width is 1px rather than 0,
getZoomedColumn() returns null, so no zoom command is check-marked either: the menu
reports a normal layout while a whole column is invisible. The only recovery is
View > Panes > Show All Panes, which the user has no reason to try.
Quieter damage in the same shape: widgetSizePriorToZoom_ survives the sidebar
toggle, and fullyMaximizeWindow only records the pre-zoom width when
widgetSizePriorToZoom_ < 0, so the next zoom restores a width measured before the
sidebar existed.
Widening the guard to endZoomIfActive's full condition would close this without
loosening the "don't clobber custom widths" constraint that method documents.
2. isAnimating_ is dead, so toggleWindowZoom has no re-entrancy guard
PaneManager.java:1292 reads isAnimating_ and PaneManager.java:3085 declares it
= false. Nothing in the tree ever assigns it, so toggleWindowZoom's
if (isAnimating_) return; can never fire.
Either remove the field and the guard, or make it real. There is a genuine hazard it
looks like it should cover: restoreLayout() -> restorePaneStateToDefault() fires
window state changes -> transitionToState -> onBeforeShow(), and a tab that calls
bringToFront() from onBeforeShow re-enters the WindowEnsureVisibleEvent handler
while maximizedWindow_ is still set (it is cleared on restoreSavedLayout's last
line), which would call fullyMaximizeWindow mid-restore. Clearing the bookkeeping
before firing the state changes may be the cheaper fix than a flag.
3. EnsureHeightEvent.MAXIMIZED bypasses the frame's maximize action
#18444 funnelled the frame-level maximize gestures through WindowFrame.maximize() so
an owner can intercept them in one place. LogicalWindow.onEnsureHeight
(LogicalWindow.java:138-149) converts EnsureHeightEvent.MAXIMIZED into a
WindowStateChangeEvent(MAXIMIZE) fired at the LogicalWindow, bypassing the frame
entirely. Producers include ToolbarPane.maximize(), reached from
ViewerPresenter and Source.
So e.g. an EnsureHeightEvent.NORMAL arriving while the Source pane is zoomed
undraws the zoom without clearing maximizedWindow_. MinimizedWindowFrame's own
maximize button is the same shape, though it is not reachable while a zoom is drawn
(the zoomed pane's sibling is HIDE, not MINIMIZE).
4. Adding a source column while a pane is zoomed
createAndDisplaySourceColumn -> MainSplitPanel.addLeftWidget (line 327) ->
clearForRefresh() + initialize(...), which re-applies persisted or default column
widths. That undraws the zoom while maximizedWindow_ stays set.
5. zoomColumn switching from a tracked pane zoom to a different column
Manually reproduced. This is the one to fix first.
The #18444 fix made zoomColumn's un-zoom branch delegate to restoreLayout() when a
pane zoom is tracked. That guard sits inside the
StringUtil.equals(currentZoomedColumn, columnId) branch, i.e. toggling the same
column off. Asking for a different column falls through to the per-column branches,
which never clear the pane-zoom bookkeeping.
Steps (default layout, sidebar visible with Chat in it):
- View > Panes > Zoom Chat.
zoomTab->fullyMaximizeWindowsets
maximizedWindow_to the sidebar window andmaximizedTab_toChat. - View > Panes > Zoom Left Column (Zoom Right Column behaves the same).
- View > Panes now shows two checkmarks at once: Zoom Chat and Zoom Left
Column. They come from independent sources --manageLayoutCommandsreads
maximizedTab_,manageZoomColumnCommandsreadsgetZoomedColumn()-- and cannot
both be legitimately live. - Run
plot(1:10). The right column takes over the whole window and everything else
collapses:WindowEnsureVisibleEventseesmaximizedWindow_still pointing at the
sidebar, which is not Plots' window, and callsfullyMaximizeWindowon TabSet2.
This is the original Stale pane-zoom state re-zooms any pane that raises itself, breaking the four-pane layout #18444 symptom.
Steps 3 and 4 were confirmed by hand. Worth noting that in the bad state the sidebar
sits at 0 width, so nothing on screen suggests Chat is still tracked as zoomed.
Read off the code but not confirmed by hand: invoking the same column zoom a second
time should hit the new guard and self-heal, and Show All Panes should recover, because
zoomColumn only records pre-zoom widths when they are < 0 so the pre-pane-zoom
widths survive. If both hold, the dangerous window is just between the column switch
and the next such action.
A guard at the top of zoomColumn covering any tracked pane zoom -- not only the
toggle-off branch -- would close this. Ordering needs care:
invalidateSavedLayoutState resets widgetSizePriorToZoom_ to -1, which zoomColumn
then reads.
Notes
Items 1-4 were found by reviewing the #18444 fix rather than from user reports, so
severity is unknown for 2-4; item 1 is a concrete two-click reproduction that hides a
pane column with no indication in the UI. Item 5 was predicted from the same review and
then reproduced by hand, and is the highest priority of the five: it reaches the
original #18444 symptom through a route that fix does not cover.
Activity
Keep EnsureHeightEvent.MAXIMIZED vertical for non-zoomed windows
Detach tab event forwarding when a tab leaves its panel
Reset a zoomed sidebar's width when its zoom ends
Dispose the outgoing sidebar panel's tab event forwarding
Test that moving a zoomed sidebar does not restore its zoomed width
Reuse the sidebar's SelectedTabStateValue across recreations
Keep the selected sidebar tab across a sidebar recreation
End a tracked zoom before removing a source column
Defer the restore callback in restorePaneLayout
Correct the endZoomBeforeRelayout docstring
Dispose the sidebar's tab panel when the sidebar is hidden
Consolidate the zoomed-width and default-sidebar-width rules
Wait on layout effects instead of sleeping in the zoom tests
Match the added source column by shape, not by number
Persist the last real sidebar selection, not a cleared panel's -1
Seed the sidebar selection fallback from the startup restore
Assert the maximize invariant, not a fixed growth, in viewer test
Clear pane-zoom state on the remaining relayout routes (#18518)