Skip to content

iOS device: perf cpu profile/frames fail, xctrace --attach <pid> broken on Xcode 27.0 #5154

Backlog

Description

@jhorvat

Summary

On a physical iPhone with Xcode 27.0, perf cpu profile stop --kind xctrace and perf frames fail with Cannot find process for provided pid: <pid>. The failure is in xcrun xctrace record … --attach <pid>. It fails for any pid, including the real app pid. xctrace record … --all-processes works on the same device in the same session.

Related but different: #2861 is about a locked device. Here the device is unlocked, and devicectl reports passcodeRequired: false throughout.

Environment

  • macOS 27.2.1
  • Xcode 27.0 (27A266a)
  • iPhone 16 Pro Max, physical, USB, unlocked, Developer Mode on (OS build 24B156)
  • agent-device 0.21.33 and 0.21.44. The relevant code is identical in both: perf-facade.js uses xctrace … --attach <pid>.
  • App: React Native dev-client build that ships an app extension (LiveActivityExtension.appex)

Reproduction

Through agent-device:

perf cpu profile start --kind xctrace --out <p>     # succeeds
perf cpu profile stop  --kind xctrace --out <p>
COMMAND_FAILED: Failed to stop Apple xctrace cpu-profile capture: Cannot find process for provided pid: 9948
# details.exitCode: 21, captureCleanedUp: true

perf frames fails the same way:

xcrun xctrace record --template "Animation Hitches" --attach 9818 --attach 9916 …

Directly with xctrace, with the device unlocked. Both the app pid and the extension pid fail:

xcrun xctrace record --template "Time Profiler" --device <udid> --attach 10870 --time-limit 3s …
Cannot find process for provided pid: 10870        # exit 21   (app process)

xcrun xctrace record --template "Time Profiler" --device <udid> --attach 10844 --time-limit 3s …
Cannot find process for provided pid: 10844        # extension process

--attach <name> doesn't help here. Two installed apps (prod and dev) and one extension share the executable name App, so it is ambiguous:

xcrun xctrace record --template "Time Profiler" --device <udid> --attach App …
Cannot find process matching name: App

--all-processes works:

xcrun xctrace record --template "Time Profiler" --device <udid> --all-processes --time-limit 3s …
# exit 0, trace written

xcrun devicectl device info processes --device <udid> lists the pids, so the processes exist and are running. For example, pid 9948 appeared in the list during an earlier failing run. Lock state: devicectl reported passcodeRequired: false throughout.

Expected

perf cpu profile stop --kind xctrace and perf frames produce a trace on a physical device that is unlocked and running the target app.

Suggested fix

The attach-by-pid path looks broken on this toolchain. Options:

  • Record with --all-processes and filter the exported time-profile rows by process/executable at report time.
  • Or expose an --all-processes fallback for when --attach fails.

Notes

  • A failed stop leaves the daemon answering later start calls with INVALID_ARGS: native perf capture already in progress. There is no status or abort subcommand to clear it. A perf cpu profile abort, or a reset of the stale capture on the next start, would help.
  • The first two Time Profiler sessions on this device worked, one of them manual. After that every --attach failed for any pid, including a freshly relaunched app and after restarting the daemon/runner and releasing claims.
  • A second, separate problem is that the perf target resolves to an app extension's pid instead of the app's. I'm filing that separately.

Activity

  1. added
    bug
    needs-info
    on Nov 28, 2026
  2. thymikee commented on Nov 28, 2026

    @thymikee
    Member

    Triage: bug; needs a toolchain control. Since direct xctrace --attach failed for the real app PID too, can you check whether the same phone and app reproduce on a later Xcode version? For the stale capture, please share a daemon debug trace from one failed stop through the immediately following start, with both commands in the same session.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds-info

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions