Repository navigation
fix(android): end close once the pre-close processes are gone - #4902
Conversation
The Android close fence refused any new process that ran for 2s after the stop, by pid presence alone. Android restarts Settings at once for a background client, so a plain close failed with android-app-close-timeout phase process. Close now succeeds once the pids that ran before the stop have exited and the package is not foreground. Drop the process phase and the relaunch special case that accepted it. Fixes #4901 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Size Report
Startup median (7 runs, lower is better):
|
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 1 new finding on adbd2a5. The verdict and the full list are in the summary comment.
Run the exit fence first and the foreground fence last, so a relaunch that is on screen after the killed processes exit still fails close, while a new background process does not. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 1 new finding on 5b74501. The verdict and the full list are in the summary comment.
A surviving visible app fails close in 2s with phase foreground again, and a relaunch that is on screen after the killed processes exit still fails. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Apex Sentinel · ✅ Approve · review of
|
| Command | What it does |
|---|---|
@apex-sentinel-staging note <context> |
Adds context; Sentinel re-checks the cited code |
@apex-sentinel-staging pivot <why> |
Says the finding is wrong; Sentinel re-checks the cited code |
@apex-sentinel-staging like |
Marks the finding as useful |
@apex-sentinel-staging dislike <why> |
Marks it as not useful, so it is not raised again |
On this conversation, comment @apex-sentinel-staging review to run a full review once again.
|
The PR is ready at b0969c7, and the code looks correct. The two earlier inline threads on the restarted-package and visible-app cases are fixed at this head (#4902 (comment) and #4902 (comment)), so the author can resolve them. CI is green: the only check not passing is Body rules run 44917865607, which was cancelled one second after start and superseded by run 44917865965 of the same workflow, which succeeded. There are no conflicts, and nothing else stands in the way of merge. Not blocking, and fine to take or leave: the comment in killAndroidPackage at https://github.com/callstack/agent-device/blob/b0969c7/packages/platform-android/src/app-lifecycle.ts#L677 says both fences run as on close, but close no longer runs the process-gone fence; the help text at https://github.com/callstack/agent-device/blob/b0969c7/packages/command-surface/src/management/app.ts#L98 and commands.md:265 reads as if any new process is ignored, though a new foreground process fails with phase foreground, so "new background process" would be accurate; and the Validation section could name the tested SHA. Not verified here: the unit tests and a device run were not executed, and the live table could not be reproduced, so the passing CI Android smoke lane is the head-level evidence, which is weak while that lane fails intermittently (#4901). |
* fix(android): end close once the pre-close processes are gone The Android close fence refused any new process that ran for 2s after the stop, by pid presence alone. Android restarts Settings at once for a background client, so a plain close failed with android-app-close-timeout phase process. Close now succeeds once the pids that ran before the stop have exited and the package is not foreground. Drop the process phase and the relaunch special case that accepted it. Fixes #4901 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(android): check the foreground last when close confirms the stop Run the exit fence first and the foreground fence last, so a relaunch that is on screen after the killed processes exit still fails close, while a new background process does not. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(android): keep the foreground fence first and re-read it last A surviving visible app fails close in 2s with phase foreground again, and a relaunch that is on screen after the killed processes exit still fails. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com> (cherry picked from commit ffef4b7)
Summary
Since #4881 a plain
closefails the Android smoke replay withprocess remained running after close. The fence refused any new Settings process that ran 2 s after the stop, by pid presence. Android restarts Settings for a background client, so that process is not the app the close ended.Close now succeeds once the pids that ran before the stop have exited and the package is not foreground (re-read after the exit fence, so a relaunch that is on screen still fails). The
processphase and the relaunch special case that accepted it are removed. A survivor of the stop still fails withexit. Help and docs match.5 files. Fixes #4901.
Before / after
AVD API 37, worktree CLI, isolated state dir. A watcher starts Settings again (provider query) once the pre-close process is gone, as Android does for a client.
open settingsthenclose, three runs each:721adbccloseprocess remained running after close, 2.6–2.9 sClosed, exit 0, 0.8 s01-settings.adreplay: 9/9 pass on head.Validation
New unit test (a new pid persists while the killed one exits) fails on base and passes on head.
packages/platform-android,srcand repo-guard suites pass locally. CI owns full validation. CI runs API 36 and logs no pids, so its failure is inferred from the same fence path.🤖 Generated with Claude Code