From 114473c8ec3a10db6fe66ad70dad47b5fee29521 Mon Sep 17 00:00:00 2001 From: David Major Date: Wed, 23 May 2018 11:54:21 -0700 Subject: Bug 1458270: Clean up in the shutdown observer. r=milan a=jcristau --HG-- extra : amend_source : 7b1277a18a3ed4f441deef8b51cb4ec4dde614cc --- widget/GfxInfoBase.cpp | 18 ++++++++++++++++-- widget/GfxInfoBase.h | 1 + widget/GfxInfoX11.cpp | 8 ++++++-- widget/android/GfxInfo.cpp | 4 ++++ widget/cocoa/GfxInfo.mm | 4 ++++ widget/uikit/GfxInfo.cpp | 4 ++++ widget/windows/GfxInfo.cpp | 4 ++++ 7 files changed, 39 insertions(+), 4 deletions(-) (limited to 'widget') diff --git a/widget/GfxInfoBase.cpp b/widget/GfxInfoBase.cpp index c937f50999..e20de82771 100644 --- a/widget/GfxInfoBase.cpp +++ b/widget/GfxInfoBase.cpp @@ -43,6 +43,7 @@ using mozilla::MutexAutoLock; nsTArray* GfxInfoBase::mDriverInfo; bool GfxInfoBase::mDriverInfoObserverInitialized; +bool GfxInfoBase::mShutdownOccurred; // Observes for shutdown so that the child GfxDriverInfo list is freed. class ShutdownObserver : public nsIObserver @@ -62,11 +63,17 @@ public: delete GfxInfoBase::mDriverInfo; GfxInfoBase::mDriverInfo = nullptr; - for (uint32_t i = 0; i < DeviceFamilyMax; i++) + for (uint32_t i = 0; i < DeviceFamilyMax; i++) { delete GfxDriverInfo::mDeviceFamilies[i]; + GfxDriverInfo::mDeviceFamilies[i] = nullptr; + } - for (uint32_t i = 0; i < DeviceVendorMax; i++) + for (uint32_t i = 0; i < DeviceVendorMax; i++) { delete GfxDriverInfo::mDeviceVendors[i]; + GfxDriverInfo::mDeviceVendors[i] = nullptr; + } + + GfxInfoBase::mShutdownOccurred = true; return NS_OK; } @@ -849,6 +856,13 @@ GfxInfoBase::GetFeatureStatusImpl(int32_t aFeature, return NS_OK; } + if (mShutdownOccurred) { + // This is futile; we've already commenced shutdown and our blocklists have + // been deleted. We may want to look into resurrecting the blocklist instead + // but for now, just don't even go there. + return NS_OK; + } + // If an operating system was provided by the derived GetFeatureStatusImpl, // grab it here. Otherwise, the OS is unknown. OperatingSystem os = (aOS ? *aOS : OperatingSystem::Unknown); diff --git a/widget/GfxInfoBase.h b/widget/GfxInfoBase.h index 6d30f1b719..5bc23f762b 100644 --- a/widget/GfxInfoBase.h +++ b/widget/GfxInfoBase.h @@ -77,6 +77,7 @@ public: static nsTArray* mDriverInfo; static bool mDriverInfoObserverInitialized; + static bool mShutdownOccurred; virtual nsString Model() { return EmptyString(); } virtual nsString Hardware() { return EmptyString(); } diff --git a/widget/GfxInfoX11.cpp b/widget/GfxInfoX11.cpp index 48fc3dbb5b..338dcac67f 100644 --- a/widget/GfxInfoX11.cpp +++ b/widget/GfxInfoX11.cpp @@ -268,8 +268,6 @@ GfxInfo::GetFeatureStatusImpl(int32_t aFeature, OperatingSystem* aOS /* = nullptr */) { - GetData(); - NS_ENSURE_ARG_POINTER(aStatus); *aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN; aSuggestedDriverVersion.SetIsVoid(true); @@ -277,6 +275,12 @@ GfxInfo::GetFeatureStatusImpl(int32_t aFeature, if (aOS) *aOS = os; + if (mShutdownOccurred) { + return NS_OK; + } + + GetData(); + if (mGLMajorVersion == 1) { // We're on OpenGL 1. In most cases that indicates really old hardware. // We better block them, rather than rely on them to fail gracefully, because they don't! diff --git a/widget/android/GfxInfo.cpp b/widget/android/GfxInfo.cpp index 181629e96f..d92cdb526d 100644 --- a/widget/android/GfxInfo.cpp +++ b/widget/android/GfxInfo.cpp @@ -377,6 +377,10 @@ GfxInfo::GetFeatureStatusImpl(int32_t aFeature, if (aOS) *aOS = os; + if (mShutdownOccurred) { + return NS_OK; + } + // OpenGL layers are never blacklisted on Android. // This early return is so we avoid potentially slow // GLStrings initialization on startup when we initialize GL layers. diff --git a/widget/cocoa/GfxInfo.mm b/widget/cocoa/GfxInfo.mm index 74333c514b..85c4692868 100644 --- a/widget/cocoa/GfxInfo.mm +++ b/widget/cocoa/GfxInfo.mm @@ -308,6 +308,10 @@ GfxInfo::GetFeatureStatusImpl(int32_t aFeature, if (aOS) *aOS = os; + if (mShutdownOccurred) { + return NS_OK; + } + // Don't evaluate special cases when we're evaluating the downloaded blocklist. if (!aDriverInfo.Length()) { if (aFeature == nsIGfxInfo::FEATURE_WEBGL_MSAA) { diff --git a/widget/uikit/GfxInfo.cpp b/widget/uikit/GfxInfo.cpp index 2aea3b5eab..cabe993dd0 100644 --- a/widget/uikit/GfxInfo.cpp +++ b/widget/uikit/GfxInfo.cpp @@ -175,6 +175,10 @@ GfxInfo::GetFeatureStatusImpl(int32_t aFeature, if (aOS) *aOS = OperatingSystem::Ios; + if (mShutdownOccurred) { + return NS_OK; + } + // OpenGL layers are never blacklisted on iOS. // This early return is so we avoid potentially slow // GLStrings initialization on startup when we initialize GL layers. diff --git a/widget/windows/GfxInfo.cpp b/widget/windows/GfxInfo.cpp index 8a429ad321..c62f5873e6 100644 --- a/widget/windows/GfxInfo.cpp +++ b/widget/windows/GfxInfo.cpp @@ -1101,6 +1101,10 @@ GfxInfo::GetFeatureStatusImpl(int32_t aFeature, if (aOS) *aOS = os; + if (mShutdownOccurred) { + return NS_OK; + } + // Don't evaluate special cases if we're checking the downloaded blocklist. if (!aDriverInfo.Length()) { nsAutoString adapterVendorID; -- cgit v1.2.3