Game crashes after coming back from sleep/standby mode using Quest 2

Hello everybody!!! I hope you can help me with this annoying crash that is causing to break all the user experience!

I am using a Quest 2 headset, and in my project, I noticed that the game crashes when you start it without wearing the headset, but seconds later, you put it on. It also crashes with the same assert if I play as usual, but if I remove my headset, I wait until standby mode, and after returning from standby mode, it crashes again!

Is only happening in builds, not in editor. This makes it more difficult to debug, attaching VS to the process, handles the error but no debug info is provided.

Here is the assert box :

openXR assert

Here is the log output :

[2022.08.10-12.10.14:858][127]Message dialog closed, result: Ok, title: The UE4-Test Game has crashed and will close, text: Assertion failed: PipelineState.FrameState.predictedDisplayTime [File:D:/Build/++UE4/Sync/Engine/Plugins/Runtime/OpenXR/Source/OpenXRHMD/Private/OpenXRHMD.cpp] [Line: 2514]

[2022.08.10-12.10.14:858][127]LogOutputDevice: Warning:

Script Stack (0 frames):

[2022.08.10-12.10.14:858][127]LogWindows: Error: Error reentered: Fatal error: [File:D:/Build/++UE4/Sync/Engine/Source/Runtime/RenderCore/Private/RenderingThread.cpp] [Line: 902]
Rendering thread exception:
Assertion failed: PipelineState.FrameState.predictedDisplayTime [File:D:/Build/++UE4/Sync/Engine/Plugins/Runtime/OpenXR/Source/OpenXRHMD/Private/OpenXRHMD.cpp] [Line: 2514]

0x00007ff830ef4fd9 KERNELBASE.dll!UnknownFunction []
0x00007ff77bf8a8f6 Test.exe!ReportAssert() []
0x00007ff77bf8e7c8 Test.exe!FWindowsErrorOutputDevice::Serialize() []
0x00007ff77bce647d Test.exe!FOutputDevice::LogfImpl() []
0x00007ff77bc49b25 Test.exe!FDebug::AssertFailed() []
0x00007ff77bc4b1a0 Test.exe!FDebug::CheckVerifyFailedImpl() []
0x00007ff779dc343f Test.exe!FOpenXRHMD::LocateViews() []
0x00007ff779dc5c63 Test.exe!FOpenXRHMD::OnBeginRendering_RenderThread() []
0x00007ff77e3273bb Test.exe!FDefaultXRCamera::PreRenderViewFamily_RenderThread() []
0x00007ff77d50e6e6 Test.exe!FViewInfo::VerifyMembersChecks() []
0x00007ff77d4e6296 Test.exe!FSceneRenderer::DoOcclusionQueries() []
0x00007ff77d4ea520 Test.exe!TBaseStaticDelegateInstance<void __cdecl(wchar_t const * __ptr64,IConsoleObject * __ptr64),FDefaultDelegateUserPolicy,unsigned int & __ptr64>::ExecuteIfSafe() []
0x00007ff77ba8ff7b Test.exe!FNamedTaskThread::ProcessTasksNamedThread() []
0x00007ff77ba903de Test.exe!FNamedTaskThread::ProcessTasksUntilQuit() []
0x00007ff77e7874a9 Test.exe!RenderingThreadMain() []
0x00007ff77e78c3a9 Test.exe!FRenderingThread::Run() []
0x00007ff77bfab44f Test.exe!FRunnableThreadWin::Run() []
0x00007ff77bfa1960 Test.exe!FRunnableThreadWin::GuardedRun() []
0x00007ff8328d7034 KERNEL32.DLL!UnknownFunction []
0x00007ff8334a2651 ntdll.dll!UnknownFunction []

Has anyone experience this crash? Or have any idea what can be causing it and how to solve it?

Als, tips or suggestions about how to tackle this are also welcome!!

Thanks in advance!

It asserts on an invalid 0 value of predictedDisplayTime. The OpenXR runtime is supposed to never return this value according to the spec. Seems like it could be either a bug in the runtime, or a bug in Unreal where it tries to use the value before getting it with xrWaitFrame().

To verify which it is, you would need to see if it runs xrWaitFrame() before asserting, and what value xrWaitFrame() returns for predictedDisplayTime.

@Rectus_SA Thanks for your reply! I have tried what you commented and I added a few comments just after xrWaitFrame() and where LocateViews() is called.

Here is the log:

