Skip to content

fix(app): reduce and diagnose iOS background energy - #11892

Merged
Git-on-my-level merged 7 commits into
mainfrom
codex/ios-background-energy-telemetry
Aug 20, 2026
Merged

Git-on-my-level merged 7 commits into
mainfrom
codex/ios-background-energy-telemetry

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Aug 19, 2026 •

Copy link
Copy Markdown
Member

What changed and why

iOS battery reports showed Omi consuming 29–61% with 6h36m–17h32m of background activity, matching the reconnect/write amplification reported in #11307. This removes idle background owners, bounds resource-only loops, and emits one privacy-safe summary per meaningful background session so future regressions can be attributed to BLE traffic, native offline writes, WebSocket traffic, or reconnect churn.

Product invariants affected

none

How it was verified

  • bash test.sh — all 1,384 Flutter tests passed (5 skipped).
  • app/scripts/analyze_ratchet.sh — passed with no new analyzer findings.
  • ruby app/ios/test/omi_ble_energy_policy_test.rb — passed the native RSSI and battery-history policy assertions.
  • xcodebuild -workspace app/ios/Runner.xcworkspace -scheme raybanDat -configuration Debug-dev -sdk iphonesimulator -destination 'generic/platform=iOS Simulator' CODE_SIGNING_ALLOWED=NO ASSETCATALOG_COMPILER_APPICON_NAME= build — succeeded and compiled AppDelegate, OmiBleManager, OmiBleEnergyPolicy, and the Pigeon bridge for arm64 and x86_64.
  • Independent Luna review found the native batch-counter blind spot, the stop-during-codec-lookup race, manual-disconnect overcounting, and device-swap attribution risk; each was reproduced against the production path and addressed before this verification pass.

The default dev scheme is currently blocked before Runner compilation by the existing omiWatchApp asset/WatchKit configuration. The paired iPhone 15 Pro Max was listed as unavailable, so a multi-hour physical-device background-energy run was not possible in this session; this PR does not claim that validation.

Tests

  • app/test/utils/analytics/background_resource_telemetry_test.dart covers session duration, byte deltas, native offline-writer counters, device-stable diagnostics, reset clamping, and fail-open analytics.
  • app/test/providers/capture_provider_test.dart covers idle keepalive suppression, active device/system-audio reconnects, first-transcript location capture without the foreground isolate, and stopping while codec lookup is in flight.
  • app/test/services/capture/capture_metrics_tracker_test.dart covers pausing the UI sampler while lifetime counters continue.
  • app/ios/test/omi_ble_energy_policy_test.rb covers diagnostic-only RSSI polling and bounded battery-history persistence.

Failure class (fixes)

Failure-Class: none

New guards (only when adding a check or ratchet)

The ios-ble-energy-policy manifest check would have caught #11307's always-on RSSI polling and notification-rate battery-history rewrites. This is not a shared primitive because the guarded behavior is specifically CoreBluetooth polling and iOS UserDefaults persistence inside the native BLE owner.

Review in cubic

@mintlify

mintlify Bot commented Aug 19, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
omi 🟢 Ready View Preview Aug 19, 2026, 9:48 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

Git-on-my-level and others added 2 commits August 20, 2026 08:04
Stop the iOS-only foreground-task engine and unused app-refresh request, gate reconnects and UI samplers on active work, limit diagnostic RSSI polling, and throttle native battery-history writes. Add one background-session resource event with Dart and native offline-writer counters plus BLE failure context.

Failure-Class: none
Run dart format --line-length 120 over the PR's changed non-generated
Dart files (home page diagnostics, capture provider, capture controller,
capture provider test) to satisfy the repo-checks Formatting gate.

Failure-Class: none
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Monitor fix pass (auto-generated summary):

@undivisible undivisible left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

The focused smoke is green on the live head: the Ruby BLE energy-policy test passed, the background telemetry tests passed (3), and the capture/device/metrics tests passed (101).

Residual validation is still material for this energy-sensitive change: the Watch scheme is blocked by its current asset/WatchKit configuration, and no paired iPhone was available for a multi-hour background run. Simulator/build and unit coverage establish wiring and bounded behavior, but not real BLE reconnect/write amplification or battery drain on device. I’m leaving this review-only until physical-device evidence covers the iOS path and the Watch path if it remains in release scope.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Real iOS background-energy regression (#11307) with native + Flutter tests and analyzer clean; approve-only since the diff is well over the 300-line merge gate for mobile.

@Git-on-my-level
Git-on-my-level merged commit 613622b into main Aug 20, 2026
25 of 26 checks passed
@Git-on-my-level
Git-on-my-level deleted the codex/ios-background-energy-telemetry branch August 20, 2026 20:19
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.

3 participants