Repository navigation
fix(android): stop the sync keep-alive when its foreground time limit runs out - #20488
Merged
Merged
Conversation
… runs out Android 15+ caps a dataSync foreground service at about 6 hours a day and Android 14+ caps shortService at about 3 minutes. When a cap is reached the system calls Service.onTimeout and, if the service is still running a few seconds later, crashes the process with ForegroundServiceDidNotStopInTimeException. SyncTransferForegroundService never overrode onTimeout, so a long background sync took the app down (Crashlytics: 31 users on 1.0.553+1320, Android 15-17, all background, "A foreground service of type dataSync did not stop within its timeout"). Both onTimeout overloads now release the wake lock, drop the notification and stopSelf(). The Dart transfer continues without the keep-alive, as it already does when a start is refused. Verification: - ./gradlew :app:testDevDebugUnitTest --tests com.friend.ios.sync.SyncTransferForegroundServiceTest (JDK 21): 5 pass. - The two new tests fail without the fix. Failure-Class: none
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
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.
Summary
Android users get "Omi keeps stopping" when a long background recording sync hits Android's foreground-service time limit.
dataSyncforeground service at about 6 hours a day.shortServiceat about 3 minutes.Service.onTimeout. If the service is still running a few seconds later, Android kills the process withForegroundServiceDidNotStopInTimeException.SyncTransferForegroundServicenever overrodeonTimeout.Crashlytics, last 14 days:
Change
onTimeoutoverloads now release the wake lock, drop the notification and callstopSelf():onTimeout(startId), Android 14+, forshortService;onTimeout(startId, fgsType), Android 15+, fordataSync.shortServiceas its cold-start type, so that limit needs handling too.Not in this PR
ForegroundServiceDidNotStartInTimeException, about 750 users on 1.0.553. It's addressed by fix(android): prevent startup crash when recording sync cancels immediately #20437, which is in 1.0.554+1338.OmiBleForegroundService(connectedDevice). Removing the service needs a screen-off sync test on a real Android device, so that is a follow-up.Product invariants affected
none
Failure class
Failure-Class: none
The existing foreground-service classes (
FC-foreground-service-promotion-after-startup-workandFC-foreground-start-cancelled-before-delivery) cover promotion at start. This bug is a missing timeout stop.Verification
./gradlew :app:testDevDebugUnitTest --tests com.friend.ios.sync.SyncTransferForegroundServiceTest(JDK 21): 5 tests pass, including the two new ones:dataSynctimeout stops the service and releases the wake lock;shortServicetimeout stops the service.scripts/pr-preflight --pr-body-file <this body>: passes.adb shell cmd activityFGS timeout overrides on an Android 15+ device.🤖 Generated with Claude Code