You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Limitless Pendant][iOS] BLE reconnect gets stuck ("connecting") after background disconnect, times out ~60s, no auto-retry until force-quit #6610
If the Limitless Pendant's BLE connection drops while the iOS app is backgrounded, reopening the app often shows it stuck "Connecting". Logs indicate the app attempts to reconnect, then times out and transitions to disconnected, and does not automatically retry. Users report it only recovers after force-quitting and reopening the app.
(Separate from conversation chunking issue #6551.)
Evidence from user logs
device_connection_state: connecting followed by disconnected after ~60 seconds (repeatable pattern)
later reconnect succeeds quickly after app restart:
device_connection_state: connecting 04:53:19.966Z
device_connection_state: connected 04:53:21.064Z
User also notes multiple occurrences across the day with the same ~60s timeout behavior.
Expected
If a reconnect attempt fails/times out, app should:
reset BLE connection state (cancel connection, rescan, recreate central manager if needed), and
automatically retry (with backoff) instead of stopping.
Actual
Reconnect attempt times out and the app remains disconnected until force-quit.
Suspected root cause (from user analysis)
Potential stale CBCentralManager / cached peripheral handle state after backgrounding. Force-quit resets BLE stack, making reconnect succeed in ~1-2 seconds.
@mdmohsin7 tagging you since this looks like the core BLE reconnect issue (60s connect timeout + no retry unless force-quit). See Discord thread context + attached logs/writeup.
Traced this end-to-end against origin/main at e2483828f. The bug is real and reproducible from the code. Two gaps in the iOS BLE layer combine to leave the app stuck "disconnected" after a backgrounded drop.
Gap 1 — didFailToConnect has no retry.
In app/ios/Runner/OmiBleManager.swift:423-428, when a connect attempt fails (peripheral out of range, not advertising, BLE-chipset-level failure), the handler cleans up the peripheral and notifies Dart — no retry is scheduled. The retry that does exist is only in the sibling didDisconnectPeripheral handler at OmiBleManager.swift:445-452: a single 200 ms-delayed centralManager.connect(peripheral, options: nil). If that one retry then lands back in didFailToConnect — which is exactly what happens if the peripheral is gone — the chain stops dead.
Gap 2 — no app-resume BLE recheck. app/lib/main.dart:264-272 only handles AppLifecycleState.paused and detached. The home page's resumed branch at app/lib/pages/home/page.dart:201-214 refreshes conversations, agent VM, and Apple Reminders — nothing touches BLE. On the Dart side, DeviceService.ensureConnection at app/lib/services/devices.dart:232-237 explicitly defers to native for reconnection (comment: "Transport exists for this device but disconnected — native handles reconnection. Don't dispose and recreate the transport; that would cancel native's auto-reconnect"), on the assumption that native's loop is sufficient. It isn't — per Gap 1.
The observed ~60 s timeout matches Dart's NativeBleTransport hardcoded completer timeout at app/lib/services/devices/transports/native_ble_transport.dart:65-68 (const Duration(seconds: 60) → TimeoutException('Device ready timeout after 60s')). On timeout, state flips to disconnected and the exception is rethrown; nothing catches it to retry.
Why force-quit recovers.
Force-quit deallocates the CBCentralManager singleton along with any in-flight connect attempt stuck inside CoreBluetooth. A fresh central manager on relaunch attempts connect() cleanly; the pendant is typically back in range by then and connects in 1–2 s. The reporter's "stale CBCentralManager" hypothesis isn't exactly right — the manager itself isn't corrupt — but the symptom is identical because no code path in the running app schedules a new attempt after a hard failure.
Limitless-Pendant-specific?
No. The iOS path is the shared OmiBleManager used for all BLE devices. Limitless detection happens in Dart at app/lib/backend/schema/bt_device/bt_device.dart:777-791 (isLimitlessDevice / isLimitlessDeviceFromDevice) and routes through the same NativeBleTransport. The bug is more observable on Limitless users because they move out of range / re-pair more often than users with a consistent Omi wearable, but the root cause applies to every BLE-connected device type.
Summary of the failure chain:
App backgrounded, pendant connected.
Pendant goes out of range → CoreBluetooth fires didDisconnectPeripheral → Swift schedules the 200 ms retry (line 447-451).
Pendant is still out of range when the retry fires → CoreBluetooth fires didFailToConnect → Swift cleans up and returns (line 423-428). No further retry.
Dart-side NativeBleTransport 60 s completer times out (line 65-68), state flips to disconnected.
User foregrounds the app — nothing in the resume path observes the disconnected state to re-kick (gap 2).
Force-quit + relaunch creates a fresh central manager → clean connect() → pendant in range again → succeeds in 1–2 s.
Findings only, no fix proposed here. Root cause is missing retry on didFailToConnect plus no AppLifecycleState.resumed hook that re-checks BLE connection state.
Activity
omi-discord-vector commentedon Apr 14, 2026
@mdmohsin7 tagging you since this looks like the core BLE reconnect issue (60s connect timeout + no retry unless force-quit). See Discord thread context + attached logs/writeup.
mdmohsin7 commentedon Apr 15, 2026
Traced this end-to-end against
origin/mainate2483828f. The bug is real and reproducible from the code. Two gaps in the iOS BLE layer combine to leave the app stuck "disconnected" after a backgrounded drop.Gap 1 —
didFailToConnecthas no retry.In
app/ios/Runner/OmiBleManager.swift:423-428, when a connect attempt fails (peripheral out of range, not advertising, BLE-chipset-level failure), the handler cleans up the peripheral and notifies Dart — no retry is scheduled. The retry that does exist is only in the siblingdidDisconnectPeripheralhandler atOmiBleManager.swift:445-452: a single 200 ms-delayedcentralManager.connect(peripheral, options: nil). If that one retry then lands back indidFailToConnect— which is exactly what happens if the peripheral is gone — the chain stops dead.Gap 2 — no app-resume BLE recheck.
app/lib/main.dart:264-272only handlesAppLifecycleState.pausedanddetached. The home page'sresumedbranch atapp/lib/pages/home/page.dart:201-214refreshes conversations, agent VM, and Apple Reminders — nothing touches BLE. On the Dart side,DeviceService.ensureConnectionatapp/lib/services/devices.dart:232-237explicitly defers to native for reconnection (comment: "Transport exists for this device but disconnected — native handles reconnection. Don't dispose and recreate the transport; that would cancel native's auto-reconnect"), on the assumption that native's loop is sufficient. It isn't — per Gap 1.The observed ~60 s timeout matches Dart's
NativeBleTransporthardcoded completer timeout atapp/lib/services/devices/transports/native_ble_transport.dart:65-68(const Duration(seconds: 60)→TimeoutException('Device ready timeout after 60s')). On timeout, state flips todisconnectedand the exception is rethrown; nothing catches it to retry.Why force-quit recovers.
Force-quit deallocates the
CBCentralManagersingleton along with any in-flight connect attempt stuck inside CoreBluetooth. A fresh central manager on relaunch attemptsconnect()cleanly; the pendant is typically back in range by then and connects in 1–2 s. The reporter's "stale CBCentralManager" hypothesis isn't exactly right — the manager itself isn't corrupt — but the symptom is identical because no code path in the running app schedules a new attempt after a hard failure.Limitless-Pendant-specific?
No. The iOS path is the shared
OmiBleManagerused for all BLE devices. Limitless detection happens in Dart atapp/lib/backend/schema/bt_device/bt_device.dart:777-791(isLimitlessDevice/isLimitlessDeviceFromDevice) and routes through the sameNativeBleTransport. The bug is more observable on Limitless users because they move out of range / re-pair more often than users with a consistent Omi wearable, but the root cause applies to every BLE-connected device type.Summary of the failure chain:
didDisconnectPeripheral→ Swift schedules the 200 ms retry (line 447-451).didFailToConnect→ Swift cleans up and returns (line 423-428). No further retry.NativeBleTransport60 s completer times out (line 65-68), state flips todisconnected.connect()→ pendant in range again → succeeds in 1–2 s.Findings only, no fix proposed here. Root cause is missing retry on
didFailToConnectplus noAppLifecycleState.resumedhook that re-checks BLE connection state.— caleb
mdmohsin7 commentedon Apr 16, 2026
#6674
fix(ble): restore audio after Limitless pendant reconnect on iOS
fix(ble): restore audio after Limitless pendant reconnect on iOS
fix(ble): restore audio after Limitless pendant reconnect on iOS (#7725)
style(app): dart format BLE reconnect retry wiring (BasedHardware#6610)
fix(app): address cubic review on BLE reconnect retry (BasedHardware#…
fix(app): add missing library directive to ble_connect_retry.dart
fix(ios): stop background audio keep-alive and back off BLE timeouts (#…