This guide reviews baseline targets, recommendations, tools, resources, and common workflows for performance analysis and bug squashing for Unity VR applications.
VR application profiling provides insight into how an application is performing, then isolating and eliminating problems and bottlenecks. Focus on bottlenecks first. Change one thing at a time, for example, resolution, hardware, quality, configuration.
We recommend creating a non-VR version of your camera rig so you can swap between VR and non-VR perspectives. This allows you to spot check your scenes, and it may be useful if you want to do profiling with third-party tools.
It can be useful to disable Multithreaded Rendering in Player Settings during debugging. This will slow down the renderer, but also give you a clearer view to trace your frame time. Turn it back on when you’re done.
Before debugging performance problems, establish clear targets to use as a baseline for calibrating your performance. These targets can give you a sense of where to aim, and what to look at if you’re not making frame rate or are having performance problems.
The following data points serve as a general guideline to establish your customized baseline, given as approximate ranges unless otherwise noted.
For more information, go to Draw Call Cost Analysis page.
This section details tools provided by Unity to help you diagnose app problems and bottlenecks.
Unity’s built-in profiler provides valuable information such as per-frame CPU and GPU performance metrics, which can be used to help identify bottlenecks. You should lock your CPU/GPU level before profiling to get consistent profiling results and measure improvements. For more information about Unity Profile, go to the Profiler manual
To use Unity Profiler with a Rift application, select Development Build and Autoconnect Profiler in Build Settings and build your application. When you launch your application, Profiler opens automatically.
You can also profile your app as it is running on your Oculus Quest by using either adb or WiFi.Make sure to lock your CPU/GPU level before profiling to get consistent profiling results and measure improvements. See the Android Development guide for information on setting CPU/GPU levels. For steps on using the Unity GPU Profiler, go to the GPU Profiler guide.
The Unity profiler displays performance metrics for your app. If your app isn’t performing as expected, you may need to gather information on what the entire system is doing.
The total draw call results from the GPU profiler may not be absolutely accurate due to profiling overhead. We recommend using this value as a comparison when profiling builds.
Unity provides an option to display real-time rendering statistics, such as FPS, Draw Calls, Tri and Vert Counts, VRAM usage. While in the Game View, pressing the Stats button above the Game View will display an overlay showing realtime render statistics. Viewing stats in the Editor can help analyze and improve batching for your scene by indicating how many draw calls are being issued and how many are being saved by batching (the OverDraw render mode is helpful for this as well).
Unity provides a specific render mode for viewing overdraw in a scene. From the Scene View Control Bar, select OverDraw in the drop-down Render Mode selection box.
In this mode, translucent colors will accumulate providing an overdraw “heat map” where more saturated colors represent areas with the most overdraw.
Unity Frame Debugger lets you walk through the order of draw calls for any scene. Even if you’re not actively debugging, it can be useful for understanding how Unity is putting your scene together and debugging pipeline problems.
For more information, see Frame Debugger in Unity 5.0.
Unity Built-in Profiler (not to be confused with Unity Profiler) provides frame rate statistics through logcat, including the number of draw calls, min/max frametime, number of tris and verts, et cetera.
To use this profiler, connect to your device over Wi-Fi using ADB over TCPIP as described in the Wireless usage section of Android’s adb documentation. Then run
adb logcat while the device is docked in the headset.
See Unity’s Measuring Performance with the Built-in Profiler for more information. For more on using adb and logcat, see Android Debugging in the Mobile SDK documentation.
This section describes performance analysis tools for Rift development.
The Oculus Performance Head-Up Display (HUD) is an important, easy-to-use tool for viewing timings for render, latency, and performance headroom in real-time as you run an application in the Oculus Rift. The HUD is easily accessible through the Oculus Debug Tool provided with the PC SDK. For more details, see the Performance Head-Up Display and Oculus Debug Tool sections of the Oculus Rift Developers Guide.
The compositor mirror is an experimental tool for viewing exactly what appears in the headset, with Asynchronous TimeWarp and distortion applied.
The compositor mirror is useful for development and troubleshooting without having to wear the headset. Everything that appears in the headset will appear, including Oculus Home, Guardian boundaries, in-game notifications, and transition fades. The compositor mirror is compatible with any game or experience, regardless of whether it was developed using the native PC SDK or a game engine.
For more details, see the Compositor Mirror section of the PC SDK Guide.
OVR Metrics Tool is an application that provides performance metrics for Oculus Android applications.
OVR Metrics Tool reports application frame rate, heat, GPU and CPU throttling values, and the number of tears and stale frames per second. It is available for download from our Downloads page.
OVR Metrics Tool can be run two modes. In Report Mode, it displays performance report about a VR session after it is complete. Report data may be easily exported as a CSV and PNG graphs.
In Performance HUD Mode, OVR Metrics Tool renders performance graphs as a VR overlay over any running Oculus application.
For more information, see OVR Metrics Tool in our Mobile SDK Guide.
This section describes other tools that we have found useful for debugging and performance analysis.
ETW and GPUView
Event Tracing for Windows (ETW) is a trace utility provided by Windows for performance analysis. GPUView view provides a window into both GPU and CPU performance with DirectX applications. It is precise, has low overhead, and covers the whole Windows system.
Most Unity developers will find the Unity Profiler sufficient, but in some cases ETW and GPUView may be useful for debugging problems such as system-level contention with background processes. For a detailed description of how to use ETW with our native Rift SDK, see VR Performance Optimization in our PC SDK Developer Guide. Not all of the content will be relevant to the Unity developer, but it contains a lot of applicable conceptual material that may be very useful.
Reports complete Android system utilization. Available here: http://developer.android.com/tools/help/systrace.html
Mac OpenGL Monitor
An OpenGL debugging and optimizing tool for OS X. Available here: https://developer.apple.com/library/mac/technotes/tn2178/_index.html#//apple_ref/doc/uid/DTS40007990
This section describes basic techniques for performance analysis for Android development.
Use Oculus Remote Monitor (Android) for VRAPI, render times, and latency. Systrace shows CPU queueing.
It is a common problem to see Gfx.WaitForPresent appear frequently in Oculus Remote Monitor. This reports the amount of time the render pipeline is stalled, so begin troubleshooting by understanding your scene is assembled by Unity - the Unity Frame Debugger is a good starting place. See Unity Profiling Tools for more information.