omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

LockService reports self-contradictory state: isLocked=true while status shows locked components all false

Open jfdnet opened this issue 1 month ago • 8 comments

Environment: omarchy 4.0.4-1, quickshell 0.3.2 (locally rebuilt for Qt 6.12), Hyprland, up-to-date Arch.

What happened

After a session that included several suspend/hibernate cycles and a few shell restarts, the lock IPC started returning a locked value that contradicts its own components:

$ omarchy-shell lock isLocked
true

$ omarchy-shell lock status
{"locked":true,"requested":false,"pending":false,"sessionLocked":false,"secure":false,...,"lastEvent":"unlocked","lastEventAt":"..."}

Per plugins/lock/Service.qml line 37:

readonly property bool locked: lockRequested || sessionLock.locked || sessionLock.secure

with all three inputs false the composite cannot be true — yet both IPC calls return locked: true from the same live process (verified single quickshell instance via pgrep and pid-scoped IPC). lastEvent was unlocked and events kept updating, so the service object was alive; only the derived locked value appeared frozen at its last-true value.

Impact

Anything that polls omarchy-shell lock isLocked (idle/power scripts, the idle screensaver gate) believes the session is permanently locked: screens blank mid-use, "about to suspend" notifications repeat, and battery-only suspend logic can engage while the user is actively working.

Recovery

Restarting quickshell resets the state; isLocked returns false immediately after.

Suspect

WlSessionLock.locked is given a literal binding (locked: false, line ~234) but is then written imperatively (sessionLock.locked = true/false in requestSessionLock/finishUnlock), which breaks QML binding semantics — after enough lock/unlock churn (possibly combined with ext-session-lock object replacement across restarts, cf. the orphan-lock comment above checkStrandedLock), the derived locked can end up stale-true. I have not reduced this to a minimal reproduction; the contradiction between the two IPC answers is reproducible from the outputs above while the state is stuck.

Happy to provide the full journal excerpt of the lock/unlock sequence before the state froze if useful.

jfdnet avatar Oct 08 '26 12:10 jfdnet

Thanks for the detailed write-up. The two IPC answers really do contradict each other: status builds locked from root.locked, while sessionLocked and secure are read live in the same call.

One note on the suspect: locked: false on the WlSessionLock is a constant, not a binding to anything. Assigning sessionLock.locked = true/false later just overrides it and doesn't break a binding we rely on. My best guess is that a NOTIFY never fired: root.locked (lockRequested || sessionLock.locked || sessionLock.secure) only re-evaluates when one of those three emits a change. If secure or locked dropped back to false without secureStateChanged/lockStateChanged firing, for example when the compositor finished the lock object across a restart, the derived value would stay true just like this.

Could you share:

  • the journal excerpt you offered (journalctl --user -t omarchy-shell), especially the secure= and lock/unlock events before it got stuck
  • whether this also happens on the stock quickshell package (I see a local 0.3.2 rebuild for Qt 6.12), since that changes which WlSessionLock signals we get

Possibly related: #10546 (IPC serving stale lock state while wedged).

jandrusk avatar Oct 08 '26 13:10 jandrusk

Root cause: locked stays true after every unlock with Quickshell 0.3.2, so the next lock lock and the pre-suspend lock are skipped

