Skip to content

StableBar is quit while the Mac goes to sleep or sits asleep, and stays off after wake #952

Done

Description

@MaHofseth

What happens

After closing the lid, or after the Mac has slept, StableBar is sometimes no longer running when the Mac wakes. No crash report is written. The process got a Quit through loginwindow, accepted it and exited normally. Nothing relaunches it, so the bar stays off on every wake after that until it's opened by hand. This makes it look like it happens "every time the lid closes".

Steps to reproduce

Not reliable. It happened twice in one day, out of about 15 lid closes and several idle sleeps:

  1. Run StableBar from /Applications, with the bar on the top edge.
  2. Close the lid (or let the Mac idle-sleep), then wake it.
  3. Sometimes StableBar is gone: no bar and no menu-bar icon, and pgrep -x StableBar prints nothing.

A deliberate lid close (closed for 2 minutes) didn't reproduce it.

Expected

StableBar keeps running through sleep and wake. Failing that, it comes back on its own, or the reason it was quit is logged.

Environment

  • StableBar 0.19.0 from /Applications
  • macOS 27.2.1 (26B131), MacBook Pro (MacBookPro18,3), built-in display
  • Clear theme, bar on the top edge with offset 0, AeroSpace running

Evidence

Unified log (/usr/bin/log show --predicate 'process == "StableBar"', plus loginwindow and backgroundtaskmanagementd):

1. 09:30:04, pid 8592, during a DarkWake. The Mac had idle-slept at 09:20 and nobody was using it.

09:30:02  DarkWake from Deep Idle [CDNP] (pmset)
09:30:04.717 backgroundtaskmanagementd noteUseOfItemWithIdentifier: identifier=2.org.stablebar.app
09:30:04.717 backgroundtaskmanagementd checkTasksAllowedInBackgroundForAppURL: shouldRegister:true ...
09:30:04.820 loginwindow [com.apple.libquit:logging] StableBar [8592] force quit (caller responsible for termination)
09:30:04.824 loginwindow (CrashReporterSupport) Write failed to file ~/Library/Application Support/CrashReporter/StableBar_….plist
09:30:04.824 loginwindow [com.apple.libquit:logging] StableBar [8592] calling back to client to terminate
09:30:04.911 StableBar Handling Quit AppleEvent -> applicationShouldTerminate: NSTerminateNow -> terminate

2. 16:53:52, pid 3307, as the lid closed.

16:53:50.886 StableBar CGSDisplayNotifyProc: got notification kCGSDisplayWillSleep
16:53:51.0   loginwindow shows the lock screen
16:53:52.006 backgroundtaskmanagementd noteUseOfItemWithIdentifier: identifier=2.org.stablebar.app
16:53:52.007 backgroundtaskmanagementd checkTasksAllowedInBackgroundForAppURL: shouldRegister:true ...
16:53:52.107 loginwindow [com.apple.libquit:logging] StableBar [3307] force quit (caller responsible for termination)
16:53:52.110 loginwindow [com.apple.libquit:logging] StableBar [3307] calling back to client to terminate
16:53:52.166 StableBar Handling Quit AppleEvent -> applicationShouldTerminate: NSTerminateNow -> terminate
16:53:55  Entering Sleep state due to 'Clamshell Sleep' (pmset)

Neither quit was done by the user. For comparison, a deliberate Force Quit from the Force Quit Applications window logs -[ProcessPanel serverOptionsSheetDidEnd:returnCode:] | Forcequit confirmed just before the same libquit lines. Neither quit above has that line, and neither has a Dock or Activity Monitor action. Both are StableBar alone; this isn't a logout batch. There was no memory pressure at either time. No sleep hook, LaunchAgent or StableBar configuration action quits apps on this Mac. The only StableBar*.ips is an unrelated dev build that failed to load Sparkle at launch.

Diagnosis

The sender isn't identified. What the code on main shows:

  • StableBar doesn't quit itself on sleep. Sources/StableBar/App/StableBarApp.swift (sleeping, woke, screensSlept, screenLocked) only pauses scripts and providers and stops the window-clearance and menu-bar timers.
  • NSApp.terminate is reached only from Quit menus, --quit (RuntimeCommands.swift) and a failed runtime-control start. terminate() of other copies happens only in Uninstall (Uninstall.swift). The system monitor's quit action (WidgetActions.swift, confirmQuit) always asks first.
  • applicationShouldTerminate returns .terminateNow, so any Quit Apple Event ends the bar at once. No log of StableBar's own records why it quit.
  • Both quits come right after backgroundtaskmanagementd checks StableBar's background-task registration (2.org.stablebar.app), which points at macOS's login-item / background-item handling rather than StableBar code. That's not confirmed.

Two things in StableBar could make this visible or recoverable: log the sender of a Quit Apple Event (keySenderPIDAttr on the current Apple Event in applicationShouldTerminate), and decide whether a bar quit during sleep should come back on wake, for example through a launchd KeepAlive helper or SMAppService relaunch.

Related

Triaged by Claude Code (Claude Opus 5.5).

