Skip to content

[Limitless Pendant][iOS] BLE reconnect gets stuck ("connecting") after background disconnect, times out ~60s, no auto-retry until force-quit #6610

Closed

Description

@omi-discord-vector

Summary

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)
  • Example span (UTC):
    • wal_initialized 04:39:04Z
    • device_connection_state: disconnected 04:40:03.941Z
    • 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.

Environment

  • App: Omi AI 1.0.531 (812)
  • Device: iPhone
  • OS: iOS 26.4
  • Third-party device: Limitless Pendant
  • Reporter: Discord @twilsonco

Activity

  1. added
    bug
    on Apr 13, 2026
  2. omi-discord-vector commented on Apr 14, 2026

    @omi-discord-vector
    Author

    @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.

  3. mdmohsin7 commented on Apr 15, 2026

    @mdmohsin7
    Member

    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:

    1. App backgrounded, pendant connected.
    2. Pendant goes out of range → CoreBluetooth fires didDisconnectPeripheral → Swift schedules the 200 ms retry (line 447-451).
    3. Pendant is still out of range when the retry fires → CoreBluetooth fires didFailToConnect → Swift cleans up and returns (line 423-428). No further retry.
    4. Dart-side NativeBleTransport 60 s completer times out (line 65-68), state flips to disconnected.
    5. User foregrounds the app — nothing in the resume path observes the disconnected state to re-kick (gap 2).
    6. 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.

    — caleb

  4. mdmohsin7 commented on Apr 16, 2026

    @mdmohsin7
    Member
  5. added
    p1
    on May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugp1

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions