Accessing Frame rate on VIsionOS

Hi there. We are working with apple to port our game to visionOS. One of their requirement’s is that the game is running at 90fps.

We have hooked up a simple frame rate counter that is displaying the fps in unity during runtime, and its running around 180 fps in editor, 90 in the simulator and exactly 45 on device.

We have tried several different things to unlock it:

  1. Setting the target framerate via code.
  2. Turning all VSync settings off
  3. Running the XCode project as a release build

Our set up:
We are developing using 0.5.0 for polyspaital and visionOS with the AppMode: Mixed Reality in unity 2022.3.12f1 using URP.

Are we grabbing the right frame rate by calculating it via a c# script running on the unity engine or should we be getting it a different way?

Or, maybe there is a specific setting we overlooked related to Polyspatial and frame rate locking?

Any help is greatly appreciated! Thanks!

There are two independent frame rates, only one of which (afaik) can be measured from Unity. You can inspect them both though using Xcode Instruments profiler. When you open Instruments, start a new profile and choose “RealityKit Trace” profiling template.

The top section shows “RealityKit Frames” which is the framerate of the device’s fully composed render, including other applications and system UI.

Although each frame here is around 12.6ms, they are pipelined, and if you measure the frame-to-frame time you can see it’s hitting 11ms as required for 90 FPS.

image

The green color-coding also indicates that the frame was completed within the required time – sometimes the system will slow down the framerate deliberately, but this is not due to a performance issue:

All of the above CPU and GPU measurements are from the “backboardd” system process which is actually compositing your game with the rest of the system. Your code is not actually running here, but if you have complex geometry or shaders then you could possibly see a slowdown here (seems unlikely if you’re getting 180 FPS in editor).

Your actual Unity code is running in a separate process and is shown in the Runloops section:

In the above image each runloop iteration is easily completing within the 11ms, so it’s keeping up with the system framerate. However, even if it takes longer (for example, your CPU cost is too high in your Unity code), that doesn’t affect the system framerate:

image

The long Main Thread iteration here is 18ms, but the system doesn’t wait for it to complete before it renders its own frame, which is how it generally keep up a 90 FPS for the sake of good head-tracking even if your Unity app is running at a lower framerate, or having hitches like this one.

Enable high-frequency sampling in the Time Profiler options to identify the causes of the high CPU cost (or examine the GPU tracks I haven’t mentioned if you’re GPU-bound).

7 Likes

Alex, wow. Thank you for providing such a descriptive explanation!

I had a feeling there were two, and this helps solidify my assumptions and brings a lot of clarity.

Huge thanks!!

This was really useful @Alex_StudioDrydock!

I’ve also just encountered a FPS counter giving abnormally high reading in sim, when all the Unity content is clearly rendering much more slowly.

Is there any way to get a FPS counter visible in the sim/device that will display what FPS the Unity content is rendering at?

While I can use Instruments as described, having an FPS counter right there would be super useful.