Closed Bug 2070375 Opened 2 months ago Closed 2 months ago

Launcher visibility leaks back to visible in "hide-sidebar" mode because _launcherStateAtOpen is captured on every show() but only restored when dismissPanel is true

Categories

(Firefox :: Sidebar, defect, P2)

Firefox 155
Desktop
Windows 11
defect

Tracking

()

RESOLVED DUPLICATE of bug 2066086

People

(Reporter: hello, Unassigned)

References

Details

(Whiteboard: [fidefe-sidebar])

What happens

With vertical tabs on, sidebar.visibility = "hide-sidebar", and a WebExtension
panel (Sidebery) as the active sidebar, hiding the sidebar and then re-opening it
leaves the native launcher rail visible. It sits on top of the extension panel and
covers it.

The state Firefox persists says the opposite. From sessionstore-backups/recovery.jsonlz4,
read while the rail was on screen, both windows:

{"command": "_3c078156-...-sidebar-action", "panelOpen": true, "panelWidth": 253,
 "launcherWidth": 0, "launcherExpanded": false, "launcherVisible": false,
 "pinnedTabsHeight": 0, "collapsedPinnedTabsHeight": 0}

launcherVisible: false with the launcher rendered. sidebar.backupState in
prefs.js agrees. So the persisted model and the DOM disagree, which is why no
pref change fixes it. I've tried.

What should happen

In "hide-sidebar" mode a launcher the user hid should stay hidden after a panel is
closed and re-opened. That's the intent stated in bug 2007183 and in the source
comment at browser-sidebar.js line 2439.

Steps to reproduce

  1. sidebar.revamp = true, sidebar.verticalTabs = true, sidebar.visibility = "hide-sidebar"
  2. Install any sidebar WebExtension and open its panel
  3. Hide the sidebar from the sidebar settings menu
  4. Re-open the extension panel

Expected: panel shows, launcher stays hidden.
Actual: panel shows with the launcher rail visible over it.

It isn't fully deterministic. It reproduces on some hide/unhide cycles and not others,
which fits a state-ordering problem rather than a pure logic error.

Mechanism

Line numbers verified against the files shipped in this install, extracted from
omni.ja rather than from a source checkout. They're accurate for 155.0.1 as
shipped and nothing else, so expect them to drift in later versions. The hashes
below pin exactly what I read.

SidebarState.sys.mjs sha256 0813bdf41fe0b2400113289c7fc44cd4ee771ea2a0952603c06646a9d49d1480
(28,523 bytes, byte-identical to the release branch copy at time of writing).

On the way in, opening a panel forces the launcher visible.
SidebarState.sys.mjs line 381, inside set panelOpen(open):

this.launcherVisible = !this.launcherHiddenWithPanel;

launcherHiddenWithPanel (line 474) is only true for "hide-launcher". In
"hide-sidebar" it is false, so this sets launcherVisible = true every time a
panel opens, no matter what the user chose.

The intended compensation is the pair added by bug 2007183. Capture, in
browser-sidebar.js line 2266, which runs on every show():

// capture the launcher state so we can revert to it when the panel closes
if (this._launcherStateAtOpen === undefined) {
  this._launcherStateAtOpen = this._state.launcherVisible;
}

Restore, at line 2438, is inside hide():

if (dismissPanel) {
  this._state.command = "";
  this.lastOpenedId = null;
  if (this._launcherStateAtOpen !== undefined) {
    if (["hide-sidebar", "hide-on-close"].includes(this.sidebarRevampVisibility)) {
      this._state.launcherVisible = this._launcherStateAtOpen;
    }
    delete this._launcherStateAtOpen;
  }
}

The asymmetry: capture is unconditional, restore sits behind if (dismissPanel)
at line 2433. Of the five hide() call sites in the file, four pass
dismissPanel: false, at lines 810, 1026, 1615, 1635, 2218. Line 1635 is the
sidebar toggle itself:

} else if (!shouldShowLauncher) {
  // hide the open panel. It will re-open next time as we don't change the command value
  this.hide({ dismissPanel: false });
}

So on the ordinary hide/show path the captured value never gets applied, and the
panelOpen setter has already pushed launcherVisible back to true on the way in.

