aboutsummaryrefslogtreecommitdiffstats
path: root/support
diff options
context:
space:
mode:
Diffstat (limited to 'support')
-rw-r--r--support/hololens/ServoApp/App.cpp8
-rw-r--r--support/hololens/ServoApp/Package.appxmanifest2
-rw-r--r--support/hololens/ServoApp/ServoControl/Servo.cpp45
-rw-r--r--support/hololens/ServoApp/ServoControl/Servo.h1
4 files changed, 52 insertions, 4 deletions
diff --git a/support/hololens/ServoApp/App.cpp b/support/hololens/ServoApp/App.cpp
index a505da34d5a..22b6f4586f4 100644
--- a/support/hololens/ServoApp/App.cpp
+++ b/support/hololens/ServoApp/App.cpp
@@ -103,10 +103,14 @@ void App::OnActivated(IActivatedEventArgs const &args) {
}
void App::OnSuspending(IInspectable const &, SuspendingEventArgs const &) {
- auto content = Window::Current().Content();
+ // FIXME: Apps can be suspended for various reasons, not just closing them.
+ // * Figure out how to save state like the current URL so it can be
+ // restored if necessary.
+ // * Determine if the user has actually closed the app and shutdown.
+ /*auto content = Window::Current().Content();
Frame rootFrame = content.try_as<Frame>();
auto page = rootFrame.Content().try_as<BrowserPage>();
- page->Shutdown();
+ page->Shutdown();*/
}
void App::OnNavigationFailed(IInspectable const &,
diff --git a/support/hololens/ServoApp/Package.appxmanifest b/support/hololens/ServoApp/Package.appxmanifest
index 5ada19983d7..26091d47f0a 100644
--- a/support/hololens/ServoApp/Package.appxmanifest
+++ b/support/hololens/ServoApp/Package.appxmanifest
@@ -9,7 +9,7 @@
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
- <PackageDependency Name="Microsoft.WindowsMixedReality.Runtime" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" MinVersion="0.0.1.0" />
+ <PackageDependency Name="Microsoft.WindowsMixedReality.Runtime" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" MinVersion="100.2004.3007.0"/>
</Dependencies>
<Resources>
<Resource Language="x-generate" />
diff --git a/support/hololens/ServoApp/ServoControl/Servo.cpp b/support/hololens/ServoApp/ServoControl/Servo.cpp
index 76753d0758f..17c86f17271 100644
--- a/support/hololens/ServoApp/ServoControl/Servo.cpp
+++ b/support/hololens/ServoApp/ServoControl/Servo.cpp
@@ -36,6 +36,10 @@ void on_animating_changed(bool aAnimating) {
}
void on_panic(const char *backtrace) {
+ if (sLogHandle != INVALID_HANDLE_VALUE) {
+ CloseHandle(sLogHandle);
+ sLogHandle = INVALID_HANDLE_VALUE;
+ }
throw hresult_error(E_FAIL, char2hstring(backtrace));
}
@@ -86,6 +90,23 @@ void on_devtools_started(Servo::DevtoolsServerState result,
result == Servo::DevtoolsServerState::Started, port);
}
+void on_log_output(const char *buffer, uint32_t buffer_length) {
+ OutputDebugStringA(buffer);
+
+ if (sLogHandle == INVALID_HANDLE_VALUE) {
+ return;
+ }
+
+ DWORD bytesWritten;
+ auto writeResult =
+ WriteFile(sLogHandle, buffer, buffer_length, &bytesWritten, nullptr);
+
+ if (writeResult == FALSE || bytesWritten != buffer_length)
+ throw std::runtime_error(
+ "Failed to write log message to the log file: error code " +
+ std::to_string(GetLastError()));
+}
+
Servo::PromptResult prompt_ok_cancel(const char *message, bool trusted) {
return sServo->Delegate().OnServoPromptOkCancel(char2hstring(message),
trusted);
@@ -109,6 +130,7 @@ const char *prompt_input(const char *message, const char *default,
Servo::Servo(hstring url, hstring args, GLsizei width, GLsizei height,
float dpi, ServoDelegate &aDelegate)
: mWindowHeight(height), mWindowWidth(width), mDelegate(aDelegate) {
+ SetEnvironmentVariableA("PreviewRuntimeEnabled", "1");
capi::CInitOptions o;
hstring defaultPrefs = L" --pref dom.webxr.enabled --devtools";
@@ -140,6 +162,22 @@ 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()));
+#endif
+
capi::CHostCallbacks c;
c.flush = &flush;
c.make_current = &make_current;
@@ -163,13 +201,18 @@ Servo::Servo(hstring url, hstring args, GLsizei width, GLsizei height,
c.prompt_input = &prompt_input;
c.on_devtools_started = &on_devtools_started;
c.show_context_menu = &show_context_menu;
+ c.on_log_output = &on_log_output;
capi::register_panic_handler(&on_panic);
capi::init_with_egl(o, &wakeup, c);
}
-Servo::~Servo() { sServo = nullptr; }
+Servo::~Servo() {
+ sServo = nullptr;
+ if (sLogHandle != INVALID_HANDLE_VALUE)
+ CloseHandle(sLogHandle);
+}
winrt::hstring char2hstring(const char *c_str) {
// FIXME: any better way of doing this?
diff --git a/support/hololens/ServoApp/ServoControl/Servo.h b/support/hololens/ServoApp/ServoControl/Servo.h
index 7b3b3b00ed3..ccc8c1efa06 100644
--- a/support/hololens/ServoApp/ServoControl/Servo.h
+++ b/support/hololens/ServoApp/ServoControl/Servo.h
@@ -119,5 +119,6 @@ protected:
// pointer as callback in Servo, and these functions need a way to get
// the Servo instance. See https://github.com/servo/servo/issues/22967
static Servo *sServo = nullptr;
+static HANDLE sLogHandle = INVALID_HANDLE_VALUE;
} // namespace winrt::servo