Stutter / Frame Pacing issues after upgrading to 2021.3

After the Upgrading project from Unity 2020.3.4 (URP 10.4.0) to Unity 2021.3.10 (URP 12.1.7), we are experiencing a stutter/frame pacing issue that had not been there before the upgrade. The stutter is noticeable when the player is using smooth locomotion and also visible on animated moving objects. The issue is only noticeable on Quest vr builds. With Steam VR the issue does not appear present.

We’ve been able to reduce the issue by switching to 72h. But there is still a stutter every one to two seconds. We’v e discovered that if we try to change the refresh rate with the OVRManager call the issue will get worse until the headset is put to sleep and woken back up.

OVRManager.display.displayFrequency = 80;

OVR metrics have no visible stutters and appear smooth.

When running with the profiler the issue gets worse and the spikes show as OculusRuntime.WaitToBeginFrame.

What We’ve tried and hasn’t had an impact

  • Upgrading the Oculus Integration 3.2.2 (Package Manager)

  • Upgrading the Oculus SDK to v47 (Asset Store)

  • Switched Oculus to use the OpenXR back end

  • Tested on OpenGLES and Vulken

  • Test builds with Late Latching, Phase Sync, and Optimized Frame Pacing

  • Tested on 2021.3.1. 2021.3.14, 2021.3.15, 2021.3.16

Steps to reproduce:

  • Open a new URP project in 2021.3.10

  • Make a simple animation of a moving shape

  • Download the Oculus Integration and SDK

  • Put OVR camera prefab in scene

  • Add a simple script that changes the refresh rate on launch

  • OVRManager.display.displayFrequency = 90;

  • Change Quality settings to performant

  • Make an android Quest build and test on device

4 Likes

Bug report submitted

CASE IN-30623

1 Like

Here are those stutters when looked at in the profiler

Looking at the profiler, you’re on the edge of obtaining 90fps, so once you hit 89fps the framerate will vsync back to 45.
Generally XRUpdate is GPU related.

Do you still see the spike if you set the fps to 72?

Default URP is not optimized for VR. There are optimisation to be done, disabling SSAO is the first of many

1 Like

Does a deep profile of “EarlyUpdate.XRUpdate” come up as “OculusRuntime.WaitToBeginFrame”? I find that even on simple test projects that it’s like Oculus’ runtime has Phase Sync on regardless of the Unity setting and often overshoots. Worst part is, I have no control over it and no way to turn it off.

Phase Sync

Related “By Design” Bug Report?

2 Likes

It’s not a performance issue.
If you ADB command to set refresh rate to 90, then sleep-cycle the headset, the stutters stop happening. Then ADB command to change the refresh to 72, without letting the headset go to sleep, and the stutters will come back. At a perfect interval.

It’ll happen with any refresh rate change, with every version of Unity 2021 I’ve tested. Didn’t happen in Unity 2020.

1 Like

Then make a repro project and make a bug report.
If there are no well documented bug reports there won’t be fixes

1 Like

Thanks for the responses!

The stutters get worse with the profiler attached so not 100% those spikes in the profiler are related to the original issue and not just from over head from the profiler itself.

@DevDunk Yeah still see it at 72hz, attached a image. But still this spike could just be from the profiler over head.

@ScottJustScott Yup, on deep profile they read as OculusRuntime.WaitToBeginFrame. Intersting are you also seeing this just on 2021.3?

3 Likes

Hey @kayke
I just wanted to let you know we received your bug report and we will work on looking into this issue when we are able.
We appreciate you bringing this to our attention so we can continue to improve our software.

3 Likes

@lianne13 thanks for looking into this. Reeeeaaaallly hoping to not have to move back to 2020 but I haven’t been able to find a solution to these frame pacing/stutter issues.

@kayke thanks for putting in a bug report and for sending me the repo project. I’m definitely seeing the same issue and have tried everything under the sun to fix it without luck (in the repo project and with our company’s product).

Here’s a MQDH/Perfetto report of what I’m seeing in a simple project with a couple animated lines. Before and after the frames shown here, I’m getting 80fps pretty solidly but then I get frames like these on semi-regularly that make the whole VR experience feel stuttery/bad. If OculusRuntime forcing a kind of Phase Sync is the issue, I’d love an option to turn it off and give Swappy a chance to do its thing. If it’s more of a frame pacing issue, I’m not really sure where to start as I’ve exhausted what feels like all combinations of all related settings exposed to me.

3 Likes

Just an update on our end. We may have found part of the issue.
We ran some test on deltaTime and were getting some values that were matching the pattern of stutters that were experiencing. When we changed some of our systems over to use our own custom deltaTime the consistent stutter was gone.

Running some tests it appears that after you change the hz with OVR, Time.deltaTime is off until the headset is sleep cycled.

We still see an intermittent stutter every ~5 seconds, but the consistent stutter appears to be directly linked to deltaTime.

2 Likes

Interesting, I thought they fixed deltatime issues in a recent LTS

2 Likes

Glad to here you found your main issue @kayke ! But also pretty alarming that such a low level thing as delta time could be giving erroneous results. Especially since there is plenty of Unity code that relies on it that we don’t have access to, like animations.

3 Likes

A seemingly related thread. The most recent posts point to a regression in some of the deltaTime improvements dependent on platform.

Time.deltaTime Not Constant: VSync CameraFollow and Jitter page-11

2 Likes

Hi, all. Did anyone happen to find any solution or bypass, except for moving to 2020? Is there a chance that the fix is coming anytime soon? Really struggling with the same issue

Here is a relevant datapoint:

This thread here has people losing their mind about Time.deltaTime being unstable. It was started in 2016:
https://discussions.unity.com/t/639394

A fix was introduced in 2020.

2 Likes

@immersification haven’t heard back from Unity on when/if a fix is planned.

I was able to work around the issue by implementing our own delta time. I used the system stopwatch class to track time and used

stopwatch.ElapsedMilliseconds

to extrapolate delta time.

3 Likes

@kayke thanks a lot! We’re going to try this. Almost got our brains melted with this

1 Like

Just for reference the bug has been confirmed by Unity and there is a page for it on the issue tracker.

3 Likes