`[2022.08.15-11.19.08:480][ 92]LogStreaming: Display: FlushAsyncLoading: 1 QueuedPackages, 0 AsyncPackages

[2022.08.15-11.19.08:845][113]LogBlueprintUserMessages: [BP_Character_VR_C_2147482176] Local X: Avatar Ready

[2022.08.15-11.19.09:035][132]LogBlueprintUserMessages: [BP_Character_VR_C_2147482176] Local X: VRIH Ready

[2022.08.15-11.19.13:662][766]LogHMD: FOpenXRHMD::Enumerate_Views() :: predictedDisplayTime id :  0

[2022.08.15-11.19.13:662][766]LogWindows: Windows GetLastError: The operation completed successfully. (0)

[2022.08.15-11.19.13:664][766]LogHMD: FOpenXRHMD::OnBeginRendering_GameThread() ::xrWaitFrame predictedDisplayTime id :  261659264356899

[2022.08.15-11.19.13:667][766]LogHMD: FOpenXRHMD::Enumerate_Views() :: predictedDisplayTime id :  261659264356899

[2022.08.15-11.19.18:000][767]LogWindows: Could not start crash report client using ../../../Engine/Binaries/Win64/CrashReportClient-Win64-Debug.exe

[2022.08.15-11.19.18:000][767]LogMemory: Platform Memory Stats for WindowsNoEditor
[2022.08.15-11.19.18:000][767]LogMemory: Process Physical Memory: 1740.19 MB used, 3245.45 MB peak

[2022.08.15-11.19.18:000][767]LogMemory: Process Virtual Memory: 4405.39 MB used, 5853.01 MB peak

[2022.08.15-11.19.18:000][767]LogMemory: Physical Memory: 19774.70 MB used,  12929.58 MB free, 32704.27 MB total

[2022.08.15-11.19.18:000][767]LogMemory: Virtual Memory: 134207832.00 MB used,  9894.92 MB free, 134217728.00 MB total

[2022.08.15-11.19.18:000][767]Message dialog closed, result: Ok, title: The UE4-VRProjectGame has crashed and will close, text: Assertion failed: PipelineState.FrameState.predictedDisplayTime [File:G:/Epic/427/Engine/Plugins/Runtime/OpenXR/Source/OpenXRHMD/Private/OpenXRHMD.cpp] [Line: 2517] 




[2022.08.15-11.19.18:000][767]LogOutputDevice: Warning: 

Script Stack (0 frames):

[2022.08.15-11.19.18:000][767]LogWindows: Windows GetLastError: The operation completed successfully. (0)
[2022.08.15-11.19.18:000][767]LogWindows: Error: === Critical error: ===
[2022.08.15-11.19.18:000][767]LogWindows: Error: 
[2022.08.15-11.19.18:000][767]LogWindows: Error: Fatal error: [File:G:/Epic/427/Engine/Source/Runtime/RenderCore/Private/RenderingThread.cpp] [Line: 902] 
[2022.08.15-11.19.18:000][767]LogWindows: Error: Rendering thread exception:
[2022.08.15-11.19.18:000][767]LogWindows: Error: Assertion failed: PipelineState.FrameState.predictedDisplayTime [File:G:/Epic/427/Engine/Plugins/Runtime/OpenXR/Source/OpenXRHMD/Private/OpenXRHMD.cpp] [Line: 2517] 
[2022.08.15-11.19.18:000][767]LogWindows: Error: 
[2022.08.15-11.19.18:000][767]LogWindows: Error: `

This line [2022.08.15-11.19.13:662][766]LogHMD: FOpenXRHMD::Enumerate_Views() :: predictedDisplayTime id : 0 is called right before enters to LocateView() function which contains the assert. Then, xrWait is called with valid values, but the assert is called anyway.

Does that mean UE4 is trying to get this value before getting it from xrWait? Is a bug in UE4 then? Any suggestions on how to approach this?

Looks like it first calls EnumerateViews() from the FOpenXRHMD constructor. If that call ends up calling xrWaitFrame(), then it’s probably a bug in the runtime. Otherwise UE4 isn’t initializing the views before trying to render them. The game and render threads are pipelined and xrWaitFrame() is run on the game thread, so it would pass the invalid data to the first frame rendered after the OpenXR session is initialized.

Either way, it might be fixable by checking if the value is correct before starting rendering in OnBeginRendering_RenderThread(). Note that it copies PipelinedFrameStateGame into PipelinedFrameStateRendering at the start, so make sure you check the correct one.

Thanks, @Rectus_SA ! With your guidance, I managed to “fix” it by just tracking where it got null and doing an early return if it is not valid. It is not a real fix, but it works until UE4 or XR fixs it!

Thanks!

im having this exact same issue, can you please clarify a bit more on to where your fix went?thankyou

@ch0pster can you please help kind sir and explain some more how one would achieve this solution, thank you so much

This was 100% reproducible six months ago, but, I’m no longer able to. Not sure if the runtime got updated, or if it got fixed in 5.1/5.2, but it’s no longer an issue that I can reproduce.

still an issue in 4.27.2 which is what what we have to use for production due to stability

There won’t be any more updates to OpenXR in 4.27, all future work is in 5+. If you have stability issues in UE5, please spin up a new post on the forums with reproducible steps. I should note that 5.1 is significantly more stable than 5.0, and 5.2 even further.

thats fine Victor, I’m not asking for engine help, I’m asking for community help, but I’m already attempting a fix and will post shortly if I can help other ue4.27.2 devs instead of abandoning them :slight_smile: … 5.1 and 5.2 are still broken when it comes to physics. its not production ready(ccd still doesn’t work correctly in chaos vs physx)…

Just making sure expectations are clear so that you can make the right decisions for you and your team. If you could link me to a post, or provide reproducible steps for the CCD issues I’d appreciate it!

1 Like

if (!PipelineState.FrameState.predictedDisplayTime) {return;} just add that before wherever your crash is… worked for me… in my case it was line 2528 of OpenXRHMD.cpp