I had originally asked a question, but I figured that since I found what the issue was, it would be better to make a separate topic to document my current progress.
I was having an issue while trying to develop a VR game in Unreal Engine 5.2.
Even using the starter sample project or an empty world, the World Tick Time seemed to be bottlenecked even when nothing had been added or changed in the level yet. It ended up making the cpu frame time go over 11.1ms so it wasn’t hitting my target 90hz.
I tried to profile it, but was getting stuck at World Tick Time > Self (see image).
I eventually went far enough to find what was happening.
The problem with World Tick Time I found is that the frame time gets unsynched when Garbage Collection runs.
Afterward, every xrWaitFrame waits an unnecessary amount of time, of which it can increase further on more garbage collections or other thread stalls.
I found that if I measure the time xrWaitFrame takes and it is over a threshold (I set mine to 1ms), and I make it immediately return on the next pass, it fixes the issue. Though obviously not fully ideal since every time GC is run you will get a 1 frame skip. If you have GC running once per minute, you’ll notice the skip every minute. I combined this with extending the “Time Between Purging Pending Kill Objects” setting to 10 minutes and now don’t really have any issues. Just that once every 10 minutes you may or may not notice a frame skip. Would be better if instead of skipping it was able to sync the timings up another way, but still need to figure that out.
Runs great now though…
I made my changes in the FOpenXRHMD::OnBeginSimulation_GameThread() function in OpenXRHMD.cpp.