Skip to content

Fix background sync: hold BLE connection alive + persistent flusher + honest upload count - #3

Merged
abdulsaheel merged 1 commit into
mainfrom
fix/background-sync-keepalive
Jun 13, 2026
Merged

Fix background sync: hold BLE connection alive + persistent flusher + honest upload count#3
abdulsaheel merged 1 commit into
mainfrom
fix/background-sync-keepalive

Conversation

@abdulsaheel

Copy link
Copy Markdown
Collaborator

iOS only ever synced on app-open: pauseForBackground disconnected the band, so iOS dropped the Bluetooth assertion and suspended the app in ~34s, and the restore central never armed. Now we KEEP the live connection in the background (iOS resumes us per BLE notification under bluetooth-central) so the drain + upload continue.

  • Add one connection-independent flusher (~15s) that uploads queued records and retries anything a prior tick failed to send (uploader retains rows on any non-200). Removes the per-record flushing that was tripping the backend rate limit. No cooldown.
  • Show the honest uploaded count: read received from the ingest response (the client was reading a non-existent processed field, so it always showed 0/N).
  • BleRestoreManager is recovery-only: event-driven re-arm via setOwnsBand, and the 50-min cooldown timer is gone (replaced by an idle-after-sync flag).
  • Remove the 15-min WorkManager periodic task (iOS + Android) and all its plumbing; Android keep-alive is the Edge Tracking foreground service, iOS is the kept-alive connection with CB state-restoration as recovery only.
  • Ensure the flusher + Android foreground service start on every session-establish path (init/login/reconnect/resume), not just openSession.
  • Cleanup: drop the workmanager dependency, the BGTask/processing/fetch Info.plist entries, and RECEIVE_BOOT_COMPLETED.

… honest upload count

iOS only ever synced on app-open: pauseForBackground disconnected the band, so iOS
dropped the Bluetooth assertion and suspended the app in ~34s, and the restore
central never armed. Now we KEEP the live connection in the background (iOS resumes
us per BLE notification under bluetooth-central) so the drain + upload continue.

- Add one connection-independent flusher (~15s) that uploads queued records and
  retries anything a prior tick failed to send (uploader retains rows on any non-200).
  Removes the per-record flushing that was tripping the backend rate limit. No cooldown.
- Show the honest uploaded count: read `received` from the ingest response (the client
  was reading a non-existent `processed` field, so it always showed 0/N).
- BleRestoreManager is recovery-only: event-driven re-arm via setOwnsBand, and the
  50-min cooldown timer is gone (replaced by an idle-after-sync flag).
- Remove the 15-min WorkManager periodic task (iOS + Android) and all its plumbing;
  Android keep-alive is the Edge Tracking foreground service, iOS is the kept-alive
  connection with CB state-restoration as recovery only.
- Ensure the flusher + Android foreground service start on every session-establish
  path (init/login/reconnect/resume), not just openSession.
- Cleanup: drop the workmanager dependency, the BGTask/processing/fetch Info.plist
  entries, and RECEIVE_BOOT_COMPLETED.
@abdulsaheel
abdulsaheel merged commit dc96860 into main Jun 13, 2026
@abdulsaheel
abdulsaheel deleted the fix/background-sync-keepalive branch June 13, 2026 15:10
abdulsaheel added a commit that referenced this pull request Jun 13, 2026
Merge pull request #3 from OpenStrap/fix/background-sync-keepalive
abdulsaheel added a commit that referenced this pull request Jun 26, 2026
Fix background sync: hold BLE connection alive + persistent flusher + honest upload count
abdulsaheel added a commit that referenced this pull request Jun 26, 2026
Merge pull request #3 from OpenStrap/fix/background-sync-keepalive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant