hz-perfetto-debug
Skill200 starsChanged 53 days agoApache-2.0View on GitHub
Analyzes Meta VR 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 Meta VR devices. Build paths: all Meta VR app stacks; use hz-quest-verify-first if the build path is unclear.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- mirzaaghazadeh/unity-meta-quest-skillsword for word, first seen Nov 15, 2026
- mirzaaghazadeh/iwsdk-webxr-skillsword for word, first seen Oct 17, 2026
Other versions2 projects use a version of this.
Word for word · 2
- mirzaaghazadeh/iwsdk-webxr-skills★ 1100% same
- mirzaaghazadeh/unity-meta-quest-skills★ 1100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository37 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- hz-android-2d-portingSkill
- hz-api-upgradeSkill
- hz-immersive-designerSkill
- hz-iwsdk-webxrSkill
- hz-metavrx-layout-sdkSkill
- hz-metavrx-ui-setSkill
- hz-new-project-creationSkill
- hz-platform-sdkSkill
- hz-psdk-integrationSkill
- hz-quest-verify-firstSkill
- hz-react-native-expoSkill
- hz-simpleperf-debugSkill
- hz-spatial-sdkSkill
- hz-store-pwaSkill
- hz-store-submitSkill
- hz-unity-code-reviewSkill
- hz-unity-device-readinessSkill
- hz-unity-face-trackingSkill
- hz-unity-fbx-importSkill
- hz-unity-meta-core-sdkSkill
- hz-unity-meta-interaction-sdkSkill
- hz-unity-meta-mixed-reality-utility-kitSkill
- hz-unity-meta-movement-sdk-retargetingSkill
- hz-unity-meta-quest-uiSkill
- hz-unity-passthrough-camera-accessSkill
- hz-unity-placementSkill
- hz-unity-platform-sdkSkill
- hz-unity-project-analyzerSkill
- hz-unity-sdk-upgradeSkill
- hz-unity-tmp-resourcesSkill
- hz-vr-debugSkill
- hz-xr-simulator-controlSkill
- hz-xr-simulator-install-and-configureSkill
- metavr-cliSkill
- portalSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 6 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Use this skill when investigating VR performance issues on Meta VR devices:
- Distinctive: line 125
Follow these steps in order for a thorough performance investigation.
- Distinctive: line 129
Before analyzing, confirm the trace is usable:
- Distinctive: line 132
Slice count: Should have thousands of slices for a meaningful trace
- Very specific: line 142
If the trace has fewer than 1000 slices or is under 1 second, it may not contain enough data for meaningful analysis.
- Distinctive: line 162
Look for engine-specific markers:
- Distinctive: line 277
Do NOT report PhaseSync or xrWaitFrame idle time as a performance problem — these are intentional frame pacing mechanisms.
- Very specific: line 280
Always use utid (not tid) when joining thread-related tables in SQL queries.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Perfetto Debug Skill
When to Use
Use this skill when investigating VR performance issues on Meta VR 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 — install the standalone binary on your PATH (see the metavr-cli skill), or invoke via npx with no install:
metavr --versionExamples below use the bare metavr command; if you use the npm distribution, prefix with npx -y. Connect your Meta VR device 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-nameThe 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 tracesReturns .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 contextReturns 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 5000000000Returns 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,350Returns 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 sliceIf 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 pidFor 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.nameCritical threads to locate:
| Thread | Purpose |
| Main thread (UnityMain / GameThread) | Game logic, physics, scripts |
| Render thread (UnityGfx / RenderThread) | Draw call submission |
| GPU completion (GPU completion / RHI Thread) | GPU fence waiting |
| Worker threads (Job.Worker / TaskGraph) | Parallel workloads |
Once you have a thread's utid, use metavr perf thread-state <session-id> <utid> to get a quick breakdown of its running/sleeping/blocked time.
Step 5: Detect Frame Boundaries
Find frame start/end markers to segment per-frame analysis:
- Unity:
PlayerLoopslices on the main thread define frame boundaries - Unreal:
FEngineLoop::Tickslices on the game thread - OpenXR:
xrWaitFrametoxrEndFramesequences
Step 6: Analyze Expensive Functions
Find what consumes the most time per frame:
SELECT name, COUNT(*) AS call_count, SUM(dur)/1e6 AS total_ms, AVG(dur)/1e6 AS avg_ms
FROM slice
WHERE track_id IN (
SELECT id FROM thread_track WHERE utid = <main_thread_utid>
)
GROUP BY name
ORDER BY total_ms DESC
LIMIT 20Step 7: Check High-Frequency Calls
Functions called excessively per frame can indicate batching issues:
SELECT name, COUNT(*) AS calls
FROM slice
WHERE track_id IN (
SELECT id FROM thread_track WHERE utid = <utid>
)
AND dur < 100000
GROUP BY name
HAVING calls > 1000
ORDER BY calls DESCStep 8: Analyze GPU Render Passes
See the GPU analysis reference for detailed render pass breakdown, surface analysis, and GPU counter interpretation.
Key Perfetto Concepts
| Concept | Description |
| Slice | A timed span of execution (function call, frame, render pass). Has ts (start), dur (duration), name, and track_id. |
| Track | A timeline lane. Thread tracks hold slices for a specific thread. Counter tracks hold metric values over time. |
| Thread (utid) | Unique thread ID within the trace. Use utid (not tid) for joins — tid can be reused. |
| Process (upid) | Unique process ID within the trace. Use upid (not pid) for joins. |
| Timestamps | All timestamps are in nanoseconds. Divide by 1e6 for milliseconds, 1e9 for seconds. |
| Counter | A time-series metric (GPU utilization, clock frequency, temperature). Stored in the counter table. |
| Args | Key-value metadata attached to slices. Accessed via the args table joined on arg_set_id. |
Performance Targets
| Metric | Target | Warning | Critical |
| Frame time (90 Hz) | < 11.1 ms | > 11.1 ms | > 16.7 ms |
| Stale frame rate | < 5% | > 10% | > 25% |
| Main thread utilization | < 80% of budget | > 80% | > 95% |
| GPU utilization | < 85% of budget | > 85% | > 95% |
| Frame variance (std dev) | < 1 ms | > 2 ms | > 4 ms |
| Draw calls per frame | < 100 | > 200 | > 500 |
Engine-Specific Notes
Unity
- PhaseSync: VR vsync alignment mechanism. Appears as idle time at the start of
PlayerLoop. This is normal and intentional — do NOT flag as wasted time. - Single-pass multiview: Both eyes rendered in one pass. If you see two render passes per frame, the app may be using multi-pass rendering (less efficient).
- Dynamic batching: Watch for high
SetPasscall counts, which indicate materials are not being batched. - IL2CPP vs Mono: IL2CPP builds have different function naming in traces. Look for mangled C++ names instead of C# method names.
Unreal Engine
- RHI Thread: Unreal uses a separate RHI (Render Hardware Interface) thread for GPU command submission. Check this thread for driver overhead.
- Forward vs Deferred: Forward rendering is preferred on Meta VR. Deferred rendering has significantly higher GPU cost.
- Blueprint Tick: Heavy Blueprint usage shows up as
UObject::ProcessEvent. High counts indicate Blueprints should be converted to C++. - Nativized Blueprints: Show up with
__StaticExecsuffix in trace names.
Common Pitfalls
- Do NOT report PhaseSync or xrWaitFrame idle time as a performance problem — these are intentional frame pacing mechanisms.
- GPU render pass names like
surface#0are not descriptive — correlate them with the resolution and MSAA level to identify what they render. - Thread names can be truncated in traces.
UnityMainmay appear asUnityMaior similar. - Always use
utid(nottid) when joining thread-related tables in SQL queries. - Timestamps are nanoseconds. A common mistake is treating them as microseconds.
- Counter values are instantaneous samples, not averages over a period.
References
For detailed guides on specific topics, see:
- Capturing Traces — How to capture Perfetto traces on Meta VR
- Analyzing Traces — Step-by-step trace analysis with SQL queries
- GPU Analysis — Render pass analysis, GPU counters, and metrics
- Frame Timing — VR frame markers, pacing, and compositor timing
- SQL Queries — Ready-to-use SQL queries for common analysis tasks
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

