Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upHandle STOPPING state correctly #109
Conversation
According to Bryce this is a bug in the runtime, we should be getting READY when you tap the servo window. They hope to have this fixed by the next release (Jan). |
| @@ -347,6 +367,10 @@ impl OpenXrDevice { | |||
| Some(_) => { | |||
| // FIXME: Handle other events | |||
| } | |||
| None if stopped => { | |||
| // wait a bit before repolling for events | |||
| thread::sleep(Duration::from_millis(200)); | |||
This comment has been minimized.
This comment has been minimized.
Manishearth
Dec 17, 2019
Author
Member
Actually I'm not sure this is a good idea, this means the XR thread is indefinitely blocked while we're in the IDLE state, and since the XR thread is the main thread right now (@asajeffrey, can we change this for Hololens?) this means we're blocking the main thread too
This comment has been minimized.
This comment has been minimized.
asajeffrey
Dec 17, 2019
Member
Yeah, this doesn't look great. I don't know if we can run the HL AR APIs off the main thread, it would be nice if we could.
This comment has been minimized.
This comment has been minimized.
Manishearth
Dec 17, 2019
Author
Member
Pretty sure we can, there's no documentation about main thread affinity
This comment has been minimized.
This comment has been minimized.
jdm
Dec 17, 2019
•
Member
I specifically asked about thread affinity back when we were starting openxr and was told that openxr can run on any thread on the hololens.
So I'm thinking about this and I'm not really enjoying any of the approaches available: Approach 1: Make the XR event loop handle thisWe can split out This involves changing stuff all the way up to Approach 2: New threadSpawn a new thread that loops and polls for events, and put the main thread in "don't listen to raf calls" mode where it just remembers all the raf calls it gets. This is ... okay, but it's ugly since a lot of OpenXR state stuff leaks into webxr-api. Approach 3: double quit channelThe only thing we care about is the quit message, everything else can wait until the next frame. Perhaps we instead @asajeffrey thoughts? |
|
If we can run the HL AR APIs off the main thread, would this get round all of this? In the medium term, we should probably revisit the embedding story to move as much of Servo as we can off the main thread. |
|
@asajeffrey running things off main thread would let us pick Option 3, which is the cleanest. |
|
|
This question is doubly interesting now that we are running openxr in its own thread. |
|
@jdm now that we've done this, approach 3 can Just Work, though i'm not super happy with it |
|
Oops, reused a branch name |
|
Superseded by #139 |
openxr: Handle STOPPING event and visibility state changes The runtime now correctly triggers the `READY` state, and we're also now at a reasonable FPS that the `visible-blurred` state actually can occur. Tested on both examples that run at 60FPS and 20FPS (where the `STOPPING` is immediately triggered when you hit the menu button) Supersedes #109 Fixes #76 r? @jdm
Manishearth commentedDec 16, 2019
Tapping the start menu button works now. It does hide the app, but this is how openxr expects you to handle the stopping state.
One thing that doesn't work right now is that when you hit the home button on the start menu, we do not get any events, nor do we get any events when you tap the greyed-out servo window. This puts the session in a state where it's idle but can't be told that it should wake up again. Not quite sure what to do here.
Also, doing this completely inside handle_openxr_events isn't great; because now we can't receive quit events. It might be worth working this into the larger webxr event loop, though that would involve some tricky control flow.
Fixes #76
Progress towards servo/servo#24722, won't fix that issue until we can exit the session when you tap home.
r? @jdm @paulrouget