The startup restore path does handle this correctly, for what it's worth:
loadCurrentState computes hasExplicitHiddenLauncher at line 255 and honors it
at line 297, so a restored launcherVisible: false survives session restore. The
gap is in the runtime toggle path only.

Why it is visible rather than harmless

This isn't part of the bug, but it explains why the report comes from an extension user.
An extension panel lives in #sidebar-box. The native launcher is #sidebar-main.
When both are present the launcher paints over the panel, so a leaked launcher isn't
a stray icon strip, it's a covered sidebar. Users of the built-in panels see
a cosmetic rail; extension users lose their sidebar.

What this is not

Ruled out before filing:

  • Not a pref. Prefs were captured in a broken state and in a working state on
    the same machine. All 29 sidebar and theme prefs were byte-identical, including
    sidebar.verticalTabs, sidebar.visibility, sidebar.revamp, and
    sidebar.revamp.defaultLauncherVisible.
  • Not a stale profile. user.js is absent from the profile root, so nothing
    overwrites prefs at startup.
  • Not userChrome CSS. This profile runs a userChrome theme. Its only rules
    touching #sidebar-main set stacking order and width. None of them set or clear
    the hidden attribute, which is what set launcherVisible (line 537) toggles.
    The CSS changes how the leaked launcher looks, not whether it leaks.

Suggested fix

Move the _launcherStateAtOpen restore out of the dismissPanel branch, so it
runs whenever a panel closes in a mode where the launcher can be hidden. Roughly:

this._state.panelOpen = false;
if (this._launcherStateAtOpen !== undefined) {
  if (["hide-sidebar", "hide-on-close"].includes(this.sidebarRevampVisibility)) {
    this._state.launcherVisible = this._launcherStateAtOpen;
  }
  delete this._launcherStateAtOpen;
}
if (dismissPanel) {
  this._state.command = "";
  this.lastOpenedId = null;
}

Bug 2007183 got backed out once for browser_ext_sidebarAction.js failures before
it relanded, so the extension path is worth covering in any test here. A regression
test would toggle the sidebar closed and open in "hide-sidebar" with an extension
panel active, then assert launcherVisible === false.

Environment

  • Firefox 155.0.1, Windows 11
  • sidebar.revamp = true, sidebar.verticalTabs = true, sidebar.visibility = "hide-sidebar", sidebar.revamp.defaultLauncherVisible = true
  • Sidebery 5.x as the active sidebar panel
  • A userChrome theme is installed; see "What this is not" above

Evidence status

Stated plainly so nothing here gets taken for more than it is. Measured: the
persisted session state, the pref comparison between broken and working, the file
hashes, and every cited line number, all read from the running install. Inferred:
that the toggle path is the specific route taken on the occasion observed. I've got
the resulting state and the code path that produces it, but not an instrumented
trace of the moment it happened.

Disclaimer

This report was drafted by an LLM working from my machine, and I read it before
filing. I work in construction, not software. The line numbers and hashes were
machine-checked against the shipped files, but I'm not in a position to vouch for
the reasoning the way a developer could. If the mechanism's wrong, I'd rather be
told than have it sit in the queue.

Keywords: regression
Regressed by: 2007183

:sfoster, since you are the author of the regressor, bug 2007183, could you take a look?

For more information, please visit BugBot documentation.

Flags: needinfo?(sfoster)

Sounds plausible, thanks for the report.

Flags: needinfo?(sfoster)
Priority: -- → P2
Whiteboard: [fidefe-sidebar]
See Also: → 2068002
See Also: → 2067960
See Also: → 2066086
Status: UNCONFIRMED → RESOLVED
Closed: 2 months ago
Duplicate of bug: 2066086
Resolution: --- → DUPLICATE

Actually this may be slightly different from 2066086, but I'm not able to reproduce. If I select 'hide tabs and sidebar' from the sidebar settings, that means the panel is open. If I try to follow the STR and open another panel (it isn't specified how that happens), say the bookmarks panel using the keyboard shortcut then it replaces the settings panel with the bookmarks panel and the sidebar launcher stays closed.

See Also: 2066086 →
See Also: 2067960 →
See Also: 2068002 →
Keywords: regression
No longer regressed by: 2007183
See Also: 1954056, 1959196, 2007183 →
You need to log in before you can comment on or make changes to this bug.