diff --git a/internal/gui/app.go b/internal/gui/app.go index e7ad58e69..cd78a7da4 100644 --- a/internal/gui/app.go +++ b/internal/gui/app.go @@ -515,7 +515,13 @@ func Run(version string, showMain bool, link string) error { e.Cancel() }) - h.panel = h.makePanel() + // The Mac's panel is made the first time it is opened (panelWin): made + // here, its page and WebContent process (~67 MB) sat hidden for as long + // as magpie ran, for a user who never opens it too. Elsewhere it is made + // now, as the made-again path hasn't been run in a real window there. + if !panelOnFirstOpen(runtime.GOOS) { + h.panel = h.makePanel() + } h.main = h.makeMain("/?" + theme) onFonts = h.fontsChanged @@ -635,7 +641,9 @@ func Run(version string, showMain bool, link string) error { }) } h.tray.SetMenu(menu) - h.tray.AttachWindow(h.panel).WindowOffset(6) + if h.panel != nil { // one made later hangs itself on the icon (makePanel) + h.tray.AttachWindow(h.panel).WindowOffset(6) + } // before Wails removes the item as the app quits, which would forget // where the user put the icon (trayshown_darwin.go; nothing elsewhere) h.app.OnShutdown(func() { keepTrayPlace() }) @@ -714,8 +722,10 @@ func Run(version string, showMain bool, link string) error { // makes a window of its own (toolbarRounder), which deadlocks the // main thread while a hidden background launch (an update's // relaunch) is still inside FBSWorkspaceScenesClient on macOS 26. - nameWindow(h.panel, panelTitle) - ownFrame(h.panel) // KDE: no title bar of KWin's on it (#1283) + if h.panel != nil { // one made later is named as it is (madeAgain) + nameWindow(h.panel, panelTitle) + ownFrame(h.panel) // KDE: no title bar of KWin's on it (#1283) + } markReady() }) } diff --git a/internal/gui/lightweight_rule.go b/internal/gui/lightweight_rule.go index 9e937faa8..564807542 100644 --- a/internal/gui/lightweight_rule.go +++ b/internal/gui/lightweight_rule.go @@ -28,3 +28,8 @@ func lightStep(on, shown bool, ticks int) (int, bool) { ticks++ return ticks, ticks >= lightTicks } + +// panelOnFirstOpen says whether the tray panel is made the first time it is +// opened rather than as magpie starts: on the Mac, where a hidden panel's +// page kept a WebContent process of its own (~67 MB) for nothing. +func panelOnFirstOpen(goos string) bool { return goos == "darwin" } diff --git a/internal/gui/lightweight_rule_test.go b/internal/gui/lightweight_rule_test.go index e65ee6a7c..a070032af 100644 --- a/internal/gui/lightweight_rule_test.go +++ b/internal/gui/lightweight_rule_test.go @@ -28,3 +28,14 @@ func TestLightStep(t *testing.T) { } } } + +// The Mac's tray panel is made when it is first opened, not at start: a +// hidden one kept a WebContent process of ~67 MB for a user who never +// opened it. Elsewhere it is still made at start. +func TestPanelOnFirstOpen(t *testing.T) { + for goos, want := range map[string]bool{"darwin": true, "linux": false, "windows": false} { + if got := panelOnFirstOpen(goos); got != want { + t.Errorf("panelOnFirstOpen(%s) = %v, want %v", goos, got, want) + } + } +}