Activity

  1. added
    needs-triage
    on Nov 27, 2026
  2. M4n0x commented on Nov 27, 2026

    @M4n0x
    Collaborator

    Dug into it, nothing in StableBar quits on sleep, the Quit comes from loginwindow right after backgroundtaskmanagementd checks the login item so it smells like a macOS thing. #953 logs who sends a quit and shows it in Settings → Status → Unexpected quits (and in StableBar --report), once it's out could you paste what it says next time it happens, then we'll see if bringing the bar back on wake makes sense

  3. stablebar-releases commented on Nov 29, 2026

    @stablebar-releases

    🎉 This issue has been resolved in version 0.20.0 🎉

    The release is available on GitHub release

    Your semantic-release bot 📦🚀

  4. MaHofseth commented on Nov 30, 2026

    @MaHofseth
    ContributorAuthor

    @M4n0x 0.20.0 caught it twice on 29 Nov. Both are in Settings → Status → Unexpected quits:

    Time (CET) Cause Sender Conditions
    19:48:00 Quit Apple Event loginwindow (com.apple.loginwindow, pid 440, parent launchd (1)) system asleep, displays asleep, screen locked
    20:36:27 Quit Apple Event loginwindow (com.apple.loginwindow, pid 440, parent launchd (1)) system asleep, displays asleep, screen locked

    The unified log around both quits runs the same way as the two cases in the report, so that's four out of four:

    19:47:58.365 powerd  mDNSResponder Released MaintenanceWake "mDNSResponder:maintenance"
    19:48:00.043 backgroundtaskmanagementd noteUseOfItemWithIdentifier: identifier=2.org.stablebar.app, uid=501
    19:48:00.044 backgroundtaskmanagementd itemWithAppURL: appURL=file:///Applications/StableBar.app/, type=background tasks
    19:48:00.150 loginwindow [libquit] StableBar [8061] force quit (caller responsible for termination)
    19:48:00.152 loginwindow [libquit] StableBar [8061] calling back to client to terminate
    19:48:00.233 StableBar   Handling Quit AppleEvent
    19:48:00.238 StableBar   [org.stablebar.app:quit] quit by a Quit Apple Event from loginwindow (com.apple.loginwindow, pid 440, ...)
    
    20:36:26.309 powerd  WakeDetails
    20:36:26.686 powerd  mDNSResponder Released MaintenanceWake "mDNSResponder:maintenance"
    20:36:26.785 backgroundtaskmanagementd noteUseOfItemWithIdentifier: identifier=2.org.stablebar.app, uid=501
    20:36:26.786 backgroundtaskmanagementd itemWithAppURL: appURL=file:///Applications/StableBar.app/, type=background tasks
    20:36:26.906 loginwindow [libquit] StableBar [84570] force quit (caller responsible for termination)
    20:36:26.910 loginwindow [libquit] StableBar [84570] calling back to client to terminate
    20:36:27.008 StableBar   Handling Quit AppleEvent
    20:36:27.014 StableBar   [org.stablebar.app:quit] quit by a Quit Apple Event from loginwindow (com.apple.loginwindow, pid 440, ...)
    

    So it's always loginwindow, always during a maintenance DarkWake while the Mac is asleep and locked, and always about 100 ms after backgroundtaskmanagementd checks StableBar's background-item entry. The log still doesn't say why loginwindow decides to quit it, and the bar stays off until it's opened by hand.

    This was closed when 0.20.0 shipped the diagnostics, but the quit itself still happens. Could you reopen it so we can decide whether the bar should come back after a wake?

    Posted by Claude Code (Claude Opus 5.5).

  5. MaHofseth commented on Nov 30, 2026

    @MaHofseth
    ContributorAuthor

    Likely cause found: on this Mac, "Allow in the Background" is off for StableBar, and macOS quits the app when it checks that setting during a maintenance wake.

    sudo sfltool dumpbtm has one StableBar entry and one child entry. Both point at the release build (/Applications, release Team ID), so there are no stray dev builds involved:

    #79  Name: StableBar
         Type: app (0x2)
         Disposition: [disabled, disallowed, notified] (0x8)
         Identifier: 2.org.stablebar.app
         URL: /Applications/StableBar.app
         Last Use: 2026-11-29 20:36:27+01:00
    
    #80  Name: StableBar - background tasks
         Type: background tasks (0x2000)
         Disposition: [enabled, disallowed, notified] (0x9)
         Identifier: 8192.org.stablebar.app
         URL: (null)
         Last Use: 2026-11-29 20:36:26+01:00
         Parent Identifier: 2.org.stablebar.app
    
    • "disabled" on Add a reminders provider for due and overdue reminders #79 is just Open at login being off.
    • "disallowed" on both is "Allow in the Background" being off in System Settings → General → Login Items & Extensions.
    • The Last Use times match the 20:36 quit to the second. 20:36:26 is when backgroundtaskmanagementd recorded a use of 8192.org.stablebar.app, and 20:36:27 is when StableBar exited.

    So the likely chain: during a maintenance wake, macOS counts something StableBar does as background activity, finds the item disallowed, and loginwindow quits the app to enforce it. That fits all four quits: only while asleep and locked, about 100 ms after the background-item check, and rare (4 in about 200 dark wakes since 27 Nov).

    Ruled out along the way: Sparkle's hourly check (the 20:36 quit came 17 minutes after launch), device management (no MDM, no profiles), and logout, restart or shutdown (the records have no quit reason).

    Next: run a few days with "Allow in the Background" turned on. If the quits stop, this is confirmed. I'll report back either way.

    StableBar only registers SMAppService.mainApp, so the 8192. item is one macOS creates on its own. Two things StableBar could do, if it's confirmed:

    1. When Unexpected quits shows a loginwindow quit while asleep with no quit reason, point to "Allow in the Background".
    2. Mention it in the guide's Open at login / troubleshooting section.

    Posted by Claude Code (Claude Opus 5.5).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triagereleased

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions