Bug 951120 - Don't process native events on the main thread during xpcom shutdown in metro widget. r=bbondy

This commit is contained in:
Jim Mathies 2014-01-27 09:09:33 -06:00
parent 69cbc0bbff
commit 21f0fe30cc
3 changed files with 16 additions and 2 deletions

View File

@ -42,6 +42,7 @@ namespace winrt {
ComPtr<FrameworkView> sFrameworkView;
ComPtr<MetroApp> sMetroApp;
ComPtr<ICoreApplication> sCoreApp;
bool MetroApp::sGeckoShuttingDown = false;
////////////////////////////////////////////////////
// IFrameworkViewSource impl.
@ -109,6 +110,8 @@ MetroApp::ShutdownXPCOM()
sFrameworkView->ShutdownXPCOM();
}
MetroApp::sGeckoShuttingDown = true;
// Shut down xpcom
XRE_metroShutdown();

View File

@ -46,6 +46,8 @@ public:
void CoreExit();
void ShutdownXPCOM();
// Set when gecko enters xpcom shutdown.
static bool sGeckoShuttingDown;
// Shared pointers between framework and widget
static void SetBaseWidget(MetroWidget* aPtr);

View File

@ -324,8 +324,8 @@ MetroAppShell::InputEventsDispatched()
void
MetroAppShell::DispatchAllGeckoEvents()
{
// Only do this if requested
if (!sShouldPurgeThreadQueue) {
// Only do this if requested and when we're not shutting down
if (!sShouldPurgeThreadQueue || MetroApp::sGeckoShuttingDown) {
return;
}
@ -414,6 +414,15 @@ void
MetroAppShell::NativeCallback()
{
NS_ASSERTION(NS_IsMainThread(), "Native callbacks must be on the metro main thread");
// We shouldn't process native events during xpcom shutdown - this can
// trigger unexpected xpcom event dispatching for the main thread when
// the thread manager is in the process of shutting down non-main threads,
// resulting in shutdown hangs.
if (MetroApp::sGeckoShuttingDown) {
return;
}
NativeEventCallback();
}