Skip to content
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

Preliminary WebXR support #22528

Merged
merged 25 commits into from
Jan 4, 2019
Merged

Preliminary WebXR support #22528

merged 25 commits into from
Jan 4, 2019

Conversation

Manishearth
Copy link
Member

@Manishearth Manishearth commented Dec 22, 2018

This implements just enough WebXR to display to 3DOF devices in
immersive mode only.

Couple missing things:

Once I add spec links and pref gating this can be landed as-is for further experimentation.

r? @jdm @MortimerGoro


This change is Reviewable

@highfive
Copy link

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/webidls/XRSession.webidl, components/script/dom/navigator.rs, components/script/dom/webidls/XRViewport.webidl, components/script/dom/vrdisplay.rs, components/script/dom/webidls/XRStationaryReferenceSpace.webidl and 27 more
  • @KiChjang: components/script/dom/webidls/XRSession.webidl, components/script/dom/navigator.rs, components/script/dom/webidls/XRViewport.webidl, components/script/dom/vrdisplay.rs, components/script/dom/webidls/XRStationaryReferenceSpace.webidl and 27 more

@highfive
Copy link

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
  • These commits modify script code, but no tests are modified. Please consider adding a test!

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Dec 22, 2018
[NoInterfaceObject]
interface VR {
[Pref="dom.webvr.enabled"]
Promise<sequence<VRDisplay>> getDisplays();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not clear to me that eliminating WebVR from our implementation is the right choice right now. It's useful to test against the existing WebVR content.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not! navigator.vr is old WebVR (it's not in the spec anymore). I still support navigator.getVRDisplays() which is the new thing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just found it convenient to repurpose the VR object as XR since it has the same purpose and I didn't want to duplicate the messaging/syncing logic

@Manishearth
Copy link
Member Author

Oh, also, one departure from the spec: we don't support FrozenArray and attributes can't be sequences so currently the views attribute is a function.

I might try to make it use any instead so that it works the same.

Copy link
Contributor

@MortimerGoro MortimerGoro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

Code looks good on first pass.


// https://immersive-web.github.io/webxr/#xrframe-interface

[SecureContext, Exposed=Window] interface XRFrame {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new XR interfaces should be behind a pref [Pref="dom.webxr.enabled"]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I'd mentioned in the PR title that this was missing 😄


callback XRFrameRequestCallback = void (DOMHighResTimeStamp time, XRFrame frame);

[SecureContext, Exposed=Window] interface XRSession : EventTarget {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Pref="dom.webxr.enabled"] and in other new interfaces

@@ -266,6 +268,7 @@ impl WebGLRenderingContext {
pub fn recreate(&self, size: Size2D<u32>) {
let (sender, receiver) = webgl_channel().unwrap();
self.webgl_sender.send_resize(size, sender).unwrap();
self.size.set(size);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we guarantee that rust-offscreen-rendering-context is going to respect this size? There may be some corner cases such as JS requesting a larger size than the maximum allowed by the GPU. We can check with the existing webgl tests.

If we can guarantee this size you can also optimize DrawingBufferWidth() and DrawingBufferHeigh()

Copy link
Member Author

@Manishearth Manishearth Dec 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe when that happens it just doesn't work (throwing a GL error). At least, when I was playing with this in Firefox with Pathfinder that was the case, there's a limit to the texture size.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The webgl implementation is allowed to choose a smaller size than what is requested; Servo's implementation does not right now and panics, #21718 tracks implementing this correctly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it enough to just drop a comment linking to that since that's not implemented yet?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

@bors-servo
Copy link
Contributor

☀️ Test successful - linux-rel-css, linux-rel-wpt, status-taskcluster
State: approved= try=True

@Manishearth
Copy link
Member Author

@bors-servo try- r=jdm,MortimerGoro

@bors-servo
Copy link
Contributor

📌 Commit fc69cd3 has been approved by jdm,MortimerGoro

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Jan 4, 2019
@bors-servo
Copy link
Contributor

⌛ Testing commit fc69cd3 with merge be035df...

bors-servo pushed a commit that referenced this pull request Jan 4, 2019
Preliminary WebXR support

This implements just enough WebXR to display to 3DOF devices in
immersive mode only.

Couple missing things:

 - [ ] Handling reference spaces (even if just supporting eye-level spaces)
 - [x] Spec links
 - [ ] We enter immersive mode when baseLayer is set, but it seems like
we're supposed to do this when requestSession is called (immersive-web/webxr#453)
 - [ ] VR/XR should block less (#22505)
 - [x] More pref-gating
 - [x] `views` is a method instead of an attribute because we don't support FrozenArray

<s>Once I add spec links and pref gating</s> this can be landed as-is for further experimentation.

r? @jdm @MortimerGoro

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22528)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

💔 Test failed - status-taskcluster

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Jan 4, 2019
@jdm
Copy link
Member

jdm commented Jan 4, 2019

Diff in /home/travis/build/servo/servo/components/script/dom/xrwebgllayer.rs at line 18:
 use crate::dom::xrviewport::XRViewport;
 use dom_struct::dom_struct;
 
-
 #[dom_struct]
 pub struct XRWebGLLayer {
     xrlayer: XRLayer,
Run `./mach fmt` to fix the formatting

@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels Jan 4, 2019
@Manishearth
Copy link
Member Author

@bors-servo r=jdm,MortimerGoro

@bors-servo
Copy link
Contributor

📌 Commit e544462 has been approved by jdm,MortimerGoro

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Jan 4, 2019
@bors-servo
Copy link
Contributor

⌛ Testing commit e544462 with merge c4a6dcf...

bors-servo pushed a commit that referenced this pull request Jan 4, 2019
Preliminary WebXR support

This implements just enough WebXR to display to 3DOF devices in
immersive mode only.

Couple missing things:

 - [ ] Handling reference spaces (even if just supporting eye-level spaces)
 - [x] Spec links
 - [ ] We enter immersive mode when baseLayer is set, but it seems like
we're supposed to do this when requestSession is called (immersive-web/webxr#453)
 - [ ] VR/XR should block less (#22505)
 - [x] More pref-gating
 - [x] `views` is a method instead of an attribute because we don't support FrozenArray

<s>Once I add spec links and pref gating</s> this can be landed as-is for further experimentation.

r? @jdm @MortimerGoro

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22528)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

☀️ Test successful - android-mac, arm32, arm64, linux-rel-css, linux-rel-wpt, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, magicleap, status-taskcluster
Approved by: jdm,MortimerGoro
Pushing c4a6dcf to master...

@bors-servo bors-servo merged commit e544462 into servo:master Jan 4, 2019
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jan 4, 2019
@Manishearth Manishearth deleted the webxr branch January 4, 2019 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants