omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

Launching… OSD can remain indefinitely due to unordered show/close IPC calls

Open brianmsm opened this issue 3 months ago • 4 comments

System details

  • AMD Ryzen AI 9 365 / Radeon 880M
  • Omarchy 4.0.1-1
  • Hyprland 0.56.2
  • Quickshell 0.3.1-1

What's wrong?

The Launching … OSD can remain visible indefinitely after the launched application has already mapped and become active. I have seen this twice; the latest occurrence was launching TIDAL Hi-Fi from the Omarchy app menu.

Expected: the OSD closes when the app maps, or at worst after the 15-second launch timeout.

Actual: the app launches successfully, but the OSD remains until manually closed with:

omarchy-shell osd close

A privacy-cropped screenshot is available if needed. The full omarchy-debug output is intentionally not attached because it contains unrelated local identifiers and network logs; the system details above and deterministic reproduction contain the relevant evidence.

Probable root cause: unordered detached show / close IPC calls

In shell/services/AppLibrary.qml, launchDelay waits 2 seconds, sets launchOsdOpen = true, and dispatches this asynchronously:

Quickshell.execDetached(["omarchy-shell", "osd", "show", JSON.stringify({
  icon: "󱓞",
  message: root.launchOsdMessage,
  duration: 0
})])

If the app maps at approximately the same time, onValuesChanged() or onActiveToplevelChanged() calls closeLaunchFeedback(). That stops launchTimeout, dispatches a separate detached osd close process, and sets launchOsdOpen = false.

The two detached IPC client processes are not ordered. The close request can reach Quickshell first, followed by the delayed show. In that ordering:

  1. close closes an OSD that is not open yet.
  2. AppLibrary marks the OSD closed and stops the 15-second timeout.
  3. show arrives afterward with duration: 0.
  4. Nothing remains that can close it, so it stays indefinitely.

This timing explains why the problem is intermittent and more likely for apps that map around the 2-second launch-feedback threshold.

Deterministic IPC-level reproduction

Running the same show and close commands concurrently reproduces the unordered final state:

payload='{"icon":"󱓞","message":"Race test","duration":0}'
open=0
closed=0
for i in $(seq 1 100); do
  omarchy-shell osd show "$payload" >/dev/null &
  omarchy-shell osd close >/dev/null &
  wait
  state=$(omarchy-shell osd state)
  if [[ $state == open ]]; then
    ((open+=1))
    omarchy-shell osd close >/dev/null
  else
    ((closed+=1))
  fi
done
printf 'open=%d closed=%d\n' "$open" "$closed"

Observed:

open=53 closed=47

A finite OSD duration provides a reliable backstop. Repeating 100 iterations with duration: 20 and checking after 30 ms resulted in:

open=0 closed=100

Possible fixes

  • Minimal/defensive: give the launch OSD a finite duration (for example 13,000 ms, the time remaining between the 2-second display delay and the existing 15-second overall timeout). Normal app mapping can still close it early, but an inverted IPC ordering can no longer strand it forever.
  • Stronger: serialize/acknowledge the show before allowing close, or pass a launch generation/token to the OSD so a close can cancel a not-yet-processed show for that generation.

This appears related in symptom, but not identical in cause, to PR #6413 (Stop stranding the Launching… OSD when a second app is launched). That fix preserved launchOsdOpen across a second launch; this is another path where the QML-side flag and actual OSD state diverge.

brianmsm avatar Aug 25 '26 16:08 brianmsm

Independent confirmation on different hardware and a different application — your root-cause analysis matches what I found before I located this issue.

Occurrence

  • App: OBS Studio (launched from the Omarchy app menu)
  • The Launching OBS Studio… OSD stayed on the primary display for roughly 3 hours, long after OBS had mapped, been used for ~35 minutes, and exited.
  • omarchy-shell osd state reported open; omarchy-shell osd close cleared it.

Journal confirms the app itself was fine — the launch scope ran to completion:

Aug 26 10:26:04 uwsm_app-daemon: received: app -- gtk-launch com.obsproject.Studio.desktop
Aug 26 11:01:09 systemd: app-Hyprland-gtk\x2dlaunch-ad2a24da.scope: Consumed 7min 51.139s CPU time over 35min 5.234s wall clock time

System details

  • Intel Core i7-12700 / NVIDIA RTX 4070 Ti (AD104)
  • Omarchy 4.0.1-1
  • Hyprland 0.56.2
  • Quickshell 0.3.1-1

Reproduction

Concurrent dispatch, 20 iterations: 11 open / 9 closed (~55%), consistent with your 53/100.

I also isolated the terminal state directly, which shows the stranding is permanent rather than merely delayed — issuing close before a duration: 0 show:

omarchy-shell osd close
omarchy-shell osd show '{"icon":"󱓞","message":"RACE TEST","duration":0}'
sleep 8
omarchy-shell osd state   # -> open, and stays open indefinitely

This confirms step 4 of your analysis: once the inverted ordering happens, duration: 0 means hideTimer.stop() is called, launchTimeout has already been stopped by closeLaunchFeedback(), and launchOsdOpen is false — so the QML side will never dispatch another close for that OSD. Nothing short of a manual osd close or a shell restart recovers it.

Worth noting that OBS is a plausible trigger for the same reason TIDAL Hi-Fi was: it maps its first window right around the 2-second launchDelay threshold, which is exactly the window where show and close can be dispatched close enough together to reorder.

The finite-duration backstop you suggest as the minimal fix would have prevented this occurrence.

brad-b-miller avatar Aug 26 '26 19:08 brad-b-miller

