fix(android): wait for killed processes to exit before the close fence

Merged
OK
1h ago
+341-54

Summary

Android close and open --relaunch failed with android-app-close-timeout (phase process) on loaded CI emulators while the force-stopped app was still exiting. Logcat from 15 CI runs of the e2e mobile benchmark shows every Killing <pid> followed by Zygote: Process <pid> exited due to signal 9 with no restart in between after up to ~700 ms (7 ms on an idle Mac). The 2 s fence counted that exit time, so a busier runner failed it (2 of ~20 runs today).

  • close reads the package's pids before am force-stop, then waits up to 10 s for those pids to exit (new phase exit; the bound only catches a wedged device). The 2 s process fence then still refuses a new process.
  • A pidof that errors, prints no pid list, or times out (bounded by the fence) fails with android-process-probe-unavailable, as killApp does.
  • 7 files. Help text, docs and changeset updated.

Known gap: a process started between the pidof read and force-stop is not in the killed set, so a slow exit of that one still hits the 2 s fence.

Validation

  • pnpm check:affected --run --head 42e84d915: all runnable checks passed.
  • New test "waits past the process fence for a killed process that exits slowly" fails on 3537dc549 with process remained running after close and passes on 42e84d915.
  • Live at 42e84d915, Pixel Tablet API 37 emulator: open --relaunch 3x gave a fresh pid each time, close left no process. At fc6d6373c, Pixel 9 API 37: e2e mobile benchmark on this build: Android deterministic flows-lists + login-form 10/10, agentic Login Form / Infinite Scroll / Modal Flow 2/2.