Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Other XREarlyUpdate spikes any news?

Discussion in '2021.1 Beta' started by BATTLEKOT, Dec 3, 2020.

  1. BATTLEKOT

    BATTLEKOT

    Joined:
    Oct 2, 2016
    Posts:
    179
    Hey all! Is there any news about case
    XR: [XR SDK][Oculus] EarlyUpdate.XRUpdate spikes inconsistently (1262597)

    Wondering because this problem is almost 1 year old, and do not allow to upload games to Oculus Store. That very critical for marketplace.
    Every week i checking changelog of 2019.4 , 2020.1 , 2020.2 , 2021.1 with hope that this bug resolved.
    I really would be happy to know more news about progress of fixing this bug (Already uploaded several ticket with different projects to help out fix this bug faster).

    Thanks!
     
  2. jj-unity

    jj-unity

    Unity Technologies

    Joined:
    Jan 4, 2017
    Posts:
    74
    Ok, we've been investigating this a fair amount. XRUpdate covers a *lot* of cases, so there's no one answer here. We added a new profiler marker to attempt to help with resolving this. The tl;dr is that almost all of the time in XRUpdate is spent in the Oculus runtime waiting for frame timing cadence. This is intentional. If there are situations where this does not seem to be the case, we absolutely want to hear about them. Please try out 1.7.0-preview.1 of the Oculus XR Plugin and verify that the time is spent inside the Oculus runtime waiting for frame timing.

    Here are the notes I added to the bug:


    The XRUpdate profiler marker covers a lot, so we're going to go over a few cases where it can spike in duration.

    First of all, almost always, the biggest consumer of time in XRUpdate on Oculus platforms is going to be waiting for frame sync. This wait happens in the Oculus runtime, and they do this wait to reduce latency, maintain proper cadence, etc. In order to clarify where XRUpdate is spending its time, we have added a new profiler marker: `OculusRuntime.WaitToBeginFrame`. This is available in the Oculus XR Plugin 1.7.0-preview.1 and higher. Anyone reporting or voting on this bug, it would be great if you could try this version of the Oculus XR Plugin and verify that the time is being spent in WaitToBeginFrame. If it is, it's likely going to be related to one of the items below. If it's not, please give us feedback.

    1) If you are using minimal frame time. In this case, WaitToBeginFrame will be waiting because you're running great and it's preventing the engine from feeding it frames too fast.
    2) If you are missing framerate, even if barely, or seemingly right on the edge with maybe even a bit of breathing room.
    3) If you are experiencing highly variable frame times. In this case you might see unusual behavior where WaitToBeginFrame is taking a long time one frame, and almost no time the next. This can happen because the runtime is trying to compensate for this variable frame timing.

    For point 3, one thing we've seen is that the in-editor profiler can induce these spikes. The Unity profiler updates in the main thread, but not every frame. When it does update, you'll notice two `EditorLoop` profiler markers. The second one is the profiler updating the UI, etc. Because this is on the main thread, it causes a spike in frame time, and the Oculus runtime appears to be compensating for this, resulting in the WaitToBeginFrame timing that we see.

    In Unity 2020.1+, you can run the profiler standalone, outside of the editor process. Doing this, we aren't seeing the same spikes caused by the profiler timing.

    In summary, please try out the 1.7.0-preview.1 or higher Oculus XR Plugin and see if the WaitToBeginFrame marker is what is taking the most time. If so, this is in the Oculus runtime, and it is doing what is needed to maintain proper cadence and low latency.

    If you don't believe that you are seeing one of the 3 cases mentioned above or something similar, please let us know.
     
  3. jj-unity

    jj-unity

    Unity Technologies

    Joined:
    Jan 4, 2017
    Posts:
    74
    One additional comment: this new profiler marker will only show up in Unity 2020.1 and higher, because the profiler interfaces weren't exposed to plugins in 2019.4.
     
  4. BATTLEKOT

    BATTLEKOT

    Joined:
    Oct 2, 2016
    Posts:
    179
    upload_2020-12-9_23-43-25.png
    Where are i can find the new version of Oculus XR Plugin?
    I'm on 2021.1 alpha. playing with latest URP versions =)
     
  5. BATTLEKOT

    BATTLEKOT

    Joined:
    Oct 2, 2016
    Posts:
    179
  6. BATTLEKOT

    BATTLEKOT

    Joined:
    Oct 2, 2016
    Posts:
    179
    Here is example of rendering without VR. just rendering two 4k display in scene and its about 2.5 ms to render
    upload_2020-12-10_1-26-34.png
     
  7. jj-unity

    jj-unity

    Unity Technologies

    Joined:
    Jan 4, 2017
    Posts:
    74
    Those captures are pretty different. For one the two FixedUpdates don't even show up on the second. I'm also wondering what's going on with the XREarlyUpdate, because we don't usually see that.
     
  8. BATTLEKOT

    BATTLEKOT

    Joined:
    Oct 2, 2016
    Posts:
    179
    Maybe i can send to you a project files?
     
  9. BATTLEKOT

    BATTLEKOT

    Joined:
    Oct 2, 2016
    Posts:
    179

    Attached Files:

  10. EusebiuMarcu

    EusebiuMarcu

    Joined:
    Sep 20, 2018
    Posts:
    26
    Still happens on Unity 2020.2 with Oculus Integration 20.1, Oculus XR Plugin 1.7.0 preview 2.
    The time is spent in OculusRuntime.WaitToBeginFrame.
     
    Last edited: Dec 22, 2020
  11. EusebiuMarcu

    EusebiuMarcu

    Joined:
    Sep 20, 2018
    Posts:
    26
    I tried with an older version of Unity (2019.4) with legacy XR and Oculus Integration v15(?) (OVR 1.46.0) and the FPS is still low (on same Oculus App v24 and Oculus Quest v23). This wasn't the case before the update of either Windows 10 (20H2 from 1809), NVidia Drivers (v460.89 for GTX 1070) or Oculus Quest/App.
    Since it works fine (i.e. 80-90 FPS) the first time I start the app (Unity, Oculus App/Link) I tend to believe that is the latest update of Oculus Quest.
    The issue is not present if I build & run directly on the Quest (Android Player).
     
  12. BATTLEKOT

    BATTLEKOT

    Joined:
    Oct 2, 2016
    Posts:
    179
    Happy new year everyone!
    jj-unity
    Any news about that?
     
  13. EusebiuMarcu

    EusebiuMarcu

    Joined:
    Sep 20, 2018
    Posts:
    26
    Happy new year!
    After some research on various forums, I think this is caused by a mix from Windows 10 (20H2 in my case) and NVidia drivers (mine is GTX 1070). Basically, this started (at least I started to notice it) after the Windows 10 20H2 update from 1809.
    In various topic NVidia forums I found that other users have this issue but not so much on older Windows 10 build (1909 is the last stable one - don't take my word as an absolute - 2004 and above are problematic).
    I tried disabling all kind of "features" from Windows 10 (Game mode, DVR, etc.) and enabled the most performance for other (NVidia Control panel, Windows 10 baterry settings, OVRServer priority to High etc.) with little success.
    So, I am looking forward to new Windows 10 Updates and/or NVidia drivers.
     
  14. BATTLEKOT

    BATTLEKOT

    Joined:
    Oct 2, 2016
    Posts:
    179
    maybe, not sure about that. its happening at everyone from my friends. Even on RTX2080
     
  15. EusebiuMarcu

    EusebiuMarcu

    Joined:
    Sep 20, 2018
    Posts:
    26
    Are you using an older built of Windows 10 = below 2004?
     
  16. BATTLEKOT

    BATTLEKOT

    Joined:
    Oct 2, 2016
    Posts:
    179
    My windows version is 1909
     
  17. EusebiuMarcu

    EusebiuMarcu

    Joined:
    Sep 20, 2018
    Posts:
    26
    Can you check on an even older build?

    I still think it is a Windows/GPU Driver issue for the following reasons:
    1/ It happens on SteamVR/Oculus default apps (SteamVR Home and Oculus Link/Oculus Home), too - not Unity related
    2/ It works fine for some time (1-2 minutes) and then the FPS drops (in both Unity and default VR apps) - this is experienced by other ppl on NVidia forums (especially if I start a fresh Unity & Oculus Link session)
    3/ the entire system is getting very slow and it recovers as soon as I exit the app.

    So, it is like something is not keeping up with the demand or is some Thread.Sleep/while(1) forgotten in the code... :)
     
  18. EusebiuMarcu

    EusebiuMarcu

    Joined:
    Sep 20, 2018
    Posts:
    26
    I've updated to 461.33 and seems to be better - average FPS is 30 but the spikes are there after running the VR app in the Editor.
     
  19. Josun

    Josun

    Joined:
    Oct 8, 2017
    Posts:
    3
    It looks like directly setting Application.targetFrameRate at runtime can cause intermittent lag spikes (every second or so) afterwards in 2020 LTS with Oculus Integration. Problem is consistent in the editor and when built for PC. During these spikes, the profiler shows the following two entries taking up a large amount of time each:

    EarlyUpdate.XRUpdate => OculusRuntime.WaitToBeginFrame
    TimeUpdate.WaitForPresentationAndUpdateTime => WaitForTargetFPS

    I upgraded from 2019 LTS and ran into this problem right away. Removing my call to Application.targetFrameRate seems to have fixed it.

    Hope this helps anyone else running into this when jumping to 2020 LTS.
     
    lena_unity458 and Quarty like this.
  20. mosabsaraireh

    mosabsaraireh

    Joined:
    Mar 28, 2021
    Posts:
    4

    Hi, can you explain how did you remove that please?
     
  21. ArthurRibeiro

    ArthurRibeiro

    Joined:
    Jul 10, 2018
    Posts:
    3
    Any news on this? I am currently wasting 17.82ms on OculusRuntime.WaitToBeginFrame alone, 60 ~ 80% of my frame time is just this.
    upload_2022-8-4_14-54-33.png

    I profiled on a oculus build directly, so no editor influence.
    My scene is super small, never going over 30 drawcalls.

    Everything is up to date:
    - Unity 2021.3.7
    - XR Management: 4.2.1
    - Oculus Plugin 3.0.2
     

    Attached Files:

  22. ArthurRibeiro

    ArthurRibeiro

    Joined:
    Jul 10, 2018
    Posts:
    3
    Something simillar happens with the OpenXR plugin, but the execution is stuck in "FrameEvents.XRBeginFrame > Gfx.WaitForRenderThread"
    upload_2022-8-4_15-33-27.png

    The render thread is doing nothing though...
    upload_2022-8-4_15-35-59.png
     
  23. DriesVrBase

    DriesVrBase

    Joined:
    Mar 24, 2020
    Posts:
    65
    Having the same issue, did you find a fix?
     
  24. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    Wanted to add my "me too". In my case, it spends 40ms(!) on OculusRuntime.WaitToBeginFrame causing my frame rate to drop to around 20 FPS on a scene (an empty room) with one point light, 4 walls, a floor and a ceiling and nothing else.
     
  25. CoreyOSmith

    CoreyOSmith

    Joined:
    Dec 2, 2021
    Posts:
    1
    This happens to me as well.

    Spikes every other frame, with the culprit being OculusRuntime.WaitToBeginFrame.

    It only happens in the Unity Editor and only after taking off the HMD and putting it back on in a different area of the play space. Afterwards it will continue to spike until restarting the game.

    upload_2023-1-11_17-33-16.png
     
  26. adeick8

    adeick8

    Joined:
    Jan 4, 2023
    Posts:
    8
    OculusRuntime.WaitToBeginFrame seems to be taking up over half the CPU budget in every frame. How is this possible?
     
  27. zhangwlgq_unity

    zhangwlgq_unity

    Joined:
    Nov 4, 2022
    Posts:
    2
    Me too. The difference is my OculusRuntime.WaitToBeginFrame not spikes, but taking 50% cpu time at every frame.
     
  28. unityventures21

    unityventures21

    Joined:
    Feb 7, 2023
    Posts:
    1
    up. Am also having the same issue wiht OculusRuntime.WaitToBeginFrame, but instead of spiking its consistenlty taking at least 50% of cpu time every frame.
     
  29. Siba_M_M

    Siba_M_M

    Joined:
    Aug 11, 2020
    Posts:
    15
    Hi everyone, I'm facing this issue too... Has anyone been able to solve it?
     
  30. Mach_XNU

    Mach_XNU

    Joined:
    Dec 11, 2021
    Posts:
    1
    I was able to solve this by realising that it was an optimisation problem of my game. Basically, the CPU is waiting for a long time for the next frame, that's why EarlyUpdate.XRUpdate takes such a long time, it basically waits.

    It waits for the GPU to complete its job on the frame. So, in the profiler, if you have a look at the Render Thread, you should see that it is running all the time, and takes much longer than the CPU to compute its part of the job to render the frame.
    Just try different GPU optimisation techniques, so as to release stress on your Render Thread (GPU), and you'll see that the CPU will wait less time, thus reducing EarlyUpdate.XRUpdate.

    Hope this helps !
     
  31. bleach3

    bleach3

    Joined:
    Feb 22, 2023
    Posts:
    1
    @jj-unity
    My application have the same issue. But it's with "OpenXR Plug-in Providers", not "Oculus". We developed our own OpenXR runtime. Now the XRUpdate function always take about 10~20ms.
     
  32. mrphilipjoel

    mrphilipjoel

    Joined:
    Jul 6, 2019
    Posts:
    60
    Trying to get our Quest 2/3 app a stable 90 FPS with 8 players. So, our frame budget is 11.11ms. Which most of the time we are in budget. But, every now and then we get a spike that puts us over 20ms. When Profiling, I see its due to OculusRuntime.WaitToBeginFrame. Its waiting for 10 ms. In other frames, it waits 3ms or less. All my other threads appear to be idle.
     

    Attached Files: