Skip to content

Clean up suspended simulator apps after launch cancellation - #458

Merged
zunda-pixel merged 1 commit into
mainfrom
fix/reap-cancelled-launch
Oct 30, 2026
Merged

zunda-pixel merged 1 commit into
mainfrom
fix/reap-cancelled-launch

Conversation

@zunda-pixel

Copy link
Copy Markdown
Collaborator

Cancelling RunProject while its simulator app is suspended can drain the native producer and return cancellation while leaving the app behind. Xcode can invalidate the launch session before assigning its runnablePID, so cleanup through the recorded execution tracker has no app PID to stop.

Fixes #456

The simulator launch correction associates each launcher created inside a request with an object-scoped PID callback. That callback runs before Xcode records the PID on the session and captures the process's executable and start time for the owning request scope.

After native cancellation and producer drain, the scope terminates a captured app only when it still belongs to the selected simulator, has the same executable and start time, remains suspended and untraced, and has no debugger selected. Cleanup waits for process exit before releasing the workspace permit. It runs in an owned task so client cancellation cannot interrupt that wait. Successful requests discard the captures and callback hooks when the app passes to the workspace.

Validation:

  • ./scripts/check.sh
  • ./scripts/verify-proxy-target-boundaries.sh
  • Regression coverage uses a real suspended child process to verify cancellation cleanup, successful handoff, late PID reports, resumed processes, stale process identities, debugger selection, and simulator ownership.
  • Direct STDIO verification with the repository's fixture: observe the suspended process, cancel the launch, verify that the process is gone when the -32800 response returns, then build and launch again in the same workspace with and without LLDB. Stop and workspace close also complete.
  • Live environment: macOS 27.0.1, Xcode 27.2 (27B48), and a dedicated iPhone Air simulator running iOS 27.2.

This completes the suspended-app cleanup left after the cancellation-response fix; the original reproduction and investigation are recorded in the issue.

Capture the app process at the request-owned simulator launcher callback, before Xcode can invalidate its launch session without recording runnablePID. Drain native work and terminate only the same stopped, untraced simulator process before releasing the workspace. Discard captures when a successful launch passes to the workspace.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T10:27:16.055170Z 782d4a9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@zunda-pixel
zunda-pixel merged commit add0d68 into main Oct 30, 2026
7 checks passed
@zunda-pixel
zunda-pixel deleted the fix/reap-cancelled-launch branch October 30, 2026 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cancelled headless RunProject can leave a suspended simulator app behind

1 participant