Skip to content
Development
Skill

/hz-perfetto-debug

Analyzes Meta Quest and Horizon OS VR performance using Perfetto traces — frame timing, CPU/GPU bottlenecks, render pass analysis. Use when profiling frame drops, jank, or thermal issues on Quest devices.

From plugin
meta-vr
17629 skills1 hook1 MCP
Install
$ npx -y skills add meta-quest/agentic-tools --skill hz-perfetto-debug --agent claude-code

How it fires

How this skill gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.
  • Slash command/hz-perfetto-debug

Context preview

The summary Claude sees to decide when to auto-load this skill.

Analyzes Meta Quest and Horizon OS VR performance using Perfetto traces — frame timing, CPU/GPU bottlenecks, render pass analysis. Use when profiling frame drops, jank, or thermal issues on Quest devices.

SKILL.md

hz-perfetto-debug.SKILL.md
name: hz-perfetto-debug
license: Apache-2.0
description: Analyzes Meta Quest and Horizon OS VR performance using Perfetto traces — frame timing, CPU/GPU bottlenecks, render pass analysis. Use when profiling frame drops, jank, or thermal issues on Quest devices.
allowed-tools: Bash(metavr:*) Bash(hzdb:*) Bash(npx:*)

Perfetto Debug Skill

When to Use

Use this skill when investigating VR performance issues on Meta Quest devices:

  • Frame drops, jank, or stuttering
  • CPU or GPU bottlenecks
  • Render pass overhead and GPU utilization
  • Thermal throttling and clock frequency changes
  • Frame timing variance and missed vsync deadlines
  • Thread contention and synchronization issues
  • High draw call counts or overdraw

VR Frame Time Targets

These are the hard deadlines for each refresh rate. If a frame exceeds its target, the compositor must reproject or the user sees a stale frame.

| Refresh Rate | Frame Time Budget | Notes | |-------------|------------------|-------| | 120 Hz | 8.3 ms | Supported on Quest 2, Quest 3, Quest 3S | | 90 Hz | 11.1 ms | Supported on Quest 2, Quest Pro, Quest 3, Quest 3S | | 72 Hz | 13.9 ms | Default on all Quest devices | | 60 Hz | 16.7 ms | Media apps only (Quest 2); interactive apps must use 72 Hz+ |

Missing a frame deadline by even 1 ms causes a stale frame (reprojection). Stale frames above 10% of total frames indicate a serious performance problem.

metavr Setup

Perfetto tracing is powered by the metavr CLI. Invoke via `npx` — no install required:

npx -y metavr --version

Examples below use the bare `metavr` command for brevity; if it is not installed globally, replace `metavr` with `npx -y metavr`. Connect your Quest via USB with developer mode enabled before capturing traces.

Quick Start Workflow

1. Capture a Trace

# Capture a 5-second trace from the currently running VR app
metavr perf capture

# Specify duration and target app
metavr perf capture --duration 10000 --app com.example.myapp

# Enable GPU render stage tracing for detailed pass analysis
metavr perf capture --gpu-render-stage

# Enable XR runtime metrics
metavr perf capture --xr-runtime

# Custom output name
metavr perf capture -o my-session-name

The capture auto-detects the foreground VR app if `--app` is not specified. CPU scheduling and GPU metrics tracing are enabled by default. The trace is pulled to your local machine automatically.

2. List Available Traces

metavr perf traces

Returns `.pftrace` files sorted by modification time (newest first). Searches standard directories including `~/Documents`, `~/Downloads`, and the current working directory.

3. Load a Trace

metavr perf load <trace-file>

Loads and processes the trace for analysis. Accepts a hex session ID, filename (with or without `.pftrace` extension), or a full/relative path.

4. Get Performance Overview

metavr perf context

Returns a structured performance analysis including:

  • CPU and GPU frame timing statistics
  • Thread breakdown with utilization percentages
  • GPU counter summaries (if available)
  • Detected bottlenecks and recommendations

5. Run SQL Queries

metavr perf query <session-id> "SELECT ts, dur, name FROM slice WHERE name LIKE '%PlayerLoop%' LIMIT 20"

Executes arbitrary SQL against the loaded Perfetto trace database. All Perfetto tables are available: `slice`, `thread_track`, `thread`, `process`, `counter`, `counter_track`, `args`, `sched_slice`, and more.

6. Analyze Thread States

metavr perf thread-state <session-id> <utid>

# With time range
metavr perf thread-state <session-id> <utid> --start-ts 1000000 --end-ts 5000000000

Returns a thread state breakdown showing how much time the thread spent running, sleeping, blocked, or waiting for CPU. Useful for identifying whether a thread is CPU-bound, I/O-bound, or starved.

7. Get GPU Metrics

metavr perf gpu-counters <session-id> --start-ts 100,200,300 --end-ts 150,250,350

Returns GPU metric counters (mean, standard deviation, quantiles) for GPU frame ranges. Requires at least 20 frames for statistical accuracy. Metrics include texture fetch rates, shader ALU capacity, vertex processing, and fragment shading statistics.

Detailed Analysis Workflow

Follow these steps in order for a thorough performance investigation.

Step 1: Validate Trace Quality

Before analyzing, confirm the trace is usable:

  • **Duration**: At least 2 seconds of data (ideally 3-5 seconds)
  • **Slice count**: Should have thousands of slices for a meaningful trace
  • **Process presence**: The target app process must be present
SELECT
  (MAX(ts) - MIN(ts)) / 1e9 AS duration_seconds,
  COUNT(*) AS total_slices
FROM slice

If the trace has fewer than 1000 slices or is under 1 second, it may not contain enough data for meaningful analysis. Capture a new trace with `metavr perf capture`.

Step 2: Identify Target Process

Find the application process (not system services):

SELECT upid, pid, name
FROM process
WHERE name NOT LIKE 'com.oculus%'
  AND name NOT LIKE '/system%'
  AND name NOT LIKE 'com.android%'
  AND name IS NOT NULL
ORDER BY pid

For known apps, filter directly by package name.

Step 3: Identify Game Engine

Look for engine-specific markers:

| Engine | Key Markers | |--------|------------| | Unity | `PlayerLoop`, `UnityMain`, `PhaseSync`, `PostLateUpdate.FinishRendering` | | Unreal | `UGameEngine::Tick`, `FEngineLoop::Tick`, `RHI Thread` | | Native OpenXR | `xrWaitFrame`, `xrBeginFrame`, `xrEndFrame` without engine markers |

Step 4: Find Key Threads

Identify the threads that matter for VR rendering:

SELECT t.utid, t.tid, t.name, p.name AS process_name
FROM thread t
JOIN process p USING(upid)
WHERE p.name = '<target-process>'
ORDER BY t.name

Critical threads to locate:

| Thread | Purpose | |--------|---------| | Main thread (UnityMain / GameThread) | Game logic, physics, scripts

Read more
Ships withmeta-vr

Agentic skills and tools for Meta Quest and Horizon OS development.

Get the whole plugin