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
Timing of initial inputsourceschange event #961
Comments
Looks like we already queue a task within "add input source", so this is fine. But it's important to highlight that that task has to be queued for this to work right, we cannot immediately fire the event. Honestly this feels like it hinges too much on the precise scheduling of tasks, no matter what. I think given that It also means that you can only rely on this if you're running |
Always trigger an input sources change event on session creation Fixes our behavior to match the spec, and to specifically do it in a way that makes sense. This is also what Chromium does currently, though I'm not sure if it does the scheduling the same way. The spec for this may change, see immersive-web/webxr#961. This fix, along with #25770 , makes three.js content work on servo. Instead of this fix we can also wait for mrdoob/three.js#18638 to land (which isn't certain until we figure out more about immersive-web/webxr#961 ) Even if immersive-web/webxr#961 decides to choose the option that obviates this patch, we should probably keep it for now since there's already content out in the wild relying on this behavior. r? @jdm @asajeffrey
It's been pointed out to me that we can even have the resolve happen after the "queue a task to fire events" because of how microtasks work (the microtask for |
Always trigger an input sources change event on session creation Fixes our behavior to match the spec, and to specifically do it in a way that makes sense. This is also what Chromium does currently, though I'm not sure if it does the scheduling the same way. The spec for this may change, see immersive-web/webxr#961. This fix, along with #25770 , makes three.js content work on servo. Instead of this fix we can also wait for mrdoob/three.js#18638 to land (which isn't certain until we figure out more about immersive-web/webxr#961 ) Even if immersive-web/webxr#961 decides to choose the option that obviates this patch, we should probably keep it for now since there's already content out in the wild relying on this behavior. r? @jdm @asajeffrey
Always trigger an input sources change event on session creation Fixes our behavior to match the spec, and to specifically do it in a way that makes sense. This is also what Chromium does currently, though I'm not sure if it does the scheduling the same way. The spec for this may change, see immersive-web/webxr#961. This fix, along with #25770 , makes three.js content work on servo. Instead of this fix we can also wait for mrdoob/three.js#18638 to land (which isn't certain until we figure out more about immersive-web/webxr#961 ) Even if immersive-web/webxr#961 decides to choose the option that obviates this patch, we should probably keep it for now since there's already content out in the wild relying on this behavior. r? @jdm @asajeffrey
cc @cabanier oculus browser may also have this race, worth looking into |
Thanks! I will take a look |
@Manishearth Is the issue that the |
Yes, because there's a gap between when the session sets up its resources and when |
If the event was missed, the list of controllers should not be empty. There should be a note in the spec to clarify this behavior. |
Right, threejs is currently incorrect by making this assumption. Our options are:
I slightly prefer the second option because the failure mode of (1) is a very subtle race and I'm not certain that authors will notice it. But I'm down for any of these options, I just want us to do something |
I don't quite follow. Can you elaborate what would be the spec change? |
The spec change would be to:
The reason I'd like to make the change is that given that Chrome never starts off with input sources attached based on their architecture (but may have a rare race condition around it), authors may assume this to always be the case, and I'd like to avoid the pit of failure by asking user agents to implement this robustly. |
@cabanier any thoughts? should we go with allowing the array to start empty, or tweaking the spec as listed above to be more robust? I can try and write a PR for it. |
I think we should tweak the spec. |
https://immersive-web.github.io/webxr/#list-of-active-xr-input-sources
This means that if the device already has input sources connected from the start, it needs to immediately fire an
inputsourceschange
event after the session is created. Threejs relies on this happening.However, there's a period of time in which the session exists but is not yet available to user code (when the promise hasn't been resolved yet, or the promise has resolved and the resolution microtasks haven't triggered yet). In such a scenario, firing an
inputsourceschange
event is not useful since nothing can catch it. The current design of the spec seems to have a bit of a pit of failure where codebases can reasonably assume that all input sources will arrive through aninputsourceschange
event, but it is technically legal for implementors to fire these events before JS code is practically able to catch it.I feel like we should either:
requestSession()
algorithmServo currently does the former, but that's currently incorrect. Chrome seems to be doing the latter, but it's not explicit, so it might be possible that there's actually a race there.
cc @alcooper91
The text was updated successfully, but these errors were encountered: