-
Notifications
You must be signed in to change notification settings - Fork 19
Document events on window
#15
Comments
The spec doesn't yet go into depth yet about the events. But the Web IDL is here. It was brought up earlier (and in this comment by @ashconnell), I actually like the idea of passing detail about the VR display in the event. That way you don't have to look things up on I'd like to suggest adding a Let's take a look at two examples of other Web APIs that have similar events: Fullscreen APIFWIW, the Fullscreen API spec doesn't describe any custom event data to be passed. In the vendor-prefixed, non-Promise-based versions of the Fullscreen API implemented in Firefox and Chrome today, the Gamepad APIThe Gamepad API spec defines two events |
When would the most appropriate time to trigger |
We need to get some more explicit text into the spec about this, but I think in general the pattern seen in the Gamepad API is applicable here. In that API gamepadconnected is fired as soon as a device receives a user gesture, even if it was already technically connected beforehand. Applying that to WebVR, since we're not gating device access on any sort of user action, it seems logical that if a VRDisplay is available when the "vrdisplayconnected" listener is registered it should immediately fire, and thereafter only fire when new devices are connected. Not sure if it should fire every time a listener is added, or only once per page, though. Once per page seems more sane, but also means that libraries you use can "steal" the event from you without you knowing it, simply by registering first. I'd love @kearwood's input on this as well! |
Whoops! Wrong button! Don't mind me! |
@toji I like this. I know in Chrome the Gamepad wouldn't show up in For WebVR, per this discussion in issue #22, if we plan on adding a permission check (using the Permissions API) for querying VR devices, for I like this behaviour because it means I can rely on
@toji: what do you mean "if a VRDisplay is available when the 'vrdisplayconnected' listener is registered"? Do you literally mean if the developer called IMO, connected/disconnected events offer a very nice option for developers to handle VR support and state. It also means developers wouldn't need to call In conclusion, I recommend either introducing a permission to the Permission API for "querying VR displays" (i.e., Thoughts? |
@cvan: What I meant was that the event should fire when the event listener is added (as in: |
Oh, that's what you mean. Gotcha, I like that. I just looked at the Chromium source; I didn't know the So, as you know, the Gamepad API implementations in Firefox and Chromium were also slightly different in several ways. I did some testing, and I found a few more inconsistencies I wasn't already aware of. If a gamepad is connected and there's a
Anyway, I know there were discussions on the Gamepad mailing list, Bugzilla + Chromium bugs, and a couple spec issues filed for related issues (e.g., w3c/gamepad/issues#4, w3c/gamepad/issues#8, w3c/gamepad/issues#10). I should probably move this discussion to the w3c/gamepad repo and file Chromium and Firefox bugs. But since we need to follow a similar pattern for the WebVR APIs ( |
How big an issue is a library or previous registered handling stealing? Is it important to ensure that all |
Perhaps I'm misunderstanding the issues at hand here, but IMO the browser should engage querying for VR devices when at least one of the following criteria is satisfied:
|
@mkeblx: The case I'm concerned about is a page which relies on "vrdisplayconnected" to show things like an "Enter VR" button. If they register that even fairly late in the page load but some third party library (Modernizr seems like a logical one?) has registered the same event will the library get the event and the users script never see it? In that case it sounds like the right solution is to always call getVRDisplays on startup to get the initial list and then install the listener to see updates. Not a terrible pattern, but I doubt developers will follow it rigorously. |
First, do we ever plan on adding a permission to call
Is that an issue though? You can have multiple event listeners for Maybe you aren't talking about exactly a "Modernizr" detection script for WebVR (which I'll file an issue for, btw). But, fwiw, this is how the Gamepad API is detected. How is this different from having And what if the third-party script calls
I don't know - it seems like a roundabout way of identifying intent IMO. |
The issue is when the |
Per my comment above, Firefox fires the Interestingly, the Gamepad API implementation on Windows (xinput) in Firefox actually requires a gamepad gesture (button press, axis move), and only then, will it emit a If we do figure out a sane signal for identifying user intent for interacting with the WebVR APIs, we should do the same with the Gamepad API. I understand gating it on I like firing events on |
So it's kind of late but a couple of points:
The events are very useful from an API ergonomics perspective--handling them is much simpler than polling to detect new devices. Polling for new data is OK, although for the Gamepad API we would like to spec events for input data as well (and Firefox has non-standard |
Moved to immersive-web/webxr#23 |
vrdisplayconnected
vrdisplaydisconnected
vrdisplaypresentchange
The text was updated successfully, but these errors were encountered: