Agent Skills › software-mansion/argent › argent-native-profiler

argent-native-profiler

GitHub

跨平台原生性能剖析工具,支持iOS(xctrace)和Android(Perfetto),用于定位CPU热点、UI卡顿及内存泄漏。提供启动、停止、分析及栈查询功能,辅助性能诊断与优化验证。

packages/skills/skills/argent-native-profiler/SKILL.md software-mansion/argent

触发场景

诊断应用性能问题 分析CPU热点或内存泄漏 排查UI卡顿原因

安装

npx skills add software-mansion/argent --skill argent-native-profiler -g -y
更多选项

非标准路径

npx skills add https://github.com/software-mansion/argent/tree/main/packages/skills/skills/argent-native-profiler -g -y

不安装直接使用

npx skills use software-mansion/argent@argent-native-profiler

指定 Agent (Claude Code)

npx skills add software-mansion/argent --skill argent-native-profiler -a claude-code -g -y

安装 repo 全部 skill

npx skills add software-mansion/argent --all -g -y

预览 repo 内 skill

npx skills add software-mansion/argent --list

SKILL.md

Frontmatter
{
    "name": "argent-native-profiler",
    "description": "Native profiling for CPU hotspots, UI hangs, memory issues. iOS via xctrace; Android via Perfetto. Use when diagnosing native-level performance issues."
}

1. Tools and platforms

  • native-profiler-start → native-profiler-stop → native-profiler-analyze: record, export, and report.
  • profiler-stack-query: drill into the analyzed data (hang stacks, function callers, thread breakdown, leaks).
  • profiler-load: reload an earlier session from disk.

iOS (Instruments via xctrace): simulator only; a physical iPhone is not supported. Needs full Xcode (xcrun xctrace version). Reports CPU hotspots, UI hangs and memory leaks.

Android (Perfetto): emulator or physical device. Reports CPU hotspots and UI hangs (with jank reasons and the main thread's blocking function), plus an RSS-growth signal for memory pressure: treat it as a hint to confirm, not a confirmed leak. The app must be debuggable or declare <profileable android:shell="true"/> in its manifest, or no perf_sample callstacks are captured.

argent-react-native-profiler starts native profiling alongside React profiling by default; this skill's workflow and investigation patterns apply in both cases.

2. Workflow

Complete all steps in order; do not break mid-flow.

  1. Start. Make sure the app is running (launch-app if not); native-profiler-start detects it. Pass app_process only if it reports several running user apps (e.g. dev and prod flavors) or picks the wrong one. Then let the user interact, or drive the app yourself (argent-device-interact skill). While a profiler records, interaction tools return no automatic screenshot or element tree, so the capture does not load the app. Call screenshot or describe when you need to see the screen; interaction tools still wait for the screen to settle before they return, so add no wait of your own; on an Android emulator each screenshot during a profile takes one frame in about 100 ms and does not wake the screen capture; on a physical Android device it takes about 150–200 ms and briefly wakes the device screen capture, so take them sparingly there.
  2. Stop. native-profiler-stop. On iOS, check exportDiagnostics for export warnings.
  3. Analyze. native-profiler-analyze. Findings are 🔴 RED (act on it) or 🟡 YELLOW (worth investigating, may be acceptable).
  4. Present and ask. Summarize the key findings, then ask the user whether to investigate further, implement fixes, or stop. Do not move on silently.
  5. Drill down with profiler-stack-query (patterns below).
  6. Fix and re-profile the same scenario; compare with the earlier session via profiler-load (list, then load_native with its session_id and the device_id). Report honestly whether the target metric improved, regressed, or stayed flat; if there is no net benefit or something else regressed, say so and reconsider. For reproducible before/after runs, record the interaction as an e2e test (argent-create-e2e skill) before the first run and replay it with e2e-execute.

Investigation patterns

  • Hang → mode hang_stacks for the native call chain → function_callers for the suspected function → read the native source.
  • CPU hotspot → thread_breakdown for the per-thread split → function_callers for the dominant function.
  • Memory leak (iOS) → leak_stacks, filtered by object_type, for the responsible frames and libraries. To attribute leaks shown as <Call stack limit reached>, re-run native-profiler-start with malloc_stack_logging: true; it restarts the app and adds overhead, so not for CPU or hang passes.

3. Caveats

  • Simulator and emulator timings reflect the host machine, not device hardware. Compare runs against each other rather than trusting absolute numbers; a physical Android device gives real-hardware numbers.
  • Profiler overhead: if JSLexer, JSONEmitter or Hermes internals dominate the JS thread, that is instrumentation cost, not app work. Discount those entries.
  • Run-to-run variance: treat only consistent, directional changes (across 2+ runs, or a >15% delta) as signal.
  • Live data: if the app fetches live API data, different responses change the workload independently of code changes. Note when data-dependent screens vary.

版本历史

  • b965c94 当前 2026-11-07 15:13
  • 617db8d 2026-11-02 18:47

    新增按需捕获功能,在Android性能剖析期间自动跳过屏幕录制、截图及描述操作,避免干扰数据;修正文档说明Android需Debug或Profileable构建版本。

  • f0e04a6 2026-10-19 02:09

    将工具描述中的破折号替换为冒号等标点,统一文本风格,未改变功能逻辑。

  • b6576ef 2026-09-09 02:11

    修复iOS物理设备签名传递、Flow设备解析逻辑及手势操作描述,更新相关技能文档以明确硬件限制。

  • a0460ee 2026-07-24 11:27

    新增iOS内存泄漏可追溯功能:通过malloc_stack_logging在冷启动时捕获真实分配回溯,解决之前显示'Call stack limit reached'无法归因的问题;默认行为保持不变,需显式开启。

  • bc04c3b 2026-07-06 19:59

同 Skill 集合

packages/skills/skills/argent-android-emulator-setup/SKILL.md
packages/skills/skills/argent-create-e2e/SKILL.md
packages/skills/skills/argent-create-flow/SKILL.md
packages/skills/skills/argent-device-interact/SKILL.md
packages/skills/skills/argent-ios-device-interact/SKILL.md
packages/skills/skills/argent-ios-device-setup/SKILL.md
packages/skills/skills/argent-ios-simulator-setup/SKILL.md
packages/skills/skills/argent-lens/SKILL.md
packages/skills/skills/argent-metro-debugger/SKILL.md
packages/skills/skills/argent-react-native-app-workflow/SKILL.md
packages/skills/skills/argent-react-native-optimization/SKILL.md
packages/skills/skills/argent-react-native-profiler/SKILL.md
packages/skills/skills/argent-screen-recording/SKILL.md
packages/skills/skills/argent-screenshot-diff/SKILL.md
packages/skills/skills/argent-test-ui-flow/SKILL.md
packages/skills/skills/argent-tv-interact/SKILL.md
packages/skills/skills/argent-qa-e2e/SKILL.md
packages/skills/skills/argent-qa-flows/SKILL.md
packages/skills/skills/argent-settings-permissions/SKILL.md

元信息

文件数
0
版本
b965c94
Hash
6c90dd13
收录时间
2026-07-06 19:59

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.156.0. UTC+08:00, 2026-11-10 08:01
浙ICP备14020137号-1