Skip to content

Trace Capture

Capture Perfetto traces from Android devices via adb.

Prerequisites

  • adb must be in your PATH
  • Device connected via USB or wireless debugging
  • Only one device connected (or use ANDROID_SERIAL env var)

Commands

trace start

Start a trace capture session.

# Default: 10 second capture
perfetto-cli trace start

# Custom duration
perfetto-cli trace start --duration 30s

# Custom buffer size
perfetto-cli trace start --buffer-size 64mb

Options:

Option Description Default
--duration <time> Capture duration (e.g., 10s, 1m) 10s
--buffer-size <size> Ring buffer size (e.g., 32mb, 64mb) 32mb

trace stop

Stop an active capture and pull the trace file.

perfetto-cli trace stop

trace run

One-shot capture: start → wait → stop → pull.

perfetto-cli trace run --duration 15s -o ./traces

Options:

Option Description Default
--duration <time> Capture duration 10s
-o, --output <dir> Output directory for trace file Current directory

Workflow

# 1. Start your app and reproduce the issue
# 2. Capture a trace
perfetto-cli trace run --duration 15s -o ./traces

# 3. Analyze the trace
perfetto-cli -t ./traces/*.perfetto-trace -p com.example.app frame jank

Tips

  • Use longer durations for intermittent issues
  • Increase buffer size for high-frequency traces to avoid data loss
  • The run command is best for scripted/CI workflows