fix(android): record simpleperf by package on user builds

Merged
PC
1d ago
+59-33

Summary

Fixes #5156

On Android user builds, perf cpu profile start --kind simpleperf ran simpleperf record -p <pid>, which shell is not permitted to do for an app process. It now reads ro.build.type: user builds record with --app <package>; other builds keep -p <pid>. The profiling docs note that the app must be debuggable or profileable from shell.

Before / after

perf cpu profile start --kind simpleperf on a user build, device command:

  • Before: simpleperf record -e cpu-clock:u -p <pid> ... (the issue reports Permission denied)
  • After: simpleperf record -e cpu-clock:u --app <package> ...

Validation

Tested at b78a2c4b1:

  • vitest run on platform-android perf.test.ts and perf/runtime.test.ts: 22 passed. The new user build case fails without the fix.
  • oxlint, oxfmt --check and tsc --noEmit: clean.

Unresolved risk: no live-device run. Start, stop, pull and report with a debuggable app on a user build are not verified. In AOSP simpleperf, --app mode opens the output file from the shell process and forwards SIGINT/SIGTERM to the in-app recorder, so the stop and pull steps are left unchanged.

AI assistance was used to prepare this change.


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