On macOS 26 an update's silent relaunch (open -n -g) deadlocked the new process's main thread: ApplicationStarted ran plainTitlebar -> insetLights -> toolbarRounder, which allocates a temporary NSWindow and releases it while the hidden background launch is still inside FBSWorkspaceScenesClient createSceneWithIdentity. Every InvokeSync waiter (tray usage, lighten, the resize/move timers) then blocked behind it, so the old tray left and the new one never came up. The Mac's title bar is now done in reveal, just before the window is first shown (a user action, never inside the launch); Linux keeps it at start. Their other two suggestions need no change: keepAt already returns while h.placed isn't the window, and with the main thread free the ready waiters no longer pile up. Run: gofmt; go vet darwin, linux nogui, windows; go test ./internal/gui on mote (ok, 136s). New TestMacTitleBarNotDoneAtStart, red with the call put back in ApplicationStarted and red with it removed from reveal. Not tried: the real deadlock. It needs macOS 26's hidden relaunch through LaunchServices from an updated bundle; mote (macOS 27) was not driven that way, so it is not shown not to reproduce there either. The full suite was not run before the tag.
41 lines
1.2 KiB
Go
41 lines
1.2 KiB
Go
//go:build !nogui
|
|
|
|
package gui
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// The Mac's plain title bar makes a window of its own (toolbarRounder). Done
|
|
// in ApplicationStarted, it deadlocked the main thread of an update's hidden
|
|
// relaunch on macOS 26, which is still inside FBSWorkspaceScenesClient then
|
|
// (eating_dream on X). It is done as the main window is first shown instead.
|
|
func TestMacTitleBarNotDoneAtStart(t *testing.T) {
|
|
app, err := os.ReadFile("app.go")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
i := strings.LastIndex(string(app), "events.Common.ApplicationStarted, func(")
|
|
if i < 0 {
|
|
t.Fatal("no ApplicationStarted handler in app.go")
|
|
}
|
|
body := string(app)[i:]
|
|
body = body[:strings.Index(body, "markReady()")]
|
|
if strings.Contains(strings.ReplaceAll(body, `if runtime.GOOS != "darwin" {
|
|
plainTitlebar(h.main)`, ""), "plainTitlebar(") {
|
|
t.Error("ApplicationStarted calls plainTitlebar on the Mac")
|
|
}
|
|
lw, err := os.ReadFile("lightweight.go")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
r := string(lw)
|
|
r = r[strings.Index(r, "func (h *host) reveal("):]
|
|
r = r[:strings.Index(r, "\n}\n")]
|
|
if !strings.Contains(r, "plainTitlebar(w)") {
|
|
t.Error("reveal doesn't give the Mac's main window its plain title bar")
|
|
}
|
|
}
|