Checked this against quattro (0b3f1b7e). Your diagnosis is correct as written, and the call sites are still there: closeLaunchFeedback() dispatches omarchy-shell osd close at shell/services/AppLibrary.qml:174, launchDelay.onTriggered dispatches the duration-0 osd show at shell/services/AppLibrary.qml:245, and they are two separate detached processes, so delivery order is decided by process scheduling rather than by the order QML issued them. Osd.show() stops hideTimer when duration is non-positive (shell/plugins/osd/Osd.qml:69) and close() only clears opened (:80), so an inverted delivery leaves the card open with nothing left that will close it — which is what brad-b-miller's close-then-show sequence isolates.

PR #8890 is open and cites #8795, which reports the same race. It adds a 30s maxLifetimeTimer for duration-0 OSDs in Osd.qml, and that part works: on a disposable Omarchy VM a duration-0 card was observed open until t=31s and then closed, and a newer OSD correctly cancels the cap. So with that PR a stranded launch card can no longer persist, and the three-hour case in this thread could not recur.

It does not fix the race itself. The show and the close remain two separate detached processes at the same two call sites, so the inverted ordering still occurs; the consequence is bounded at 30s rather than prevented, and for those 30s the card still looks stuck. The PR also drops the if (root.launchOsdOpen) guard so osd close fires unconditionally. Because maybeFinishLaunchFeedback() only early-returns when neither timer is running (AppLibrary.qml:180), that sends a close on every launch whose window maps inside the 2s launchDelay, and the OSD is a single shared card: omarchy.osd is what the volume, brightness and media paths all summon (shell/plugins/panels/audio/Panel.qml:435, shell/plugins/panels/monitor/Panel.qml:258, shell/plugins/services/media/Service.qml:248). So that close dismisses whatever card is on screen at the time — a volume bar mid-adjustment, for instance. This was reproduced by mutation on the same VM.

Your "stronger" option is already available in the repo, which is worth saying since it changes the cost of doing it properly: shell.callIfLoaded("omarchy.osd", ...) (shell/shell.qml:567) is an in-process call with no second process to reorder against, and it is the route those three siblings take through summon.

On duplicates: #8795 reports this same race as its first root cause, and adds a second one this issue does not discuss — a launch that produces no detectable toplevel, where the single 15s launchTimeout close is the only thing that would clear the card and nothing retries it if that detached close is lost (bin/omarchy-shell:58 gives it a 2s IPC timeout and no retry). That second path is plausible from source but undemonstrated, unlike the race here, which you and brad-b-miller both reproduced. This issue is the older of the two; whether it or #8795 stays open is the maintainer's to decide.

Next: waiting on the maintainer to choose between the 30s cap in #8890 and closing the launch OSD in-process. Nothing is needed from you.

Diagnosed by Opus 5 in Claude Code with a second opinion from Codex at xhigh reasoning. Codex confirmed the mechanism and the shared-OSD side effect against the same source, and agreed this issue and #8795 describe the same defect on the race.

omarchybot avatar Aug 29 '26 12:08 omarchybot

Additional reproduction that confirms the unordered show/close IPC race described here.

Trigger variation

I hit the same stuck "Launching firefoe…" OSD when launching an app from the menu and, during the ~2s launchDelay countdown, switching to a different desktop / assigning the launching app to a fresh unused workspace. The workspace/focus change fires maybeFinishLaunchFeedback() (onActiveToplevelChanged / onValuesChanged) around the same instant the detached osd show (duration: 0) is dispatched, ordering the close before the show, exactly as you describe. The app mapped and became active normally; the OSD stayed up indefinitely.

Verification on the live shell

$ omarchy-shell osd state
open        # stuck, app already running and focused
$ omarchy-shell osd close
ok
$ omarchy-shell osd state
closed      # only manual close clears it

hyprctl layers showed the omarchy-osd overlay surface still present before the manual close.

Your duration: 13_000 fallback (or a generation/token so close cancels a not-yet-processed show) looks like the right fix and would also cover this switch-during-countdown trigger.

LIKKLEbitoCode avatar Sep 04 '26 00:09 LIKKLEbitoCode

Rechecked against quattro at c352b62d, since a few things have moved since the last note here.

Still reproduces. omarchy-shell now answers over the shell's own socket (#13435), which is faster than qs ipc, but the launch OSD's show and close are still two separate detached processes (shell/services/AppLibrary.qml:174 and :245), and the shell runs whichever arrives first. On a VM built from the Omarchy ISO, running the shell from quattro, a close followed by a duration-0 show left the card open with nothing to close it, and the concurrent loop from the report left it stuck in 28 of 50 runs.

Where the fix is. #8890, which the last note discussed, was closed and folded into #12115, a larger bar-panel pull request. Two focused pull requests now fix this issue, and both link it, so it closes when either merges:

  • #9819 drives the launch OSD in-process, so there is no second process for the close to overtake. That removes the race itself.
  • #11568 gives the launch OSD a 15s duration, so an overtaken close leaves the card up for at most about 15s instead of indefinitely. It bounds the race rather than removing it.

Each has been reproduced and verified on a worker in its own review; the comments there have the details. #12115 also carries an in-process fix with a 13s cap, and its unit test passed on the same VM. #14406, opened this week, reports the same 2-second race.

Checked by Opus 5.5 in Claude Code, with a second opinion from Codex at medium effort. Codex agreed that the race is still on quattro and pointed to the competing pull requests and #14406. Its independence from my review is not guaranteed.

Next: waiting on the maintainer to choose between #9819 and #11568. Nothing is needed from you.

omarchybot avatar Oct 09 '26 02:10 omarchybot