-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OpenXR: Properly skip frame render when the XR runtime is not yet ready #82752
Conversation
I think the issue is that XR_FAILED only checks for return codes < 0. xrAcquireSwapchainImage and xrWaitSwapchainImage can both return > 0 (0 is XR_SUCCESS, and can be checked with the XR_UNQUALIFIED_SUCCESS macro). When receiving non-XR_SUCCESS from either of those functions, then the image swapchain should not be released and xrEndFrame should not be called (I'm surprised you aren't seeing errors for this one too, maybe I did something wrong). It is okay to call xrBeginFrame (which will likely return Anyway, instead of potentially destroying/creating image swapchains every frame...
|
@dhoverml thats really good feedback thanks, I'm going to look into that more closely asap. I didn't re-apply the workaround we did in Godot 3 because I want this to be fixed properly this time. Just hadn't come high enough on the priority list yet. I'm hoping Meta is willing to have a closer look to see why this is happening in the first place, but it could indeed be as simple as us not reacting properly on certain return statusses. |
I did a quick test with the changes suggested by @dhoverml and they seem to work! From my tests at least, only |
@decacis any chance you have time to adjust your PR to fix it using that return value? |
6379140
to
b8b4fb8
Compare
@BastiaanOlij done! I tested it with both Vulkan Mobile and GL Compatibility. By the way, I found that the only way to reproduce the issue consistently is to turn off the screen and turn it back on. Recording triggers it very rarely, taking a screenshot has never triggered it for me and neither has switching to passthrough by double tapping (all of this without the new changes, of course) |
@decacis Hmm, this is pretty interesting, we've already called I think you can simplify the check to:
This way we do get a closing It might also be safer to add |
Applied a couple of checks suggested by @dhoverml for when the XrResult is not XR_SUCCESS but is also not a failure. Also simplified checks from @BastiaanOlij feedback.
b8b4fb8
to
771ec95
Compare
@BastiaanOlij thank you for the feedback. It looks way cleaner! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to wait a day or two before merging to get some feedback from others to see if this indeed resolves the issue. I've asked @Malcolmnixon to test as well as he ran into this issue this week too.
But other than getting confirmation this fixes the issue, this looks really good.
Thanks @decacis !
It should be okay to call |
I just tested this and it fixes the record issue for me. |
Thanks! And congrats for your first merged Godot contribution 🎉 |
Cherry-picked for 4.1.3. |
This PR essentially recreates the workaround found here: GodotVR/godot_openxr@484b1a8 to recover when swapchains can't be released.
As mentioned, this is a workaround, but in my opinion is a pretty important one because the issue it fixes prevents people from recording videos of the game among other things, and worst of all, it happens seemingly randomly, which can frustrate players.
I just tried my best to adapt the previous code to the new OpenXR API, so please let me know if something could be done a better way!
Closes #82751