Root cause and a tested patch for this issue. Found while testing T2 suspend (#14664). Related: #10299 (lockRequested latch, different mechanism, same IPC short-circuit), #9734 (closed).

Environment

Item Value
Omarchy omarchy-dev 4.0.0.r6807.g902fd8a (shell/plugins/lock/Service.qml)
Quickshell 0.3.2-1, upgraded 2026-10-08 (includes afb2c27 "wayland/lock: guard against reentrancy during surface creation")
Compositor Hyprland, single internal panel, MacBook Pro T2
Sleep path logind suspend, omarchy-sleep-lock.service, omarchy-system-sleep-lock

Steps

  1. omarchy-shell lock lock (or suspend). Unlock with the password.
  2. omarchy-shell lock status
  3. omarchy-shell lock lock again, or suspend.

Expected

After step 1, locked is false. Step 3 locks the screen.

Actual

Step 2 reports locked: true with every component false:

{"locked":true,"requested":false,"pending":false,"sessionLocked":false,"secure":false,"lastEvent":"unlocked","lastEventAt":"2026-10-09T01:11:03.631Z"}

Step 3 returns ok, does nothing, and logs nothing. Before suspend, omarchy-system-sleep-lock waits 12 s and then lets the machine sleep unlocked. After wake the notification says "Screen did not lock before suspend".

[ 68.675] omarchy lock 01:08:28.829Z lock-requested
[ 68.675] omarchy lock 01:08:28.829Z lock-pending: screen-stabilizing
[ 69.179] omarchy lock 01:08:29.333Z session-locked=true
[ 69.322] omarchy lock 01:08:29.475Z secure=true
          ... suspend, resume, unlock ...
[135.182] omarchy lock 01:11:03.631Z secure=false
[135.182] omarchy lock 01:11:03.631Z unlocked
          (no "session-locked=false")
[346.965] omarchy-system-sleep-lock: suspending without a secure lock (the shell did not secure the session within 12000ms)
          (no "lock-requested" before this line)

Root cause

Service.qml:59 binds locked: lockRequested || sessionLock.locked || sessionLock.secure and relies on WlSessionLock.lockStateChanged to re-evaluate.

finishUnlock() (Service.qml:220-232) clears lockRequested, then sets sessionLock.locked = false. In Quickshell 0.3.2:

  1. WlSessionLock::unlock() (src/wayland/session_lock.cpp:173-184) calls manager->unlock().
  2. QSWaylandSessionLock::unlock() emits unlocked before SessionLockManager::unlock() clears mLock (session_lock/session_lock.cpp:40-47).
  3. That emits secureStateChanged. The binding re-evaluates now, and sessionLock.locked still reads true because mLock is still set. Result: locked = true.
  4. unlock() then emits lockStateChanged only if (this->isLocked()). That is already false, so it never fires. Before afb2c27 the check ran before manager->unlock().

Nothing re-evaluates the binding after that. The IPC lock() (Service.qml:836) runs if (!root.locked && !root.beginLock()) and returns ok without locking. onLockStateChanged (Service.qml:450-467) never runs on unlock, so lockRequested can also stick after a compositor finished.

The bug does not depend on suspend timing. One unlock is enough.

Proposed fix

Omarchy: mirror the session lock state into a plain property and refresh it where Quickshell stays silent. Patch below.

Quickshell (separate report planned): in WlSessionLock::unlock(), read isLocked() before manager->unlock() and emit lockStateChanged when the value changed.

Patch for shell/plugins/lock/Service.qml
--- a/shell/plugins/lock/Service.qml
+++ b/shell/plugins/lock/Service.qml
@@ -56,7 +56,12 @@
   property bool strandedLock: false
   property bool strandedLockResolved: false
 
-  readonly property bool locked: lockRequested || sessionLock.locked || sessionLock.secure
+  // Quickshell 0.3.2 (afb2c27) emits no lockStateChanged on unlock, and emits
+  // secureStateChanged while sessionLock.locked still reads true. A binding on
+  // sessionLock.locked then keeps `locked` true after every unlock, and the
+  // next `lock lock` is dropped. Mirror the state once each change settles.
+  property bool sessionLockHeld: false
+  readonly property bool locked: lockRequested || sessionLockHeld || sessionLock.secure
   readonly property bool authenticating: authenticatingPassword || fingerprintAuthenticating
   readonly property var batteryService: shell && shell.services ? shell.firstPartyServiceFor("omarchy.battery") : null
   readonly property bool powerSaverActive: batteryService ? batteryService.powerSaverOnBattery : false
@@ -227,10 +232,31 @@
     resetAuthenticationState()
     idleBlankTimer.stop()
     sessionLock.locked = false
+    syncSessionLockState()
     logEvent("unlocked")
     runWake()
   }
 
+  // The session lock went away (unlock, or the compositor ended it).
+  function releaseLockRequest() {
+    if (!lockRequested) return
+    lockRequested = false
+    pendingSessionLock = false
+    sessionLockStabilizeTimer.stop()
+    pendingSessionLockTimer.stop()
+    resetAuthenticationState()
+    runWake()
+  }
+
+  // Re-read sessionLock.locked for a change Quickshell did not signal.
+  function syncSessionLockState() {
+    var held = sessionLock.locked
+    if (held === sessionLockHeld) return
+    sessionLockHeld = held
+    logEvent("session-locked=" + held + " (unsignalled)")
+    if (!held) releaseLockRequest()
+  }
+
   function armBlankTimer() {
     idleBlankTimer.armedAt = Date.now()
     idleBlankTimer.restart()
@@ -445,9 +471,12 @@
         pendingSessionLockTimer.stop()
         root.startFingerprint()
       }
+      // On unlock this fires before the lock object is gone.
+      Qt.callLater(root.syncSessionLockState)
     }
 
     onLockStateChanged: {
+      root.sessionLockHeld = locked
       root.logEvent("session-locked=" + locked)
 
       if (locked) {
@@ -456,14 +485,7 @@
         pendingSessionLockTimer.stop()
       }
 
-      if (!locked && root.lockRequested) {
-        root.lockRequested = false
-        root.pendingSessionLock = false
-        sessionLockStabilizeTimer.stop()
-        pendingSessionLockTimer.stop()
-        root.resetAuthenticationState()
-        root.runWake()
-      }
+      if (!locked) root.releaseLockRequest()
     }
 
     WlSessionLockSurface {
@@ -833,7 +855,12 @@
 
     function lock(): string {
       if (!root.passwordPamConfigured) return "missing-pam"
-      if (!root.locked && !root.beginLock()) return "failed"
+      root.syncSessionLockState()
+      if (root.locked) {
+        if (!root.lockRequested) root.logEvent("lock-request: held without request")
+        return "ok"
+      }
+      if (!root.beginLock()) return "failed"
       return "ok"
     }

Workaround

  • omarchy-restart-shell while unlocked. The stale state returns at the next unlock.
  • Or apply the patch locally, or downgrade Quickshell to the release before 0.3.2.

Verified

With the patch: lock, unlock, lock again. The second lock works, lock status returns locked:false after each unlock, and the log shows the missed signal being caught:

omarchy lock secure=false
omarchy lock session-locked=false (unsignalled)
omarchy lock unlocked

Then 4 real suspends (3 docked, 1 lid-close on battery): each logged secure=true before Performing sleep operation 'suspend'.

justcarlson avatar Oct 09 '26 02:10 justcarlson

Confirming this on a second machine, and I'd like to ask for a fix to land soon. Right now every lock path silently fails after the first unlock.

Environment: Dell XPS, edge channel, omarchy-dev 4.0.0.r6815.g50d687a-1, quickshell 0.3.2-2, Qt 6.12.0, Hyprland, two displays.

The trigger matches @justcarlson's analysis: one password unlock, and session-locked=false is never logged.

09:08:59.532Z secure=false
09:08:59.532Z unlocked
              (no "session-locked=false")
{"locked":true,"requested":false,"pending":false,"sessionLocked":false,"secure":false,"lastEvent":"unlocked"}

After that, nothing locks the screen. The idle lock, Lock from the launcher, and omarchy system lock all return success and do nothing. The idle screensaver is skipped too, because its isLocked gate reads true. My journal shows it started right after the Oct 8 quickshell 0.3.2 / Qt 6.12 update. omarchy restart shell clears it until the next unlock.

Since this leaves machines unlocked with no visible error, including before suspend as reported above, could PR #14591 or the patch in the comment above get a review? I'm happy to test a build or branch.

shawnyeager avatar Oct 09 '26 14:10 shawnyeager

Confirming the bug, and confirming that the Service.qml change from #14591 fixes it.

Environment: ThinkPad E14 Gen 7, edge channel, omarchy-dev 4.0.0.r6815.g50d687a-1, quickshell 0.3.2-2, Qt 6.12.0, Hyprland, laptop panel plus two external displays.

Before: it happened the same way described above. After one unlock, lock status returned {"locked":true,"requested":false,"pending":false,"sessionLocked":false,"secure":false,"lastEvent":"unlocked"}. Later, the laptop sat idle for about 3 hours with no screensaver and no lock. The idle monitor fired on schedule both times. The screensaver command exited in about 30 ms because its isLocked guard returned true, and omarchy-system-lock exited 0 without any lock-requested being logged.

With #14591 (applied locally to a clone made with omarchy plugin clone omarchy.lock, only the Service.qml hunks):

19:25:16  idle-cycle-start: screensaver=900 lock=1200   (screensaver launched)
19:30:16  session-locked=true                           (idle lock)
19:30:17  secure=true
21:00:26  secure=false
21:00:26  unlocked
21:00:45  lock-requested                                (second lock after an unlock works)
21:00:46  session-locked=true
21:00:46  secure=true
21:00:48  secure=false
21:00:48  unlocked

After each unlock, lock status returns "locked":false,"sessionLocked":false, and the next lock goes through. +1 for landing it. Until it does, auto-lock and the pre-suspend lock silently stop working after the first unlock of a session.

Lifferado avatar Oct 09 '26 19:10 Lifferado

Confirming on omarchy-dev 4.0.0.r6860.g7cc6a55, quickshell 0.3.2-2, hyprland 0.56.2-4 (i7-6950X, Radeon RX 560). It reproduces after every password unlock: the log shows secure=false → unlocked with no session-locked=false, then status reports locked: true with requested, sessionLocked and secure all false. After that, both Super+Ctrl+L and the idle lock-timeout return ok without locking. omarchy-restart-shell clears it until the next unlock. +1 for getting #14591 reviewed.

mrdemonbkgit avatar Oct 10 '26 02:10 mrdemonbkgit

Thanks @justcarlson for the root cause and the patch, and to everyone confirming. After the first unlock on quickshell 0.3.2, every lock path (idle, Super+Ctrl+L, pre-suspend) silently does nothing, so this is worth prioritizing. #14591 has now been confirmed as the fix on three machines, so it looks ready for maintainer review.

jandrusk avatar Oct 12 '26 18:10 jandrusk

Confirming on a different architecture than the existing reports.

Environment

  • Omarchy 4.0.2-2
  • Quickshell 0.3.2 (Arch package)
  • Hyprland 0.56.2 (efb5099)
  • Apple MacBook Air M1 (MacBookAir10,1), aarch64 / Asahi, single external display

Observed (after an earlier unlock in the same shell process; bind SUPER+CTRL+L still registered):

$ omarchy-shell lock isLocked
true

$ omarchy-shell lock status
{"locked":true,"requested":false,"pending":false,"sessionLocked":false,"secure":false,"realScreens":1,"passwordPam":true,"fingerprint":false,"authenticating":false,"lastEvent":"unlocked","lastEventAt":"2026-10-12T17:48:33.000Z"}

$ omarchy-hyprland-session-locked; echo $?
1

$ omarchy-shell lock lock
ok

omarchy-shell lock lock returned ok and did not lock. omarchy restart shell cleared it (isLocked → false, lastEvent → init). Same silent no-op as described here and in #15154.

paganotoni avatar Oct 12 '26 19:10 paganotoni

This is fixed on quattro by #14978 (d1a614ce6), which first shipped in v4.5.0-rc1. lock(), isLocked(), status() and the stranded-lock checks now read lockRequested, sessionLock.locked and sessionLock.secure directly instead of trusting the locked binding.

I reproduced it on a disposable worker installed from the Omarchy ISO (Hyprland, one display), locking with omarchy-shell lock lock and unlocking by typing the password. I ran two lock/unlock cycles each time:

  • Quickshell 0.3.2-1 (Arch extra), the tree just before d1a614ce6: reproduces exactly as reported. After the first unlock, status returns {"locked":true,"requested":false,"pending":false,"sessionLocked":false,"secure":false,"lastEvent":"unlocked"}, and the second lock lock returns ok, logs nothing and does not lock.
  • Quickshell 0.3.2-1, current quattro (be54892f): both locks take, and status reads locked:false after each unlock.
  • Quickshell 0.3.2.r7.g2b4501a-1 (Omarchy package repository): does not reproduce on either tree, because session-locked=false is now logged on unlock. Upstream 2b4501a reads the lock state before calling the manager's unlock, so lockStateChanged fires again, which matches the analysis by @justcarlson above.

I compared against the commit before the fix rather than reverting it on quattro, because the revert does not apply cleanly. The test suite was not run, since nothing here changes code.

One thing is left on quattro with Quickshell 0.3.2-1: the locked binding itself still goes stale. It no longer decides anything, but it still drives monitorDpmsTimer (shell/plugins/lock/Service.qml:822). With a video lock background, that timer keeps running hyprctl monitors -j every 3 seconds after unlock. It also feeds loadBackground (line 556), which has no lasting effect because the lock surfaces are torn down on unlock. #14591 makes that drawn state follow a tracked copy, and it already references this issue. Nothing outside the lock plugin reads the property directly: the idle screensaver gate, omarchy-system-lock, omarchy-system-sleep-lock and omarchy-restart-shell all go through the IPC calls #14978 fixed.

Codex at medium effort and muse-spark-1.3 (via pi, thinking high) each reviewed this diagnosis separately and agreed with it. Codex confirmed the Quickshell mechanism in upstream source. Both found no other reader of the stale property. Their agreement is not guaranteed to be independent.

This now waits on the maintainer: whether to close it as fixed by #14978, or leave it to close when #14591 lands.

omarchybot avatar Oct 22 '26 06:10 omarchybot