Skip to content

perf(tracker): batch fused location delivery to cut wakeups#223

Draft
adsamcik wants to merge 1 commit into
dev/v10from
perf/location-batching-passive
Draft

perf(tracker): batch fused location delivery to cut wakeups#223
adsamcik wants to merge 1 commit into
dev/v10from
perf/location-batching-passive

Conversation

@adsamcik

Copy link
Copy Markdown
Owner

Summary

Battery follow-up from the tracking-architecture review (P2). The fused location request never set setMaxUpdateDelayMillis, so the device wakes for every fix even when nobody is looking at the screen.

Change

  • Adds setMaxUpdateDelayMillis(interval × 3) to the fused LocationRequest in both onEnable and updateInterval, refactored into a shared buildLocationRequest(...) helper (removes duplication).
  • This lets the OS batch several fixes and deliver them together when power-efficient (typically screen-off / Doze-adjacent windows), cutting radio + CPU wakeups. While the app is interactive the platform still delivers promptly.
  • Safe by construction: onNewData already accepts a List<Location> and filters/persists each fix with its own timestamp, so route reconstruction is unaffected by when a batch is delivered. The factor bounds worst-case delivery latency.

Why a constant factor (and not passive / tier-aware priority)

  • AMBIENT tier already uses a non-GPS trigger (AmbientCollectionTrigger), so a "passive listener for AMBIENT" is a separate, more architectural change (tracked as an issue), not a tweak to this trigger.
  • Tier-aware Priority (e.g. LOW_POWER for ECONOMY) would require threading the tier through DynamicIntervalCollectionTrigger.updateInterval(...); kept out of this PR to stay focused and low-risk.

Verification

  • ./gradlew :tracker:engine:compileDebugKotlinBUILD SUCCESSFUL.

Notes

Draft — opened for review. setMaxUpdateDelayMillis is part of the GMS LocationRequest.Builder already used here.

Add setMaxUpdateDelayMillis (3x the collection interval) to the fused
location request in both onEnable and updateInterval, refactored into a
shared buildLocationRequest helper. This lets the OS coalesce several
fixes into one delivery when power-efficient (screen-off / Doze-adjacent),
reducing radio and CPU wakeups. Delivery stays prompt while interactive,
and onNewData already filters/persists each fix in a batch so per-fix
timestamps are preserved.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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