-
Notifications
You must be signed in to change notification settings - Fork 386
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
Document events on window
#23
Comments
Comment by cvan 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 |
Comment by mkeblx When would the most appropriate time to trigger |
Comment by toji 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! |
Comment by toji Whoops! Wrong button! Don't mind me! |
Comment by cvan @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? |
Comment by toji @cvan: What I meant was that the event should fire when the event listener is added (as in: |
Comment by cvan 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 ( |
Comment by mkeblx How big an issue is a library or previous registered handling stealing? Is it important to ensure that all |
Comment by cvan 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:
|
Comment by toji @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. |
Comment by cvan 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. |
Comment by mkeblx The issue is when the |
Comment by cvan
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 |
Comment by luser 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 |
@toji can we spec for these events to fire detail of the corresponding first mentioned here - but wanted to bring it up again here. |
I don't see why not. |
We should spec when users can expect these events (e.g., |
One way to do this is using algorithms (rather than prose), including modification of existing algorithms. This can also help identify potential implementation or usability issues. However, the spec doesn't appear to follow this model currently. |
I'm going to file a separate issue for the timing, as the events have been documented (nit issue: #83): https://w3c.github.io/webvr/#interface-window |
Issue by cvan
Monday Feb 29, 2016 at 00:32 GMT
Originally opened as MozillaReality/webvr-spec#15
vrdisplayconnected
vrdisplaydisconnected
vrdisplaypresentchange
The text was updated successfully, but these errors were encountered: