Skip to content

fix(ios): exclude app extensions from physical-device process targets - #5166

Merged
thymikee merged 1 commit into
callstack:mainfrom
pcbeingused33:fix/ios-perf-appex-pid
Nov 30, 2026
Merged

thymikee merged 1 commit into
callstack:mainfrom
pcbeingused33:fix/ios-perf-appex-pid

Conversation

@pcbeingused33

@pcbeingused33 pcbeingused33 commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #5155

Summary

On a physical iPhone, process resolution matched every executable under the app bundle URL, so a running PlugIns/*.appex extension became a perf target alongside the app, and xctrace could attach to its pid. Only executables that sit directly in the app bundle are matched now. Other installed copies were already excluded by their container path.

close shares this lookup, so its depth-based sort is gone. One difference: if only an extension is running, close no longer kills it and treats the app as already closed.

Before / after

perf memory sample with the app (10870) and LiveActivityExtension (10844) running:

  • Before: matchedProcesses: ["App", "LiveActivityExtension"]
  • After: matchedProcesses: ["App"]

This output follows from the resolver test; it was not captured on a device.

Validation

At 939846b: the new regression test (second installed copy plus nested extension) fails without the source change and passes with it. The perf*, devicectl and app-launch-close tests pass (54/54); oxlint and oxfmt are clean on the changed files. No physical-device run. The --attach failure is tracked in #5154 and not addressed here.

AI assistance (Claude Code) was used to prepare this change.


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

View guided diff | Re-trigger cubic

@thymikee

Copy link
Copy Markdown
Member

Thanks for the fix. At 939846b, the code needs proof on a physical device before merge.

devicectl.ts changes which process IDs close and perf act on for physical devices, and the PR states that no physical-device run was done. The code assumes that devicectl reports the main executable as <app url>/<file> with no extra path segment. Only the fixtures and the process listing quoted in #5155 show this. That listing makes a different form unlikely. If a real listing did differ, close would report success without stopping the app, and perf would fail with No running process found. Before merge, please run this on a CoreDevice-backed physical iOS device, with an app that ships an extension and with that extension running. Record devicectl device info processes. Run perf memory sample --json and show that matchedProcesses does not include the extension. Then run close <app> and show with a second listing that the app process ID is gone.

Not verified here: tests, lint and device commands were not run, and test validity was judged from the diff and the previous filter. It was also not established whether an iOS extension in a real app can share the app’s executable name.

CI is green at this commit. Two Body rules runs show as cancelled, and a third run at the same commit passed. That job reads the PR body and does not exercise the changed code.

The physical-device evidence for perf memory sample and close is what remains before merge.

@thymikee

Copy link
Copy Markdown
Member

This PR is the one chosen to fix #5155. Filtering in resolveIosDeviceAppProcesses keeps the fix in the one place that close and every perf command already share, and it removes the depth sort instead of adding code. #5170 is being closed in favor of it.

One thing remains before merge: the physical-device run from the earlier review. Please run it at the head commit on a CoreDevice-backed physical iPhone or iPad, with an app that ships an extension and with that extension running:

  1. xcrun devicectl device info processes --device <udid>: show the app process and the extension process, with their executable paths.
  2. agent-device perf memory sample --json for that app: matchedProcesses lists the app's process ID only, not the extension's.
  3. agent-device close <app>, then the same devicectl listing again: the app process ID is gone.

Please paste the commands, the device model and iOS version, the head SHA and the outputs into the PR description. CI runs are now approved for this PR.

@pcbeingused33

Copy link
Copy Markdown
Contributor Author

Thanks for choosing this one and for spelling out the check. I don't have a CoreDevice-backed iPhone or iPad, so I can't produce the devicectl listing, the perf memory sample --json output or the close before/after that you asked for. I'd rather say so than post something that isn't a real device run.

If someone on your side with a device can run those three steps at the head commit, I'll handle anything they turn up. If the evidence can't be collected, feel free to close this.

@thymikee

Copy link
Copy Markdown
Member

Live verification on a maintainer device:

Setup

  • Device: iPhone 17 Pro (iPhone18,1), iOS 27.0.1 (24A446), physical, connected over USB.
  • Base: fc50f31d38704eee67c4b92d9f5ce861534a24c4 (merge base with main).
  • Head: 939846b9acf8bd4625909bc9be1a88e64c7c3d84.
  • Each commit was built with pnpm build and driven with node bin/agent-device.mjs, with a fresh --state-dir per run.
  • App: Weather (com.apple.weather). Its WeatherWidget widget extension was running before the app launched, so both executables sat under the same Weather.app bundle URL.

Commands (same at base and head)

agent-device open com.apple.weather --platform ios --udid <udid> --session <name> --json
agent-device perf memory sample --session <name> --json
agent-device close com.apple.weather --session <name> --json

The running processes were listed with devicectl device info processes before and after each step.

Base (fc50f31d38)

processes:  WeatherWidget.appex/WeatherWidget (37263), Weather.app/Weather (38007)
perf memory sample -> "matchedProcesses": ["WeatherWidget", "Weather"]
close -> "Closed"; afterwards only WeatherWidget (37263) is running

The first sample at base timed out in xctrace record after 60 s. The retry succeeded and is shown above.

Head (939846b9ac)

processes:  WeatherWidget.appex/WeatherWidget (37263), Weather.app/Weather (37992)
perf memory sample -> "matchedProcesses": ["Weather"], "method": "xctrace-activity-monitor"
close -> "Closed"; afterwards only WeatherWidget (37263) is running

Head, close with only the extension running

before: WeatherWidget (37263)
agent-device close com.apple.weather --platform ios --udid <udid> --json -> "Closed"
after:  WeatherWidget (37263)

This matches the behavior change in the PR body: when only the extension runs, close treats the app as already closed and leaves the extension alone.

Result

  • Base reproduces the bug: memory sampling matched the widget extension as well as the app.
  • Head matches only the app's own process.
  • close terminated the app process at base and at head. The extension survived both.

Pass.

@thymikee

Copy link
Copy Markdown
Member

The live verification at 939846b covers what the review asked for. On a physical CoreDevice-backed iPhone 17 Pro with the Weather app and its WeatherWidget extension both running, perf memory sample matched ["WeatherWidget", "Weather"] at base and only ["Weather"] at this head, so the main-executable path assumption holds on a real device listing. close stopped the app and left the extension alone. With only the extension running, close was a no-op, as the PR body describes. The required evidence is satisfied.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 30, 2026
@thymikee
thymikee merged commit 34810b9 into callstack:main Nov 30, 2026
16 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iOS: perf target resolves to an app extension (.appex) pid instead of the app process

2 participants