-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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
Always render when XR is enabled, even if no OS windows can draw #94412
Conversation
8a4c588
to
0f3ba8c
Compare
Alright, I've updated this PR to implement @BastiaanOlij's idea, with a few small changes:
However, I don't particularly like this approach:
Anyway, please let me know if this looks better to you guys! /cc @clayjohn |
c1bb353
to
d0e4090
Compare
I agree that the Heck a long standing wish of many users for XR is that we don't even have any Godot window open, I can see similar situations when integrating Godot into other apps. |
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.
lgtm, it's worth having the discussion if passing Object is indeed the best way or if we simplify this to increasing/decreasing a counter
d0e4090
to
7a5a859
Compare
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.
Looks good to me.
Thanks! |
I tried to capture Godot with OBS while minimized with this commit, but it still freezes in OBS when the window is minimized. All I have in the scene is an animated moving cube, a camera, and a script: `extends Node3D var object = Object.new() func _ready() -> void: |
@pochoco24 I responded here |
The short explanation:
Currently, in
Main::iteration()
, it will skip rendering for a particular frame ifDisplayServer::get_singleton()->can_any_window_draw()
returnsfalse
.For all current
DisplayServer
s, they either:true
, ortrue
if at least one of Godot's windows is visibleHowever, when using an XR device, we need to keep rendering, even if all OS windows aren't visible. For example, if you have a VR headset connected to your desktop, you don't want it to stop rendering to the headset if the Godot window on your desktop is minimized.
So, this PR will cause rendering to happen if the primary
XRInterface
is initialized, even ifDisplayServer::get_singleton()->can_any_window_draw()
returnsfalse
.The longer explanation:
I started looking into this because there is a case when using the Meta XR Simulator on MacOS, where we would sometimes call
xrWaitFrame()
twice without callingxrBeginFrame()
in between, which leads to the application getting "stuck" forever (spinning beach ball and everything).According the OpenXR specification (in Section 10.3):
So, the Meta XR Simulator is acting exactly as specified, and is blocking until the next
xrBeginFrame()
(which will never come when Godot is using single-threaded rendering).The reason the
xrBeginFrame()
sometimes doesn't happen, is that we're calling it at the beginning of rendering (as we should, per the spec!), and, per the "short explanation" above, Godot may skip rendering if all windows are momentarily not visible.While I originally dug into this for this very specific OpenXR related bug, I think it logically makes sense that when using XR, we shouldn't make rendering conditional on if OS windows are visible.