diff --git a/Cargo.lock b/Cargo.lock index 06355787840..c73fba7b4c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6422,7 +6422,7 @@ dependencies = [ [[package]] name = "webxr" version = "0.0.1" -source = "git+https://github.com/servo/webxr#836a08e1168e3a2b0b0fa12d7987603d5fc79002" +source = "git+https://github.com/servo/webxr#6ead41b15b0c72ef8bd98af0c09f4fefec888aac" dependencies = [ "android_injected_glue", "bindgen", @@ -6445,7 +6445,7 @@ dependencies = [ [[package]] name = "webxr-api" version = "0.0.1" -source = "git+https://github.com/servo/webxr#836a08e1168e3a2b0b0fa12d7987603d5fc79002" +source = "git+https://github.com/servo/webxr#6ead41b15b0c72ef8bd98af0c09f4fefec888aac" dependencies = [ "euclid", "ipc-channel", diff --git a/components/script/dom/xrsystem.rs b/components/script/dom/xrsystem.rs index 0fc4ab108e2..a2ba7946e62 100644 --- a/components/script/dom/xrsystem.rs +++ b/components/script/dom/xrsystem.rs @@ -267,7 +267,8 @@ impl XRSystem { ) { let session = match response { Ok(session) => session, - Err(_) => { + Err(e) => { + warn!("Error requesting XR session: {:?}", e); if mode != XRSessionMode::Inline { self.pending_immersive_session.set(false); } diff --git a/ports/libsimpleservo/api/src/lib.rs b/ports/libsimpleservo/api/src/lib.rs index afd2dd89cc2..02177e90233 100644 --- a/ports/libsimpleservo/api/src/lib.rs +++ b/ports/libsimpleservo/api/src/lib.rs @@ -810,7 +810,7 @@ impl EmbedderMethods for ServoEmbedderCallbacks { } struct GlThread(WebGlExecutor); - impl webxr::openxr::GlThread for GlThread { + impl openxr::GlThread for GlThread { fn execute(&self, runnable: Box) { let _ = self.0.send(runnable); } @@ -819,12 +819,27 @@ impl EmbedderMethods for ServoEmbedderCallbacks { } } - let discovery = webxr::openxr::OpenXrDiscovery::new( - Box::new(GlThread(executor)), - Box::new(ProviderRegistration(surface_providers)), - Box::new(ContextMenuCallback(embedder_proxy)), - ); - registry.register(discovery); + if openxr::create_instance().is_ok() { + let discovery = openxr::OpenXrDiscovery::new( + Box::new(GlThread(executor)), + Box::new(ProviderRegistration(surface_providers)), + Box::new(ContextMenuCallback(embedder_proxy)), + ); + registry.register(discovery); + } else { + let msg = + "Cannot initialize OpenXR - please ensure runtime is installed and enabled in \ + the OpenXR developer portal app.\n\nImmersive mode will not function until \ + this error is fixed."; + let (sender, _receiver) = ipc::channel().unwrap(); + embedder_proxy.send(( + None, + EmbedderMsg::Prompt( + PromptDefinition::Alert(msg.to_owned(), sender), + PromptOrigin::Trusted, + ), + )); + } } #[cfg(not(feature = "uwp"))] diff --git a/support/hololens/ServoApp/ServoControl/Servo.cpp b/support/hololens/ServoApp/ServoControl/Servo.cpp index 2502ddad06b..83d926087fb 100644 --- a/support/hololens/ServoApp/ServoControl/Servo.cpp +++ b/support/hololens/ServoApp/ServoControl/Servo.cpp @@ -161,21 +161,31 @@ Servo::Servo(hstring url, hstring args, GLsizei width, GLsizei height, sServo = this; // FIXME; -#ifdef _DEBUG - auto current = winrt::Windows::Storage::ApplicationData::Current(); - auto filePath = std::wstring(current.LocalFolder().Path()) + L"\\stdout.txt"; - sLogHandle = - CreateFile2(filePath.c_str(), GENERIC_WRITE, 0, CREATE_ALWAYS, nullptr); - if (sLogHandle == INVALID_HANDLE_VALUE) - throw std::runtime_error("Failed to open the log file: error code " + - std::to_string(GetLastError())); - - if (SetFilePointer(sLogHandle, 0, nullptr, FILE_END) == - INVALID_SET_FILE_POINTER) - throw std::runtime_error( - "Failed to set file pointer to the end of file: error code " + - std::to_string(GetLastError())); +#ifndef _DEBUG + char buffer[1024]; + bool logToFile = GetEnvironmentVariableA("FirefoxRealityLogStdout", buffer, + sizeof(buffer)) != 0; +#else + bool logToFile = true; #endif + if (logToFile) { + auto current = winrt::Windows::Storage::ApplicationData::Current(); + auto filePath = + std::wstring(current.LocalFolder().Path()) + L"\\stdout.txt"; + sLogHandle = + CreateFile2(filePath.c_str(), GENERIC_WRITE, 0, CREATE_ALWAYS, nullptr); + if (sLogHandle == INVALID_HANDLE_VALUE) { + throw std::runtime_error("Failed to open the log file: error code " + + std::to_string(GetLastError())); + } + + if (SetFilePointer(sLogHandle, 0, nullptr, FILE_END) == + INVALID_SET_FILE_POINTER) { + throw std::runtime_error( + "Failed to set file pointer to the end of file: error code " + + std::to_string(GetLastError())); + } + } capi::CHostCallbacks c; c.on_load_started = &on_load_started; diff --git a/support/hololens/ServoApp/ServoControl/ServoControl.cpp b/support/hololens/ServoApp/ServoControl/ServoControl.cpp index 9c5869d44e9..eae5016181c 100644 --- a/support/hololens/ServoApp/ServoControl/ServoControl.cpp +++ b/support/hololens/ServoApp/ServoControl/ServoControl.cpp @@ -453,10 +453,10 @@ ServoControl::PromptSync(hstring title, hstring message, hstring primaryButton, dialog.PrimaryButtonText(primaryButton); if (secondaryButton.has_value()) { - dialog.IsPrimaryButtonEnabled(true); + dialog.IsSecondaryButtonEnabled(true); dialog.SecondaryButtonText(*secondaryButton); } else { - dialog.IsPrimaryButtonEnabled(false); + dialog.IsSecondaryButtonEnabled(false); } auto titleBlock = Controls::TextBlock();