Repository navigation
Revert "fix(ios): stop background audio keep-alive and back off BLE timeouts" - #11567
Merged
mdmohsin7 merged 1 commit intoAug 14, 2026
Merged
Conversation
mdmohsin7
deleted the
revert-11547-fix/ios-background-battery-keepalive
branch
August 14, 2026 10:47
1 of 5 tasks
Git-on-my-level
added a commit
that referenced
this pull request
Aug 14, 2026
Stop the 3s readRSSI keep-alive (poll only while diagnostics is subscribed), mark CoreBluetooth-restored peripherals as everConnected, throttle battery-history writes, and retry a silent audio CCCD once after reconnect. Audio notify UUIDs live next to the constants in models.dart; no Dart reconnect-policy mirror. Salvaged from #11547 as called out in #11567. Failure-Class: none Co-authored-by: Cursor <[email protected]>
Git-on-my-level
added a commit
that referenced
this pull request
Aug 20, 2026
…1576) * fix(ios): salvage incidental BLE cleanups from reverted keepalive Stop the 3s readRSSI keep-alive (poll only while diagnostics is subscribed), mark CoreBluetooth-restored peripherals as everConnected, throttle battery-history writes, and retry a silent audio CCCD once after reconnect. Audio notify UUIDs live next to the constants in models.dart; no Dart reconnect-policy mirror. Salvaged from #11547 as called out in #11567. Failure-Class: none Co-authored-by: Cursor <[email protected]> * fix: address review — restore battery throttle baseline and cancel liveness timer on disconnect - Rehydrate lastPersistedBatteryLevel/AtMs from the newest persisted history entry so the first battery notification after a process restart is throttled against the prior persisted sample. - Cancel _audioLivenessTimer and reset _audioSilenceResubscribes at the top of disconnect(), matching dispose() and _handleConnectionState(false), so a stale watch cannot fire into a later connection. --------- Co-authored-by: Cursor <[email protected]> Co-authored-by: David Zhang <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reverts #11547.
What changed and why
#11547 was premised on
flutter_foreground_taskholdingAVAudioSessionon iOS ("green mic all day"). It does not. The plugin's iOS implementation is a BGTaskScheduler refresh task (com.pravera.flutter_foreground_task.refresh, registered inapp/ios/Runner/Info.plist) and contains noAVAudioSessionreference of any kind —grep -rin "avaudio\|audio" ios/Classesinflutter_foreground_task-9.1.0returns nothing. Background execution on iOS comes fromUIBackgroundModes(audio,location,bluetooth-central) in Info.plist, independent of the plugin. Every downstream decision in that PR — when to hold, when to release, the 5s stale-audio window, the startup grace, the liveness timer — was tuned against a mechanism that does not exist, so the policy cannot be reviewed on its merits.Four grounds for reverting rather than patching forward:
The stated cause is contradicted by the platform sources (above). ~700 of the 1231 added lines are control logic over a no-op on iOS.
It moves against the defect it cites. iOS background BLE timeouts leave live transcription unavailable for minutes to hours #11307 reports background reconnect gaps from 3.9s to 7,335s and asks for prompt re-establishment of the BLE audio path. fix(ios): stop background audio keep-alive and back off BLE timeouts #11547 adds escalating backoff (200ms → 2s → 10s → 30s → 60s) and states in its own body that iOS background BLE timeouts leave live transcription unavailable for minutes to hours #11307 stays open. The premise behind the backoff is also a misread: iOS
central.connecthas no timeout — it parks a pending connect at the chipset level (the deleted comment said exactly this), so the 200ms was a delay before parking one, not a poll interval. There was no retry storm to back off from; the attempt rate is set by how fast CoreBluetooth reports failures.It shipped a duplication that already drifted into a live defect.
app/lib/services/devices/ble_reconnect_policy.dartdeclares itself the "testable SoT" for logic that only executes in Swift, has zero production callers, and is kept in sync by comments alone. Inside fix(ios): stop background audio keep-alive and back off BLE timeouts #11547's own follow-up commits the halves diverged: the Dart audio-UUID set gained Bee (b189a505…), Fieldy (82a48422…) and Plaud (00002bb0…);OmiBleManager.swiftaudioCharUuidsstill lists three. SincereconnectAttemptonly resets on those three, Bee/Fieldy/Plaud devices never clear the counter and pin at the 60s backoff cap. The whole suite stayed green through that drift, which is the point.capture_keepalive_policy.darthas the same shape at smaller scale:shouldStartForegroundTaskFromLocationPermission() => falsehas no production caller and its only test assertsfalseisfalse.It repurposed a service across a category boundary silently. The Android service being started and stopped from BLE audio frames is
com.pravera.flutter_foreground_task.service.ForegroundService, declaredforegroundServiceType="location"— the 5-minuteGeolocatorpoll feeding_onReceiveTaskDatainapp/lib/pages/home/page.dart. After fix(ios): stop background audio keep-alive and back off BLE timeouts #11547, background location collection is gated on live capture with frames flowing. That is a user-visible data-collection change that appears nowhere in the PR description.The reported symptom is also still unexplained by the merged change. The only iOS
setActive(true)sites areconfigureForBluetoothinAppDelegate.swift(called fromvoice_recorder_provider.dart:141, with no matching deactivate), phone-mic, CallKit, and Ray-Ban. The newdeactivateForBluetoothis wired only to the capture-controller release path, which the voice recorder never enters — so a session left active there is as stuck after #11547 as before it.What is worth re-landing separately
The incidental cleanups in that PR are real, live in Swift plus one transport function, and are independently verifiable — they do not need the Dart policy layer:
readRSSItimer (it read a cached controller value and never prevented a supervision timeout; the Android keep-alive inOmiBleManager.ktis a different mechanism and is untouched here)everConnected.insertfor state-restored peripheralsnative_ble_transport.dartAny re-land should include Bee/Fieldy/Plaud in the Swift
audioCharUuidsset and drop the Dart mirror.Product invariants affected
none — no locked invariant path glob in
docs/product/invariants/matches the reverted files.How it was verified
Source-level verification of the claims above, against the merged tree at
b5b77f5fa1:OmiBleManager.swiftaudioCharUuidsvsisBleAudioCharacteristicUuidincapture_keepalive_policy.dart: 3 UUIDs vs 6, confirming the drift in ground 3.This is a mechanical
git revert -m 1 b5b77f5fa1; no commit merged after #11547 touchesapp/, so it applies without conflict and restores the exact tree that shipped before it. Not exercised on a physical device — the revert restores previously shipped behavior rather than introducing new behavior. CI (Dart Analyze & Tests,Android Compile Smoke,Formatting) is the gate for the restored state.Tests
No new tests. The revert removes the four test files added by #11547 (
ble_reconnect_policy_test.dart,capture_keepalive_policy_test.dart,capture_foreground_keepalive_sync_test.dart,native_ble_transport_resync_test.dart) along with the code they cover. Two of them asserted pure functions with no production callers; a regression test for #11307 belongs with a fix that actually addresses it, which #11547 did not claim to be.Failure class (fixes)
Failure-Class: none
Follow-ups
configureForBluetoothwith no matching deactivate invoice_recorder_provider.dart, not the foreground task.Geolocator.getCurrentPosition()poll restored by this revert is worth removing on its own merit, as a one-line change with its own evidence.