Repository navigation
Description
Investigation: Commits That Could Cause Poor Connectivity & Constant Reconnection (Past 2 Weeks)
Deep scan of all commits from the past 2 weeks across app, backend, and firmware that could affect Bluetooth connectivity and device reconnection behavior.
HIGH RISK
1. allowLongWrite BLE Transport Change — e543b9a23 (Jan 25, @mdmohsin7)
File: app/lib/services/devices/transports/ble_transport.dart:192-195
Changed characteristic.write(data) to conditionally use allowLongWrite: true when data.length > (mtuNow - 3).
Impact: allowLongWrite uses the BLE Prepare Write / Execute Write protocol (multi-step). If mtuNow returns 0 or a small value before MTU negotiation completes, ALL writes get forced through the long-write path. Some firmware may not properly handle this protocol, causing write failures that cascade into disconnects. Affects all device types (Omi, OmiGlass, Frame) since it's in the shared transport layer.
2. Time Sync Write on Every Connection — c9300441a (Jan 29, @mdmohsin7)
File: app/lib/services/devices/omi_connection.dart
connect() now calls performSyncTime() after super.connect(), writing 4 bytes to timeSyncServiceUuid (19b10030-...) on every connection/reconnection.
Impact: Devices running older firmware without this GATT service will hit a Characteristic not found exception on every reconnect attempt. The error is caught, but it adds latency and an extra BLE transaction to every reconnection cycle.
3. OmiGlass Name-Based Routing — b1b640c2b (Jan 30, @aaravgarg)
File: app/lib/services/devices/device_connection.dart:55-71
Routes devices to OmiGlassConnection if deviceName.contains('glass') — extremely broad string match.
Impact: Any Omi device whose name happens to contain "glass" gets routed to a completely wrong connection handler that lacks time sync, button handling, SD card storage, WiFi sync, and accelerometer support. Would cause features to silently fail and potentially trigger reconnection loops.
4. OmiGlass Firmware: BLE Advertising Reduced to Single UUID — 15bba7aee (Jan 31)
File: omiGlass/firmware/src/app.cpp
Only advertises main service UUID; removed battery and device info UUIDs from advertising.
Impact: On iOS, background BLE scanning relies on advertised service UUIDs for reconnection. Removing battery/device info UUIDs from advertising degrades iOS background reconnection for OmiGlass devices.
5. /listen WebSocket Memory Leak Fixes — 62b7540ad, 3a83ad371 (Jan 29, @ngocthinhdp)
File: backend/routers/transcribe.py
Replaced asyncio.create_task() with spawn() pattern that tracks and cancels tasks on disconnect. Added buffer limits (deque(maxlen=...), 10MB audio cap, 100 pending request cap).
Impact: While fixing OOM issues (which themselves caused connection drops), the new task cancellation in finally could leave STT connections dirty if tasks don't handle CancelledError properly. Buffer limits silently drop data under load.
6. Pusher Pod Memory Leak Fix — 7c046161b (Jan 19)
File: backend/routers/pusher.py
Added 300s HTTP timeouts to speaker_embedding/vad calls (previously no timeout). Introduced 1-second batching for transcript queue.
Impact: Fundamentally changes data flow timing. The 1s batching delay changes when clients receive transcript events. Non-atomic batch = queue.copy(); queue = [] could lose items between copy and clear.
MEDIUM RISK
7. Battery Level Throttling — 33580fb1c (Jan 29, @ngocthinhdp)
File: app/lib/providers/device_provider.dart:164-178
notifyListeners() now suppressed unless battery changes by >= 5% or 15 minutes elapse.
Impact: Battery updates served as an implicit "device alive" signal. Throttling these means the UI may show stale connection state. If any reconnection logic depended on provider notifications, it could be delayed.
8. Metrics Notifications Disabled — 33580fb1c (Jan 29, @ngocthinhdp)
File: app/lib/providers/capture_provider.dart
_metricsNotifyEnabled = false by default.
Impact: The periodic metrics timer no longer calls notifyListeners(). Any watchdog or health-check logic listening for BLE receive rate / WS send rate updates would be starved.
9. Bluetooth Discoverer Timing — f5295d3a0 (Jan 21, @mdmohsin7)
File: app/lib/services/devices/discovery/bluetooth_discoverer.dart
Added 2-second delay before starting scan + 5-second timeout on adapter state.
Impact: 2-second window where no scan is happening. If Bluetooth is slow to enable (cold boot), the 5-second timeout could cause scan to return empty.
10. Backend-listen Node Affinity — b22123be6 (Jan 24)
Pods now require type: high-cpu nodes. If insufficient nodes are available, pods stay in Pending, reducing connection capacity.
11. WiFi Sync Wait 3s → 8s — c680cffb0 (Jan 29, @mdmohsin7)
Longer delay with BLE + WiFi both active = more radio contention time on 2.4GHz.
12. Auto-Assign Speaker Labels — e7f2085dc (Jan 30)
Changes when websocket.send_json() fires (deferred until after assignment). Could change client-side WebSocket message handling behavior.
Summary: Most Likely Root Causes (Ranked)
| # | Commit | Change | Why |
|---|---|---|---|
| 1 | e543b9a23 |
allowLongWrite in BLE transport |
Affects ALL BLE writes for ALL devices; MTU race condition could force wrong write mode |
| 2 | 62b7540ad |
/listen WebSocket refactor |
OOM fixes are good, but task cancellation and buffer limits could cause connection drops |
| 3 | c9300441a |
Time sync on every connect | Extra BLE write fails on older firmware, adds latency to every reconnection |
| 4 | 7c046161b |
Pusher pod refactor | Changed data flow fundamentally; timing issues could affect streaming |
| 5 | 33580fb1c |
Battery + metrics throttling | UI appears disconnected; health signals suppressed |
| 6 | b1b640c2b |
OmiGlass name routing | Would break any device matching "glass" |
Recommended Next Steps
- Check if
allowLongWriteis causing failures — Add logging aroundmtuNowvalue at write time; verify firmware handles Prepare Write protocol - Test time sync on older firmware — Verify
performSyncTime()failure doesn't destabilize the connection cycle - Tighten OmiGlass name matching —
contains('glass')is too broad; use exact match or device type only - Verify iOS background reconnection for OmiGlass after advertising UUID reduction
- Monitor
/listenpod memory and connection counts after the spawn() refactor
Activity
beastoin commentedon Feb 2, 2026
it's not confirmed yet btw.
@TuEmb, please keep us updated on the issue.
@aaravgarg the connection issue is between the device and the app. You could use that information to help the AI narrow down its findings. More strict and clear requirements would help them a lot.
TuEmb commentedon Feb 2, 2026
User feedback:
TuEmb commentedon Feb 2, 2026
I'm debugging with this guy
TuEmb commentedon Feb 2, 2026
aaravgarg commentedon Feb 2, 2026
@mdmohsin7 u recently showed me the issue that os is killing app in bg when we met
can u add more info on that, that could be the key issue
beastoin commentedon Feb 3, 2026
@aaravgarg @TuEmb Update: We recently fixed transcription service issues caused by a bad commit from ~1 week ago. Some connectivity/sync issues may have been side effects.
Please verify if BLE issues still reproduce after the fix.
by AI for @beastoin
TuEmb commentedon Feb 3, 2026
Note: I'm testing the case of long-write for device: pair to CV1, then send a GATT message with length > MTU size (ex: 1000 bytes)
beastoin commentedon Feb 3, 2026
Potential BLE disconnect cause on Android: the Wi-Fi setup write (SSID+password) can exceed the negotiated MTU payload and now uses allowLongWrite (Prepare/Execute). If the device’s GATT characteristic doesn’t support long write properly, the Android stack can error and drop the connection. Example: MTU 50 -> payload 47; SSID+password 100 bytes triggers long write.
by AI for @beastoin
beastoin commentedon Feb 3, 2026
Yeah, go ahead with the test: #4521 (comment), then let me know.
beastoin commentedon Feb 3, 2026
More refs on allowLongWrite / GATT long write (client-side): FlutterBluePlus docs state allowLongWrite uses the long write BLE protocol and requires peripheral support; interrupted transfers can leave partial writes, and it’s only for writes with response. https://pub.dev/documentation/flutter_blue_plus/latest/flutter_blue_plus/BluetoothCharacteristic-class.html
Server-side support is the GATT Prepare Write / Execute Write procedure (prepare write request opcode), which the peripheral must handle and respond to; Silicon Labs docs outline prepare write requests for GATT server handlers. https://docs.silabs.com/bluetooth/10.1.0/bluetooth-stack-api/sl-bt-evt-gatt-server-user-write-request
General note: long read/write is used when characteristic value exceeds MTU. https://en.wikipedia.org/wiki/Bluetooth_Low_Energy#Long_read_and_long_write
by AI for @beastoin
mdmohsin7 commentedon Feb 3, 2026
Key line is
Killing 10277:com.friend.ios/u0a999 (adj 905): Async binder space running out while frozenbeastoin commentedon Feb 4, 2026
@mdmohsin7 what does this mean, and can you fix it?
beastoin commentedon Feb 6, 2026
@TuEmb guys, any updates on this one, either PR or committee feedback?
mdmohsin7 commentedon Feb 6, 2026
Yes already fixed in #4589 , it wasn't effecting everyone, only those who didn't give location permission. Our background service (used for location fetching every 5 mins) is also used to tell android that the same service uses ConnectedDevice foreground service type and hence the OS should not terminate the app when minimised. Fastest fix is to just let it run irrespective of location permission granted or not (we anyway gate the actual location fetching within the background service so it won't actually fetch the location), a good fix is to decouple both and have a very lightweight sticky foreground service (similar to how limitless and others do it)