Repository navigation
bluetooth: resync adapter power state via GetAll after InterfacesAdded - #1372
fjgarciainclan wants to merge 1 commit into
Conversation
The properties bundled with InterfacesAdded are a snapshot BlueZ took at signal-emission time. If the adapter was still mid-transition (PowerState "off-enabling"/"on-disabling") at that instant, and the PropertiesChanged that completes the transition reaches the bus before our PropertiesChanged subscription (registered in the constructor, just before addInterface runs) is fully installed, we never see it and are stuck showing the stale transitional state forever - this is what issue quickshell-mirror#1156 and several Omarchy duplicates describe. Re-fetch once via GetAll right after applying the InterfacesAdded snapshot, now that the subscription is guaranteed live, so we reconcile with BlueZ's actual current state instead of trusting a possibly-outdated snapshot. This is a single query triggered by the InterfacesAdded event itself, not a poll. Fixes quickshell-mirror#1156 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Tested, and I confirm this fixes it. Setup: quickshell 0.3.2.r7.g2b4501a (Omarchy 4.0.6), BlueZ 5.87, kernel 7.2.8, Intel AX201. I hit the bug twice after resume from hibernate; the dead shell's log ( Deterministic repro without sleeping: Unpatched its stuck at |
The properties bundled with InterfacesAdded are a snapshot BlueZ took at signal-emission time. If the adapter was still mid-transition (PowerState "off-enabling"/"on-disabling") at that instant, and the PropertiesChanged that completes the transition reaches the bus before our PropertiesChanged subscription (registered in the constructor, just before addInterface runs) is fully installed, we never see it and are stuck showing the stale transitional state forever - this is what issue #1156 and several Omarchy duplicates describe. Re-fetch once via GetAll right after applying the InterfacesAdded snapshot, now that the subscription is guaranteed live, so we reconcile with BlueZ's actual current state instead of trusting a possibly-outdated snapshot. This is a single query triggered by the InterfacesAdded event itself, not a poll. Fixes #1156 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> upstream: quickshell-mirror/quickshell#1372
|
Tested this on a machine that reproduced the bug on 3 of 3 S3 resumes. Setup: Omarchy 4.5.0-3, kernel Before the patch (official An independent GDBus client recorded the adapter re-registration on every wake, at the same So BlueZ did emit the completing transition, but Quickshell did not reconcile it. This is the same race the PR describes, with the adapter path unchanged. (I did not capture Quickshell's own debug log, so I can't distinguish a missed signal from a received-and-discarded one.) After the patch, 3 of 3 S3 resumes with the same re-registration sequence:
The Caveat: one machine, three wakes. A 5-second poller never observed |
Summary
Fixes #1156 — the Bluetooth adapter's
enabled/statecan get permanentlystuck on a transitional power state (
Enabling/Disabling) even though theadapter is actually powered and in use, most commonly after sleep/resume when
BlueZ removes and re-registers the adapter object.
Root cause:
BluetoothAdapter::addInterface()(src/bluetooth/adapter.cpp)applies the property values bundled inside the
InterfacesAddedD-Bus signalas the adapter's entire initial state, once, and never re-reads it. That
bundled snapshot is whatever BlueZ's internal state was at the instant it
emitted the signal. If the adapter was still mid-transition at that moment,
and the
PropertiesChangedsignal that completes the transition reaches thebus before our subscription (set up in the constructor, immediately before
addInterfaceruns) is fully installed on the bus daemon, that completingsignal is missed — nothing afterward ever triggers a re-read, so the panel
is stuck showing "off" forever despite
bluetoothctl/busctlreporting theadapter correctly as powered on.
Reproduced and diagnosed from a report on the Omarchy shell (same bug
reported from the shell side: omacom/omarchy#9561), confirmed via
bluetoothctl show/busctl get-property .../Adapter1 PoweredshowingPowered: truewhile the panel (bound to Quickshell's cached adapter state)displayed "Turned Off".
Fix
After applying the
InterfacesAddedsnapshot, issue oneGetAllcall viathe already-existing
DBusPropertyGroup::updateAllViaGetAll()to reconcilewith BlueZ's actual current state. Because D-Bus delivers messages from a
single client to the daemon in order, this
GetAllrequest is guaranteed tobe processed only after our
PropertiesChangedsubscription (sent momentsearlier, in the constructor) is already in effect at the daemon. So either:
GetAllreply arrives, and we get the correct state directly, or
completion signal (previously missed) will arrive normally.
This is a single event-triggered read fired once per adapter by the
InterfacesAddedevent itself — not a timer-based poll, per the concernraised on #1156 about a polling approach.
Testing
Built clean against Qt 6.12 (
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug/ninja, 1339/1339 targets, exit 0). I don't have a controllable reproenvironment to force BlueZ into emitting an
InterfacesAddedwith a stucktransitional snapshot, so this hasn't been runtime-verified against the
original failure yet — flagging that explicitly for review.