fix: move blocking IOBluetooth release calls off the main thread - #101
Merged
Conversation
remove/closeConnection are synchronous bluetoothd IPC — seconds against a dead or out-of-range device — and every handoff ran them on main. Move them to bluetoothQueue; callers that sequence on the release get explicit completions. The full-set and single-send handoffs paint .releasing before the releases start and the release path leaves .releasing rows alone, so the isAnyPeripheralTransitioning re-entrancy guards see the in-flight handoff for the whole async window; the disconnect poll loops keep their fast first check via queue FIFO.
|
🎉 This PR is included in version 2.25.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
From the adversarial review sweep (confirmed finding).
unregisterFromPC/disconnectPeripheralranremove/closeConnection— synchronous bluetoothd IPC, documented by Apple as blocking, seconds against a dead or out-of-range device — on the main thread, on every handoff. Their bodies now run onbluetoothQueue;unregisterFromPCgained an optional main-queue completion.Ordering is preserved explicitly where it mattered:
.releasingbefore the releases start, and the release path leaves.releasingrows alone — so theisAnyPeripheralTransitioningre-entrancy guards see the in-flight handoff across the whole async window (a double-pressed hotkey can no longer reverse into a take mid-handoff; this closes a hole the review caught in the first draft).Known secondary effect (review, accepted): a peer-commanded release can lag its ack while
bluetoothQueueis busy, occasionally degrading a first-attempt take to a watchdog/watcher retry — final state unaffected.Test: full-set switch both directions; double-press the toggle hotkey mid-switch (second press must no-op); single release/take from the dropdown; release an already-disconnected peripheral; a lid-close/wake cycle. Typechecked here; please build before merging.