Repository navigation
fix(android): prevent startup crash when recording sync cancels immediately - #20437
Merged
Merged
Conversation
Failure-Class: new
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
All reported issues were addressed across 13 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Git-on-my-level
added a commit
that referenced
this pull request
Oct 3, 2026
Collect 46 authored mobile changelog fragments for Android 1.0.554, including the recording-sync startup crash fix in #20437. Existing release lines remain verbatim and consumed fragments are removed. Validation: changelog validation passed; Android store notes derive to 452 characters within the 500-character limit. The release file retains all 43 authored user-facing lines. Failure-Class: none
mdmohsin7
added a commit
that referenced
this pull request
Oct 3, 2026
… runs out (#20488) ## Summary Android users get "Omi keeps stopping" when a long background recording sync hits Android's foreground-service time limit. - Android 15+ caps a `dataSync` foreground service at about 6 hours a day. - Android 14+ caps `shortService` at about 3 minutes. - When a cap is reached, the system calls `Service.onTimeout`. If the service is still running a few seconds later, Android kills the process with `ForegroundServiceDidNotStopInTimeException`. - `SyncTransferForegroundService` never overrode `onTimeout`. Crashlytics, last 14 days: - 31 users, all on 1.0.553+1320, Android 15–17. - Every crash happened with the app in the background. - The message is "A foreground service of type dataSync did not stop within its timeout: ComponentInfo{com.friend.ios/com.friend.ios.sync.SyncTransferForegroundService}". ## Change - Both `onTimeout` overloads now release the wake lock, drop the notification and call `stopSelf()`: - `onTimeout(startId)`, Android 14+, for `shortService`; - `onTimeout(startId, fgsType)`, Android 15+, for `dataSync`. - The service uses `shortService` as its cold-start type, so that limit needs handling too. - The Dart transfer continues without the keep-alive, as it already does when Android refuses the start. ## Not in this PR - **The larger crash in the same service:** `ForegroundServiceDidNotStartInTimeException`, about 750 users on 1.0.553. It's addressed by #20437, which is in 1.0.554+1338. - **Whether the service is needed at all:** #14296 added it for #5221 ("sync stops when the screen turns off") without a device test. The later VERIFY on #5221 traced the stall to the coordinator stopping all wakes on pause, and a connected pendant already runs `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-work` and `FC-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: - a `dataSync` timeout stops the service and releases the wake lock; - a `shortService` timeout stops the service. - Both new tests fail without the fix. - `scripts/pr-preflight --pr-body-file <this body>`: passes. - Not run on a device or emulator. Reaching the real 6-hour limit needs `adb shell cmd activity` FGS timeout overrides on an Android 15+ device. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/20488?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
Git-on-my-level
added a commit
that referenced
this pull request
Oct 3, 2026
…20485) ## What changed and why The Android startup cancellation race fixed in #20437 passed host tests and reproduced only in Android's real foreground-service command queue. Add Android 16 emulator acceptance to the existing Mobile App Checks workflow: 25 native lifecycle stress cases using production service sources and three offline cold launches of a minified AOT fixture APK that must render Get Started and retain the same healthy process. Android full-release and production Shorebird-patch tag builds now require a successful non-skipped emulator job on the exact main source SHA, alongside the existing release proofs. Manual execution of the existing workflow supplies that proof when ordinary path-based checks were skipped. Broaden Android PR selection to startup, capture, WAL and acceptance-runner inputs, and retain logs, screenshots, UI hierarchies and artifact hashes. ## Product invariants affected - INV-AUTH-1 - INV-DATA-1 - INV-BETA-1 The Codemagic edit only selects stricter Android source admission. Production authority, auth/session ownership and desktop Beta identity remain covered by their existing contracts. ## How it was verified - Android 16/API 36 local emulator: all 25 native service cases passed without process crashes, service, notification or wake-lock leaks. - Three additional offline cold launches passed on a universal APK reconstructed from released build 1338. It is debug re-signed for the local emulator, so this does not claim original-signature or Play split-install acceptance. - Offline unit fixtures exercise failed startup, ANR/process restart, missing rendered UI, account-state refusal, network restoration and exact-source admission rejection. - Actionlint, CI budget validation and repository preflight. - The packaged startup check uses local Firebase fixtures and debug signing, with network connectivity disabled before installation. This does not prove physical BLE/OEM behavior, authenticated upgrades, or the signed Play split-install artifact. Linux/KVM CI validates the x86_64 lane; local acceptance uses arm64. ## Tests Behavioral tests run the actual aggregate shell with failed/cancelled/skipped outcomes and refuse Android release admission without a successful real canonical job. A behavioral test executes the actual Shorebird publishing script and proves failed admission cannot reach publication. Collector fixtures cover push/manual acceptance, stale SHA, wrong branch/workflow/event, reruns and skipped jobs. Startup fixtures cover successful execution and failure receipts/cleanup. ## Failure class (fixes) Failure-Class: FC-foreground-start-cancelled-before-delivery ## New guards Real instance: #20437. Reuse the production-source native probe and a shared bounded ADB/offline boundary; Android's asynchronous foreground-service delivery requires emulator execution rather than a host-only assertion. The deterministic contract fixtures are registered for local and CI lanes. The Linux daily budget cap increases from 11,900 to 12,100 minutes to cover the new selected emulator lane and broader startup/WAL selection; other caps are unchanged. The Codemagic whole-document hashes are refreshed for the shared Android admission boundary on full-release and OTA-patch paths only; desktop workflow/publication contracts are unchanged.
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.
Fixes an Android 16 startup crash when a recording-sync pass finishes before its foreground service receives its first command. Cancellation now enters the service's command queue, each delivered command promotes before processing, and stops use their own start ID so newer transfers retain ownership. A retained cancellation flag also covers a rejected background STOP command: the pending START promotes and stops without acquiring a transfer wake lock.
Reproduced the production
ForegroundServiceDidNotStartInTimeExceptionusing the actual native service at main SHA147f77d86a2d: a single start immediately followed by stop killed the process. The fixed service survives that case, a 100-cycle cancellation burst, and immediate restart. The isolated regression probe also checks service, notification, and wake-lock cleanup without credentials or backend access.Why isn't this a shared primitive instead? The fix uses Android's existing ordered service-command queue and start-ID ownership primitive. The probe exercises the production shell and Robolectric tests protect command delivery and cleanup in the existing JVM CI job.
Validation: Android 16 emulator: 25 fresh-process launches across five scenarios, including 500 start/stop pairs, retained foreground service and wake lock after restart, and no service/notification/wake-lock leaks after cancellation. Android JVM: 116 tests passed, including three new Robolectric tests executing the production service.
TZ=UTC bash app/test.sh: 4,104 tests and protected contracts passed.make preflightand PR metadata preflight passed. The background case waits for Activity.onStop; every transfer start asserts OS acceptance, and every scenario requires the native log emitted only after startForeground returns successfully. Immediate cancellation still happens before service callbacks, preserving the triggering race. No physical Android device was connected.Release-gate repair: the existing Siri reconciliation cooldown test failed under CI with real 20 ms/80 ms timers. Cooldown calculations now use the existing
clockpackage (the default remains the system clock), and that test advances the clock and timers deterministically withfake_async. The native Android fix is unchanged. The 28-test Siri suite and focused analyzer pass;TZ=UTC bash app/test.shalso passed again: 4,104 tests plus protected contracts.Failure-Class: new