mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #26312 - jdm:webxr-debug, r=Manishearth
Provide feedback when OpenXR can't start - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #26213 - [x] These changes do not require tests because it's testing an edge case in an environment we can't test on CI
This commit is contained in:
commit
8c73fb997a
5 changed files with 52 additions and 26 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -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",
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<dyn FnOnce(&surfman::Device) + Send>) {
|
||||
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"))]
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue