Repository navigation
fix(ios): salvage incidental BLE cleanups from reverted keepalive - #11576
Conversation
There was a problem hiding this comment.
1 issue found across 7 files
Confidence score: 3/5
- In
app/ios/Runner/Ble/OmiBleManager.swift, the restoration reconnect path can miss retries if a re-issued connection fails before the 200 ms closure executes, so iOS suspension may leave peripherals stuck disconnected until manual recovery; persist a reconnect deadline and flush overdue reconnect work during restoration/powered-on handling to make retries resilient.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="app/ios/Runner/Ble/OmiBleManager.swift">
<violation number="1" location="app/ios/Runner/Ble/OmiBleManager.swift:603">
P2: When a restored peripheral fails its re-issued connection before the 200 ms closure runs, iOS can suspend the process and lose the retry. Persist a reconnect deadline and flush due work from restoration, powered-on, failure, and foreground recovery callbacks.
(Based on your team's feedback about durable BLE reconnect deadlines.)</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| // State-restored peripherals have already connected in a prior | ||
| // process lifetime; mark them so reconnectStalePeripherals will | ||
| // re-issue connect instead of treating them as scan strangers. | ||
| everConnected.insert(uuid) |
There was a problem hiding this comment.
P2: When a restored peripheral fails its re-issued connection before the 200 ms closure runs, iOS can suspend the process and lose the retry. Persist a reconnect deadline and flush due work from restoration, powered-on, failure, and foreground recovery callbacks.
(Based on your team's feedback about durable BLE reconnect deadlines.)
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/ios/Runner/Ble/OmiBleManager.swift, line 603:
<comment>When a restored peripheral fails its re-issued connection before the 200 ms closure runs, iOS can suspend the process and lose the retry. Persist a reconnect deadline and flush due work from restoration, powered-on, failure, and foreground recovery callbacks.
(Based on your team's feedback about durable BLE reconnect deadlines.) </comment>
<file context>
@@ -561,6 +597,10 @@ extension OmiBleManager: CBCentralManagerDelegate {
+ // State-restored peripherals have already connected in a prior
+ // process lifetime; mark them so reconnectStalePeripherals will
+ // re-issue connect instead of treating them as scan strangers.
+ everConnected.insert(uuid)
uuids.append(uuid)
</file context>
Stop the 3s readRSSI keep-alive (poll only while diagnostics is subscribed), mark CoreBluetooth-restored peripherals as everConnected, throttle battery-history writes, and retry a silent audio CCCD once after reconnect. Audio notify UUIDs live next to the constants in models.dart; no Dart reconnect-policy mirror. Salvaged from #11547 as called out in #11567. Failure-Class: none Co-authored-by: Cursor <[email protected]>
…veness timer on disconnect - Rehydrate lastPersistedBatteryLevel/AtMs from the newest persisted history entry so the first battery notification after a process restart is throttled against the prior persisted sample. - Cancel _audioLivenessTimer and reset _audioSilenceResubscribes at the top of disconnect(), matching dispose() and _handleConnectionState(false), so a stale watch cannot fire into a later connection.
a632aea to
0b4cb2b
Compare
|
Addressed the Cubic review round on
Verification: focused suites |
Summary
readRSSIkeep-alive (poll only while diagnostics is subscribed), mark CoreBluetooth-restored peripherals aseverConnected, throttle battery-history writes, and one CCCD re-subscribe if audio is silent for 4s after reconnect.models.dartfor the Dart transport watch. There is noble_reconnect_policy.dartand no comment-synced Swift copy. Android RSSI keep-alive is untouched.flutter_foreground_task, 200ms→60s BLE backoff,configureForBluetoothdeactivate, or removing the 5-minute Geolocator poll.Related: #11547 (reverted), #11567 (revert), #10573 (draft; RSSI-on-demand overlap inside a much larger DFU/GATT rewrite — not a substitute for this salvage). Related: #5491, #6570. Not a fix for #11307.
Product invariants affected
none
Failure class (fixes)
Failure-Class: none
Test plan
cd app && bash test.sh test/unit/native_ble_transport_resync_test.dart test/services/devices/transports/native_ble_transport_test.dart— 6 passed (silent CCCD retried once then left dead; Bee UUID arms the watch; existing resubscribe tests)readRSSIkeep-alivereconnectStalePeripheralswill re-issue connect