Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upUWP app panics when shutting down with active webgl #23778
Closed
Labels
Projects
Comments
|
This is in a build with #23777 applied. |
|
Turns out that Servo::~Servo is never invoked, so the embedding deinitialization never occurs. |
|
There are a few reasons I see that this occurs:
|
|
The following patch fixes the webrender panic: commit 8a4e21df929cd078b2a031a638d4ed51f239e75b
Author: Josh Matthews <josh@joshmatthews.net>
Date: Wed Jul 17 10:40:20 2019 -0400
Deinitialize Servo on app suspend.
diff --git a/support/hololens/App.xaml.cpp b/support/hololens/App.xaml.cpp
index e084de34b4..938742d000 100644
--- a/support/hololens/App.xaml.cpp
+++ b/support/hololens/App.xaml.cpp
@@ -6,10 +6,17 @@
#include "App.xaml.h"
using namespace hlservo;
+using namespace Windows::ApplicationModel;
+using namespace Windows::ApplicationModel::Activation;
+using namespace Windows::Foundation;
+using namespace Windows::Storage;
+using namespace Windows::UI::Xaml;
App::App()
{
InitializeComponent();
+ Suspending += ref new SuspendingEventHandler(this, &App::OnSuspending);
+ Resuming += ref new EventHandler<Object^>(this, &App::OnResuming);
}
void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs ^ e)
@@ -27,3 +34,31 @@ void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEvent
Windows::UI::Xaml::Window::Current->Content = mPage;
Windows::UI::Xaml::Window::Current->Activate();
}
+
+/// <summary>
+/// Invoked when application execution is being suspended. Application state is saved
+/// without knowing whether the application will be terminated or resumed with the contents
+/// of memory still intact.
+/// </summary>
+/// <param name="sender">The source of the suspend request.</param>
+/// <param name="e">Details about the suspend request.</param>
+void App::OnSuspending(Object^ sender, SuspendingEventArgs^ e)
+{
+ (void)sender; // Unused parameter
+ (void)e; // Unused parameter
+
+ mPage->SaveInternalState(ApplicationData::Current->LocalSettings->Values);
+}
+
+/// <summary>
+/// Invoked when application execution is being resumed.
+/// </summary>
+/// <param name="sender">The source of the resume request.</param>
+/// <param name="args">Details about the resume request.</param>
+void App::OnResuming(Object ^sender, Object ^args)
+{
+ (void)sender; // Unused parameter
+ (void)args; // Unused parameter
+
+ mPage->LoadInternalState(ApplicationData::Current->LocalSettings->Values);
+}
\ No newline at end of file
diff --git a/support/hololens/App.xaml.h b/support/hololens/App.xaml.h
index 4c109377d4..e305469220 100644
--- a/support/hololens/App.xaml.h
+++ b/support/hololens/App.xaml.h
@@ -13,6 +13,9 @@ ref class App sealed {
public:
App();
virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs ^ e) override;
+private:
+ void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ e);
+ void OnResuming(Platform::Object ^sender, Platform::Object ^args);
private:
OpenGLESPage ^ mPage;
diff --git a/support/hololens/OpenGLESPage.xaml.cpp b/support/hololens/OpenGLESPage.xaml.cpp
index c4c7dd21e3..fc7f87c647 100644
--- a/support/hololens/OpenGLESPage.xaml.cpp
+++ b/support/hololens/OpenGLESPage.xaml.cpp
@@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+#include <atomic>
#include "pch.h"
#include "OpenGLESPage.xaml.h"
#include "Servo.h"
@@ -10,6 +11,7 @@ using namespace hlservo;
using namespace Platform;
using namespace Concurrency;
using namespace Windows::Foundation;
+using namespace Windows::Foundation::Collections;
static char sWakeupEvent[] = "SIGNAL_WAKEUP";
@@ -118,9 +120,9 @@ void OpenGLESPage::StartRenderLoop()
EGLint panelHeight = 0;
mOpenGLES->GetSurfaceDimensions(mRenderSurface, &panelWidth, &panelHeight);
glViewport(0, 0, panelWidth, panelHeight);
- mServo = new Servo(panelWidth, panelHeight);
+ mServo.reset(new Servo(panelWidth, panelHeight));
- while (action->Status == Windows::Foundation::AsyncStatus::Started) {
+ while (action->Status == Windows::Foundation::AsyncStatus::Started && !mTerminate.load()) {
// Block until Servo::sWakeUp is called.
// Or run full speed if animating (see on_animating_changed),
// it will endup blocking on SwapBuffers to limit rendering to 60FPS
@@ -129,6 +131,8 @@ void OpenGLESPage::StartRenderLoop()
}
mServo->PerformUpdates();
}
+
+ mServo.reset(nullptr);
};
auto workItemHandler = ref new Windows::System::Threading::WorkItemHandler(loop);
@@ -147,8 +151,29 @@ void OpenGLESPage::StartRenderLoop()
void OpenGLESPage::StopRenderLoop()
{
+ mTerminate.store(true);
+ Servo::sWakeUp();
if (mRenderLoopWorker) {
mRenderLoopWorker->Cancel();
mRenderLoopWorker = nullptr;
}
}
+
+// Saves the current state of the app for suspend and terminate events.
+void OpenGLESPage::SaveInternalState(IPropertySet^ state)
+{
+ // Stop rendering when the app is suspended.
+ StopRenderLoop();
+
+ // Put code to save app state here.
+}
+
+// Loads the current state of the app for resume events.
+void OpenGLESPage::LoadInternalState(IPropertySet^ state)
+{
+ // Put code to load app state here.
+
+ // Start rendering when the app is resumed.
+ StartRenderLoop();
+}
+
diff --git a/support/hololens/OpenGLESPage.xaml.h b/support/hololens/OpenGLESPage.xaml.h
index ab2c8c2fd8..1749304d65 100644
--- a/support/hololens/OpenGLESPage.xaml.h
+++ b/support/hololens/OpenGLESPage.xaml.h
@@ -4,6 +4,7 @@
#pragma once
+#include <atomic>
#include "OpenGLES.h"
#include "OpenGLESPage.g.h"
#include "Servo.h"
@@ -17,6 +18,9 @@ public:
internal : OpenGLESPage(OpenGLES* openGLES);
+ void SaveInternalState(Windows::Foundation::Collections::IPropertySet^ state);
+ void LoadInternalState(Windows::Foundation::Collections::IPropertySet^ state);
+
private:
void OnPageLoaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
void OnVisibilityChanged(Windows::UI::Core::CoreWindow ^ sender,
@@ -32,6 +36,7 @@ private:
EGLSurface mRenderSurface;
Concurrency::critical_section mRenderSurfaceCriticalSection;
Windows::Foundation::IAsyncAction ^ mRenderLoopWorker;
- Servo* mServo;
+ std::unique_ptr<Servo> mServo;
+ std::atomic<bool> mTerminate;
};
}I'll hold off submitting it while #23790 is open, since it will require porting these changes to the new model. |
|
Fixed by #23866. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's an assertion in the webrender GL device's Drop impl that "renderer::deinit was not called":