Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Bug Stutter / Frame Pacing issues after upgrading to 2021.3

Discussion in 'VR' started by kayke, Jan 31, 2023.

  1. kayke

    kayke

    Joined:
    Oct 21, 2015
    Posts:
    42
    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
     
    Last edited: Jan 31, 2023
  2. kayke

    kayke

    Joined:
    Oct 21, 2015
    Posts:
    42
    Bug report submitted


    CASE IN-30623
     
    ScottJustScott likes this.
  3. kayke

    kayke

    Joined:
    Oct 21, 2015
    Posts:
    42
    Here are those stutters when looked at in the profiler

    upload_2023-2-1_14-49-46.png
     
  4. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,136
    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
     
    kayke likes this.
  5. ScottJustScott

    ScottJustScott

    Joined:
    Nov 15, 2022
    Posts:
    6
    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
    https://developer.oculus.com/documentation/unity/enable-phase-sync/

    Related "By Design" Bug Report?
    https://issuetracker.unity3d.com/issues/xr-sdk-oculus-earlyupdate-dot-xrupdate-spikes-inconsistently
     
    Mike_d3v and kayke like this.
  6. ckohlmeyer

    ckohlmeyer

    Joined:
    Apr 17, 2021
    Posts:
    40
    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.
     
    ScottJustScott likes this.
  7. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,136
    Then make a repro project and make a bug report.
    If there are no well documented bug reports there won't be fixes
     
  8. ckohlmeyer

    ckohlmeyer

    Joined:
    Apr 17, 2021
    Posts:
    40
     
    kayke likes this.
  9. kayke

    kayke

    Joined:
    Oct 21, 2015
    Posts:
    42
    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.

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

    upload_2023-2-1_16-17-41.png
     
  10. lianne13

    lianne13

    Unity Technologies

    Joined:
    Jan 31, 2023
    Posts:
    21
    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.
     
    Last edited: Feb 2, 2023
    GameFinder, kayke and ScottJustScott like this.
  11. ScottJustScott

    ScottJustScott

    Joined:
    Nov 15, 2022
    Posts:
    6
    @LianneUnityXR 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.

    BadFrames.png
     
  12. kayke

    kayke

    Joined:
    Oct 21, 2015
    Posts:
    42
    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.
     
    Last edited: Feb 7, 2023
    Aldeminor and ScottJustScott like this.
  13. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,136
    Interesting, I thought they fixed deltatime issues in a recent LTS
     
  14. ScottJustScott

    ScottJustScott

    Joined:
    Nov 15, 2022
    Posts:
    6
    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.
     
  15. ScottJustScott

    ScottJustScott

    Joined:
    Nov 15, 2022
    Posts:
    6
  16. immersification

    immersification

    Joined:
    Apr 20, 2022
    Posts:
    3
    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
     
  17. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,960
    immersification and kayke like this.
  18. kayke

    kayke

    Joined:
    Oct 21, 2015
    Posts:
    42
    @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
    Code (CSharp):
    1. stopwatch.ElapsedMilliseconds
    to extrapolate delta time.
     
  19. immersification

    immersification

    Joined:
    Apr 20, 2022
    Posts:
    3
    @kayke thanks a lot! We're going to try this. Almost got our brains melted with this
     
    kayke likes this.
  20. kayke

    kayke

    Joined:
    Oct 21, 2015
    Posts:
    42
    ScottJustScott, DevDunk and glenneroo like this.
  21. GameFinder

    GameFinder

    Joined:
    Jan 7, 2015
    Posts:
    17
  22. Cloudwalker_

    Cloudwalker_

    Joined:
    Jan 3, 2014
    Posts:
    140
    Looks like they are going to ignore 2020 and 2021 because of a compilation error in the submission.
     
  23. DanjelRicci

    DanjelRicci

    Joined:
    Mar 8, 2010
    Posts:
    314
    Thanks a lot for investigating this further, it's probably related to a performance problem with 2021 LTS that keeps popping up every now and then. I've been stuck in 2020 LTS for too long due to this but I might give it a try again using your workaround!

    EDIT: from the bug tracker page:
    Not sure what this means, considering you found the issue in a 2021 version.
     
    Last edited: Feb 18, 2023
  24. ChescoRed

    ChescoRed

    Joined:
    Sep 29, 2018
    Posts:
    35
    I'm running into the same problem, only using URP in Unity version 2021.3.18f, I've already tried with older versions 16f and 17f.

    It also occurs with App Space Warp.

    I thought I was going crazy, anyone suggest a solution? A hug to everyone and thanks.

    In 2021.3.19f the problem continues.*
     
    Last edited: Feb 21, 2023
    ScottJustScott likes this.
  25. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,136
    The solution is to mass vote on the issue on the issuetracker
     
    ChescoRed likes this.
  26. ChescoRed

    ChescoRed

    Joined:
    Sep 29, 2018
    Posts:
    35
    This tutorial is based on the great work done by @DevDunk which you can see in you and a thousand apologies for not having put a reference before, the basic difference with this one is the implementation of the URP that I do from the manifest.json unlike @DevDunk which perform an installation, I'm not sure that it will solve the problem but in the initial tests it seems to be so.

    TUTORIAL @DevDunk


    Hi guys, I think I have found a possible solution.

    First, I apologize for my English since it is practically nil, I will try to develop all the steps that I have taken and I hope that it works for you, it is doing quite well for me except for some initial flickering, but then it looks fluid.

    I'm not an expert either, so if you see something outrageous please don't take it into account.

    Create project with normal Unity 2021.3.19f WITHOUT URP, I load it like this for fear that later there will be residues from the initial installation of the URP that comes by default with Unity and that is not the one we need.

    Captura de pantalla 2023-02-24 183921.jpg


    Once the typical project is compiled, we move to the Android platform, install XR Plug-in Management and when finished we select Oculus tabs.The XR Plug-in Management>>>Oculus settings would be as follows.

    Captura de pantalla 2023-02-24 184700.jpg

    Now we are going to download Oculus Integration in my case I am using v49, when it is installed in the dialog boxes select OpenXR and the typical, update, restart, etc...

    In the project you can start marking assets and with the right button press Show in Explorer or go to your project folder and in Packcages you will find two .json files, open the one called manifest.json and it should look like in the image, adding the dependencies that are checked.

    Captura de pantalla 2023-02-24 185823.jpg

    You can find it at the following link in the Oculus documentation. https://developer.oculus.com/documentation/unity/unity-asw/

    Once those lines have been entered, click save and the Unity project will begin to compile the new packages.

    When finished we have to configure the graphic themes for URP, we have to create a URP Asset, in the folder that we want (I organize everything in my own way, I will not be the one to say how to follow an order =op), press the right button Create >>>Rendering>>>URP Asset (whit Universal Renderer) as it is in the image.

    Captura de pantalla 2023-02-24 190712.jpg

    In the Quality configuration, use the one you want, I recommend this, but surely someone can give ideas for a better result.

    Captura de pantalla 2023-02-24 191409.jpg


    It only lets me upload five images I continue with the post.
     
    Last edited: Feb 25, 2023
    Niter88 likes this.
  27. ChescoRed

    ChescoRed

    Joined:
    Sep 29, 2018
    Posts:
    35
    CONTINUE ->

    Clicking on the Asset Render Pipeline we configure as indicated in the image. It is how I have it but as I have already told you, I am sure that you have better ideas.

    Captura de pantalla 2023-02-24 191906.jpg

    And now we click on the other Asset Render that has been created for us (Universal Render Data) and leave it as in the image.

    Captura de pantalla 2023-02-24 192424.jpg

    Again in Project Settings in Graphics we make sure that the Scriptable is loaded otherwise we put it, the configuration that you see here is like this in the example of Oculus App-Space Warp
    Captura de pantalla 2023-02-24 192730.jpg

    And finally, under Graphics is URP Global Settings that should look like the following image.

    Captura de pantalla 2023-02-24 192924.jpg

    All that remains is to activate the Space Warp App, create a script, and drag it to an object in the scene.

    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. public class EnableAppSpaceWarp : MonoBehaviour
    7. {
    8.     // Start is called before the first frame update
    9.     void Start()
    10.     {
    11.         OVRManager.SetSpaceWarp(true);
    12.     }
    13. }
    Now it only remains to compile, you can see that the FPS are at 36, at first it jumps a bit but it disappears quickly and I can see everything smoothly.

    I leave conclusions in the next post.
     
    Niter88 likes this.
  28. ChescoRed

    ChescoRed

    Joined:
    Sep 29, 2018
    Posts:
    35
    If you look at the documentation what we are doing is implementing a URP created specifically by Oculus to use App Space Warp, we can create a material using Simple Lit for example and it shouldn't give any problems. In fact, you can use another type of material using, for example, a different Shader and you will see that the jumps occur again, in my scene I have objects with Simple Lit that I use from the oculus package and another from an Asset that I have downloaded and the strange movements they occur with the second while the rest of the scene I can walk and see without problems.

    I leave you a video of what the test scene looks like.

    The textures are 1024*1024 for the cliffs, the ground is 1025*1024 and the sky is 2048*2048

    A hug and I hope I can help you a little.



    The mountain that I see at the end is the one that gives me problems because of what I have told you, it is not visible in the video but in the glasses it is a flicker like the one that other colleagues comment. A curious thing is how the FPS is "maintained" at 36 except for a small drop at the end, however when you turn the "normal" FPS drops to 72, but in a second or two it recovers.

    I almost forgot, I'm using mixed lights, and a bakend.

    A hug to all.
     
    Niter88 likes this.
  29. ChescoRed

    ChescoRed

    Joined:
    Sep 29, 2018
    Posts:
    35
    It definitely doesn't work, I'm leaving the post if you don't care in case someone from Unity sees it and can indicate that it's being done wrong in case it's a bad configuration.

    (I really want to cry...)

    Captura de pantalla 2023-02-25 100207.jpg

    Android Logcat:

    2023/02/25 09:50:35.004 16052 16219 Info VrApi FPS=45/90,Prd=28ms,Tear=0,Early=0,Stale=1,Stale2/5/10/max=0/0/0/1,VSnc=0,Lat=-3,Fov=0,CPU4/GPU=4/3,1478/490MHz,OC=FF,TA=0/0/0,SP=N/N/N,Mem=1804MHz,Free=3094MB,PLS=0,Temp=23.0C/0.0C,TW=2.00ms,App=3.17ms,GD=0.00ms,CPU&GPU=7.40ms,LCnt=2(DR0,LM0),GPU%=0.34,CPU%=0.12(W0.15),DSF=1.00,CFL=14.74/19.66

    2023/02/25 09:50:35.004 16052 16219 Info VrApi ASW=90, Type=App E=0.011/0.261,D=0.000/0.000

    A zero comma from learning Unreal
     
    Niter88 likes this.
  30. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,136
    @ChescoRed make a bug report, you seem to have a good project for them to test on. Posting it here helps the community a bit, but doesn't guarantee unity staff looking at it
     
    tspk91 and ChescoRed like this.
  31. Cloudwalker_

    Cloudwalker_

    Joined:
    Jan 3, 2014
    Posts:
    140
    tspk91 likes this.
  32. ChescoRed

    ChescoRed

    Joined:
    Sep 29, 2018
    Posts:
    35
  33. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,136
  34. ChescoRed

    ChescoRed

    Joined:
    Sep 29, 2018
    Posts:
    35
  35. ChescoRed

    ChescoRed

    Joined:
    Sep 29, 2018
    Posts:
    35
    Hello everyone, there is a new update of 2021LTS, specifically 2021.3.21 where I just carried out tests and in principle the blinking problem when you use URP has disappeared, greetings to all.
     
    ScottJustScott, fumobox and Eclectus like this.
  36. mblt2334

    mblt2334

    Joined:
    Jul 8, 2017
    Posts:
    8
    This issue has been driving me crazy and preventing me from launching my game (developing for VR quest platform). I noticed this problem in 2021.3.15f1 and I tried updating my project to latest LTS 2021.3.25f1. It seems like my game runs very smooth for about 10mins and then slowly the stuttering sets in to where its very noticeable and really effects the gameplay. If i quit the game and then start playing again Its goes back to being smooth until after another 10 mins or so. Anyone know a fix or work around for this?
     
    madbuggerswall and Daniel_XR like this.
  37. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,136
    Is the framerate still stable if you check the profiler and or OVRMetrics?
    If so, if it's reproducable, please make a bug report.