Repository navigation
fix(app): reduce and diagnose iOS background energy - #11892
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
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
e570427 to
58340d5
Compare
|
Monitor fix pass (auto-generated summary):
|
…energy-ci-fix # Conflicts: # app/ios/Runner/Ble/BleHostApiImpl.swift # app/ios/Runner/Ble/OmiBleManager.swift
undivisible
left a comment
There was a problem hiding this comment.
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.
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 compiledAppDelegate,OmiBleManager,OmiBleEnergyPolicy, and the Pigeon bridge for arm64 and x86_64.The default
devscheme is currently blocked before Runner compilation by the existingomiWatchAppasset/WatchKitconfiguration. 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.dartcovers session duration, byte deltas, native offline-writer counters, device-stable diagnostics, reset clamping, and fail-open analytics.app/test/providers/capture_provider_test.dartcovers 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.dartcovers pausing the UI sampler while lifetime counters continue.app/ios/test/omi_ble_energy_policy_test.rbcovers 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-policymanifest 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 iOSUserDefaultspersistence inside the native BLE owner.