diff --git a/Cargo.lock b/Cargo.lock index 5d9018aee268..8638425b4bff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3307,6 +3307,26 @@ dependencies = [ "vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "openxr" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", + "openxr-sys 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "shared_library 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "openxr-sys" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "ordered-float" version = "1.0.0" @@ -3331,7 +3351,7 @@ name = "osmesa-sys" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "shared_library 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "shared_library 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4558,7 +4578,7 @@ dependencies = [ [[package]] name = "shared_library" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4594,6 +4614,7 @@ dependencies = [ "libservo 0.0.1", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "servo-media 0.1.0 (git+https://github.com/servo/media)", + "webxr 0.0.1 (git+https://github.com/servo/webxr)", "webxr-api 0.0.1 (git+https://github.com/servo/webxr)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5671,7 +5692,7 @@ dependencies = [ [[package]] name = "webxr" version = "0.0.1" -source = "git+https://github.com/servo/webxr#f67b762424af7c75c0bbce817d0e55ff51baf4cc" +source = "git+https://github.com/servo/webxr#affa222d3c187f40ed3f6e91752f1f2e3f583dc6" dependencies = [ "bindgen 0.49.2 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5679,13 +5700,16 @@ dependencies = [ "gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)", "glutin 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "openxr 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "webxr-api 0.0.1 (git+https://github.com/servo/webxr)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "wio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "webxr-api" version = "0.0.1" -source = "git+https://github.com/servo/webxr#f67b762424af7c75c0bbce817d0e55ff51baf4cc" +source = "git+https://github.com/servo/webxr#affa222d3c187f40ed3f6e91752f1f2e3f583dc6" dependencies = [ "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5778,6 +5802,14 @@ dependencies = [ "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "wio" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "wr_malloc_size_of" version = "0.0.1" @@ -6150,6 +6182,8 @@ dependencies = [ "checksum opaque-debug 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "51ecbcb821e1bd256d456fe858aaa7f380b63863eab2eb86eee1bd9f33dd6682" "checksum openssl 0.10.11 (registry+https://github.com/rust-lang/crates.io-index)" = "6c24d3508b4fb6da175c10baac54c578b33f09c89ae90c6fe9788b3b4768efdc" "checksum openssl-sys 0.9.35 (registry+https://github.com/rust-lang/crates.io-index)" = "912f301a749394e1025d9dcddef6106ddee9252620e6d0a0e5f8d0681de9b129" +"checksum openxr 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bd30879fa0a4815c204a199a06f08826c892208e6d93617194bd5a9e0b12e9e0" +"checksum openxr-sys 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "875181a679f13b1b7c6b37b7f221c11a9cabc67a51399bc8051165d2c03a17a0" "checksum ordered-float 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e9a3c8db0fca1fdb34404f0b1286db252f23930b9f7a481e376c16c0d5c309d4" "checksum ordermap 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063" "checksum osmesa-src 0.1.0 (git+https://github.com/servo/osmesa-src)" = "" @@ -6241,7 +6275,7 @@ dependencies = [ "checksum servo_media_derive 0.1.0 (git+https://github.com/servo/media)" = "" "checksum sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68" "checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" -"checksum shared_library 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8254bf098ce4d8d7cc7cc6de438c5488adc5297e5b7ffef88816c0a91bd289c1" +"checksum shared_library 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11" "checksum shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" "checksum sig 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6567e29578f9bfade6a5d94a32b9a4256348358d2a3f448cab0021f9a02614a2" "checksum signpost 0.1.0 (git+https://github.com/pcwalton/signpost.git)" = "" @@ -6343,6 +6377,7 @@ dependencies = [ "checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba" "checksum winit 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d233301129ddd33260b47f76900b50e154b7254546e2edba0e5468a1a5fe4de3" "checksum winres 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "27d9192d6356d7efe8405dec6c5506b67543cf64b6049968f39f4c4623b4f25d" +"checksum wio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5d129932f4644ac2396cb456385cbf9e63b5b30c6e8dc4820bdca4eb082037a5" "checksum wr_malloc_size_of 0.0.1 (git+https://github.com/servo/webrender)" = "" "checksum ws 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ec91ea61b83ce033c43c06c52ddc7532f465c0153281610d44c58b74083aee1a" "checksum x11 2.17.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e5c4ac579b5d324dc4add02312b5d0e3e0218521e2d5779d526ac39ee4bb171" diff --git a/components/script/dom/xr.rs b/components/script/dom/xr.rs index 8deead58b92e..a6fb4057e2c7 100644 --- a/components/script/dom/xr.rs +++ b/components/script/dom/xr.rs @@ -156,10 +156,6 @@ impl XRMethods for XR { comp: InCompartment, ) -> Rc { let promise = Promise::new_in_current_compartment(&self.global(), comp); - if mode != XRSessionMode::Immersive_vr { - promise.reject_error(Error::NotSupported); - return promise; - } if self.pending_or_active_session() { promise.reject_error(Error::InvalidState); diff --git a/ports/libsimpleservo/api/Cargo.toml b/ports/libsimpleservo/api/Cargo.toml index 4bbdda8545e7..e0204f3ebb6e 100644 --- a/ports/libsimpleservo/api/Cargo.toml +++ b/ports/libsimpleservo/api/Cargo.toml @@ -10,7 +10,9 @@ publish = false libservo = { path = "../../../components/servo" } log = "0.4" servo-media = { git = "https://github.com/servo/media" } -webxr-api = { git = "https://github.com/servo/webxr" } + +webxr-api = { git = "https://github.com/servo/webxr", features = ["ipc"] } +webxr = { git = "https://github.com/servo/webxr" , optional = true} [target.'cfg(not(target_os = "macos"))'.dependencies] libc = "0.2" @@ -44,5 +46,5 @@ no_static_freetype = ["libservo/no_static_freetype"] no_wgl = ["libservo/no_wgl"] oculusvr = ["libservo/oculusvr"] webdriver = ["libservo/webdriver"] -uwp = ["libservo/uwp"] +uwp = ["libservo/uwp", "webxr", "webxr/openxr-api"] webgl_backtrace = ["libservo/webgl_backtrace"] diff --git a/ports/libsimpleservo/api/src/lib.rs b/ports/libsimpleservo/api/src/lib.rs index 93e078095ae8..e4b065a7b40d 100644 --- a/ports/libsimpleservo/api/src/lib.rs +++ b/ports/libsimpleservo/api/src/lib.rs @@ -189,8 +189,8 @@ pub fn init( gl.finish(); let window_callbacks = Rc::new(ServoWindowCallbacks { - gl: gl.clone(), host_callbacks: callbacks, + gl: gl.clone(), coordinates: RefCell::new(init_opts.coordinates), density: init_opts.density, gl_context_pointer: init_opts.gl_context_pointer, @@ -201,6 +201,7 @@ pub fn init( vr_init: init_opts.vr_init, xr_discovery: init_opts.xr_discovery, waker, + gl: gl.clone(), }); let servo = Servo::new(embedder_callbacks, window_callbacks.clone()); @@ -581,6 +582,8 @@ struct ServoEmbedderCallbacks { waker: Box, xr_discovery: Option>, vr_init: VRInitOptions, + #[allow(unused)] + gl: Rc, } struct ServoWindowCallbacks { @@ -611,6 +614,19 @@ impl EmbedderMethods for ServoEmbedderCallbacks { } } + #[cfg(feature = "uwp")] + fn register_webxr(&mut self, registry: &mut webxr_api::MainThreadRegistry) { + debug!("EmbedderMethods::register_xr"); + assert!( + self.xr_discovery.is_none(), + "UWP builds should not be initialized with a WebXR Discovery object" + ); + let gl = self.gl.clone(); + let discovery = webxr::openxr::OpenXrDiscovery::new(gl); + registry.register(discovery); + } + + #[cfg(not(feature = "uwp"))] fn register_webxr(&mut self, registry: &mut webxr_api::MainThreadRegistry) { debug!("EmbedderMethods::register_xr"); if let Some(discovery) = self.xr_discovery.take() { diff --git a/python/servo/build_commands.py b/python/servo/build_commands.py index 206d00250e67..76d75a0673bb 100644 --- a/python/servo/build_commands.py +++ b/python/servo/build_commands.py @@ -696,6 +696,12 @@ def package_generated_shared_libraries(libs, build_path, servo_exe_dir): if not package_gstreamer_dlls(env, servo_exe_dir, target_triple, uwp): status = 1 + if uwp: + # copy needed openxr DLLs in to servo.exe dir + print("Packaging openxr DLLs") + if not self.package_openxr_dlls(env, servo_exe_dir, target_triple): + status = 1 + # UWP app packaging already bundles all required DLLs for us. print("Packaging MSVC DLLs") if not package_msvc_dlls(servo_exe_dir, target_triple, vcinstalldir, vs_version): @@ -746,6 +752,29 @@ def clean(self, manifest_path=None, params=[], verbose=False): opts += params return check_call(["cargo", "clean"] + opts, env=self.build_env(), verbose=verbose) + def package_openxr_dlls(self, env, servo_exe_dir, target): + target_arch = target.split('-')[0] + if target_arch == "aarch64": + arch = "arm64" + elif target_arch == "x64": + arch = "x64" + else: + print("ERROR: We do not have openxr_loader DLLs for %s" % target_arch) + return False + + # The package on S3 contains both debug and release DLLs, but + # by default we only use release DLLs. If you need to debug OpenXR itself, + # change this to Debug. + dll_path = os.path.join(self.msvc_package_dir("openxr-loader-uwp"), arch, "Release", "openxr_loader.dll") + + try: + shutil.copy(dll_path, servo_exe_dir) + except: + print("ERROR: Could not find %s" % dll_path) + return False + + return True + def gstreamer_root(target, env): arch = { diff --git a/python/servo/packages.py b/python/servo/packages.py index 3fa2f036fb8a..1da0d49b13d0 100644 --- a/python/servo/packages.py +++ b/python/servo/packages.py @@ -9,4 +9,5 @@ "ninja": "1.7.1", "openssl": "111.3.0+1.1.1c-vs2017", "gstreamer-uwp": "1.16.0.3", + "openxr-loader-uwp": "1.0", } diff --git a/support/hololens/.gitignore b/support/hololens/.gitignore new file mode 100644 index 000000000000..83e187f2139a --- /dev/null +++ b/support/hololens/.gitignore @@ -0,0 +1,4 @@ +/Generated Files +ServoApp.vcxproj.user +bin +obj diff --git a/support/hololens/ServoApp/ServoApp.vcxproj b/support/hololens/ServoApp/ServoApp.vcxproj index 096a0a2510ee..df1d72a2ce61 100644 --- a/support/hololens/ServoApp/ServoApp.vcxproj +++ b/support/hololens/ServoApp/ServoApp.vcxproj @@ -173,6 +173,9 @@ Designer + + true + true @@ -188,6 +191,9 @@ true + + true + true @@ -221,6 +227,13 @@ true false + + true + true + false + true + false + true true @@ -236,6 +249,9 @@ true + + true + true diff --git a/support/hololens/ServoApp/ServoApp.vcxproj.filters b/support/hololens/ServoApp/ServoApp.vcxproj.filters index 836ab85c8582..134e6e7cc95e 100644 --- a/support/hololens/ServoApp/ServoApp.vcxproj.filters +++ b/support/hololens/ServoApp/ServoApp.vcxproj.filters @@ -90,6 +90,9 @@ Content + + DebugServoDLLs + DebugServoDLLs @@ -102,12 +105,18 @@ DebugServoDLLs + + ReleaseServoDLLs + ReleaseServoDLLs ReleaseServoDLLs + + DebugARM64ServoDLLs + DebugARM64ServoDLLs @@ -117,6 +126,9 @@ DebugARM64ServoDLLs + + ReleaseARM64ServoDLLs + ReleaseARM64ServoDLLs diff --git a/support/hololens/create-openxr-package.bat b/support/hololens/create-openxr-package.bat new file mode 100644 index 000000000000..67180b9b6097 --- /dev/null +++ b/support/hololens/create-openxr-package.bat @@ -0,0 +1,29 @@ +REM USAGE +REM Clone https://github.com/microsoft/OpenXR-SDK-VisualStudio, open the openxr_loader_uwp project +REM Change the project output type to a dynamic library +REM Build it for Debug/Release x64/ARM64 +REM create-openxr-package path\to\outputdir path\to\OpenXR-SDK-VisualStudio +REM name the outputdir openxr-loader-uwp-versionnumber and zip it + +cd %1 +mkdir arm64 +mkdir arm64\Debug +cd arm64\Debug +copy %2\bin\Debug\ARM64\openxr_loader_uwp\* . +ren *.* openxr_loader.* +cd .. +mkdir Release +cd Release +copy %2\bin\Release\ARM64\openxr_loader_uwp\* . +ren *.* openxr_loader.* +cd ..\.. +mkdir x64 +mkdir x64\Debug +cd x64\Debug +copy %2\bin\Debug\x64\openxr_loader_uwp\* . +ren *.* openxr_loader.* +cd .. +mkdir Release +cd Release +copy %2\bin\Release\x64\openxr_loader_uwp\* . +ren *.* openxr_loader.* \ No newline at end of file diff --git a/tests/wpt/metadata/webxr/xrSession_requestReferenceSpace_features.https.html.ini b/tests/wpt/metadata/webxr/xrSession_requestReferenceSpace_features.https.html.ini index 84a5e1496a83..4f55ce355842 100644 --- a/tests/wpt/metadata/webxr/xrSession_requestReferenceSpace_features.https.html.ini +++ b/tests/wpt/metadata/webxr/xrSession_requestReferenceSpace_features.https.html.ini @@ -26,9 +26,6 @@ [Non-immersive session supports local space when required] expected: FAIL - [Non-immersive session supports viewer space by default] - expected: FAIL - [Non-immersive session rejects local space if not requested] expected: FAIL diff --git a/tests/wpt/metadata/webxr/xrSession_viewer_referenceSpace.https.html.ini b/tests/wpt/metadata/webxr/xrSession_viewer_referenceSpace.https.html.ini index b6af7d5f9057..47ad34657e11 100644 --- a/tests/wpt/metadata/webxr/xrSession_viewer_referenceSpace.https.html.ini +++ b/tests/wpt/metadata/webxr/xrSession_viewer_referenceSpace.https.html.ini @@ -2,6 +2,3 @@ [Identity reference space provides correct poses for immersive sessions] expected: FAIL - [Identity reference space provides correct poses for inline sessions] - expected: FAIL - diff --git a/tests/wpt/metadata/webxr/xrWebGLLayer_constructor.https.html.ini b/tests/wpt/metadata/webxr/xrWebGLLayer_constructor.https.html.ini index f9f55152f51a..08a51f5b1bcc 100644 --- a/tests/wpt/metadata/webxr/xrWebGLLayer_constructor.https.html.ini +++ b/tests/wpt/metadata/webxr/xrWebGLLayer_constructor.https.html.ini @@ -1,4 +1,5 @@ [xrWebGLLayer_constructor.https.html] + expected: ERROR [Ensure that XRWebGLLayer's constructor throws appropriate errors] - expected: FAIL + expected: TIMEOUT