fix: make magic peripheral handoff resilient (+ extend to adoption, cleanups)#57
Merged
Merged
Conversation
Builds on the cherry-picked handoff-resilience fix. Behavior change: - `continueAdoption` is a take-from-peer grab (it claims a peripheral when the peer vanishes), so it now passes `refreshPairingBeforeConnect: true` like the other take-from-peer callers. Without it, adoption hits the same stale `paired=true` / `openConnection()`-fails dead end the fix removes. Stays silent (`announcePairTimeout: false`) — it's a background retry. Cleanups (no behavior change): - Extract the duplicated `75` body-timeout literal into a named `NetworkDeviceStore.handoffBodyTimeout`, documenting the cross-file invariant: it must exceed the 60s pair watchdog and stay <= IncomingConnection.idleTimeout, so neither side gives up before the receiver acks the real connect result. - Explain why IncomingConnection.idleTimeout was raised 30s -> 75s. - Comment the post-`-remove` Thread.sleep: it lets the async unbond settle and only stalls the background bluetoothQueue, never the UI.
|
🎉 This PR is included in version 2.17.1 🎉 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.
Summary
Cherry-picks upstream
iFurySt/magic-switch@270c1e5("fix: make magic peripheral handoff resilient"), original author preserved, then extends it to this fork's adoption path and tidies the new code to match repo conventions.What the upstream fix does
paired=truewhileopenConnection()fails; the old path gave up and left it connectable on neither Mac. It now-removes the stale bond and re-pairs.CONNECT_ALL/CONNECT_ONEreceivers ack the real connect result instead of "command received", so a failed handoff is actually rolled back / reclaimed by the sender.This fork's additions (2nd commit)
continueAdoption— this fork's "adopt when the peer vanishes" path (feat: adopt peripherals when the other Mac sleeps or vanishes #54, which upstream never saw) is itself a take-from-peer grab, so it now passesrefreshPairingBeforeConnect: true(kept silent, since it's a background retry). Without it, adoption hits the samepaired=true/openConnection()-fails dead end the fix removes.75body-timeout literal into a namedNetworkDeviceStore.handoffBodyTimeoutwith the cross-file invariant documented (must exceed the 60s pair watchdog, stay<=IncomingConnection.idleTimeout); document whyidleTimeoutwent 30s -> 75s; comment the post--removeThread.sleep.Cherry-pick conflict resolution (folded into 1st commit)
reconnectInFlight.remove(id)to the top ofreclaimIfPeerIsFree's else-block, so I dropped upstream's duplicate and kept the newconnectPeripheral(...)signature.Verification
xcodebuild -scheme "Magic Switch" -configuration Debug-> BUILD SUCCEEDED.