Bug 1458270: Clean up in the shutdown observer. r=milan a=jcristau

--HG--
extra : amend_source : 7b1277a18a3ed4f441deef8b51cb4ec4dde614cc
This commit is contained in:
David Major 2018-05-23 11:54:21 -07:00 • committed by Roy Tam
commit 2c709a3e82
7 changed files with 39 additions and 4 deletions

View file

@ -43,6 +43,7 @@ using mozilla::MutexAutoLock;
nsTArray<GfxDriverInfo>* GfxInfoBase::mDriverInfo; nsTArray<GfxDriverInfo>* GfxInfoBase::mDriverInfo;
bool GfxInfoBase::mDriverInfoObserverInitialized; bool GfxInfoBase::mDriverInfoObserverInitialized;
bool GfxInfoBase::mShutdownOccurred;
// Observes for shutdown so that the child GfxDriverInfo list is freed. // Observes for shutdown so that the child GfxDriverInfo list is freed.
class ShutdownObserver : public nsIObserver class ShutdownObserver : public nsIObserver
@ -62,11 +63,17 @@ public:
delete GfxInfoBase::mDriverInfo; delete GfxInfoBase::mDriverInfo;
GfxInfoBase::mDriverInfo = nullptr; GfxInfoBase::mDriverInfo = nullptr;
for (uint32_t i = 0; i < DeviceFamilyMax; i++) for (uint32_t i = 0; i < DeviceFamilyMax; i++) {
delete GfxDriverInfo::mDeviceFamilies[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]; delete GfxDriverInfo::mDeviceVendors[i];
GfxDriverInfo::mDeviceVendors[i] = nullptr;
}
GfxInfoBase::mShutdownOccurred = true;
return NS_OK; return NS_OK;
} }
@ -855,6 +862,13 @@ GfxInfoBase::GetFeatureStatusImpl(int32_t aFeature,
return NS_OK; 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, // If an operating system was provided by the derived GetFeatureStatusImpl,
// grab it here. Otherwise, the OS is unknown. // grab it here. Otherwise, the OS is unknown.
OperatingSystem os = (aOS ? *aOS : OperatingSystem::Unknown); OperatingSystem os = (aOS ? *aOS : OperatingSystem::Unknown);

View file

@ -77,6 +77,7 @@ public:
static nsTArray<GfxDriverInfo>* mDriverInfo; static nsTArray<GfxDriverInfo>* mDriverInfo;
static bool mDriverInfoObserverInitialized; static bool mDriverInfoObserverInitialized;
static bool mShutdownOccurred;
virtual nsString Model() { return EmptyString(); } virtual nsString Model() { return EmptyString(); }
virtual nsString Hardware() { return EmptyString(); } virtual nsString Hardware() { return EmptyString(); }

View file

@ -268,8 +268,6 @@ GfxInfo::GetFeatureStatusImpl(int32_t aFeature,
OperatingSystem* aOS /* = nullptr */) OperatingSystem* aOS /* = nullptr */)
{ {
GetData();
NS_ENSURE_ARG_POINTER(aStatus); NS_ENSURE_ARG_POINTER(aStatus);
*aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN; *aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN;
aSuggestedDriverVersion.SetIsVoid(true); aSuggestedDriverVersion.SetIsVoid(true);
@ -277,6 +275,12 @@ GfxInfo::GetFeatureStatusImpl(int32_t aFeature,
if (aOS) if (aOS)
*aOS = os; *aOS = os;
if (mShutdownOccurred) {
return NS_OK;
}
GetData();
if (mGLMajorVersion == 1) { if (mGLMajorVersion == 1) {
// We're on OpenGL 1. In most cases that indicates really old hardware. // 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! // We better block them, rather than rely on them to fail gracefully, because they don't!

View file

@ -377,6 +377,10 @@ GfxInfo::GetFeatureStatusImpl(int32_t aFeature,
if (aOS) if (aOS)
*aOS = os; *aOS = os;
if (mShutdownOccurred) {
return NS_OK;
}
// OpenGL layers are never blacklisted on Android. // OpenGL layers are never blacklisted on Android.
// This early return is so we avoid potentially slow // This early return is so we avoid potentially slow
// GLStrings initialization on startup when we initialize GL layers. // GLStrings initialization on startup when we initialize GL layers.

View file

@ -308,6 +308,10 @@ GfxInfo::GetFeatureStatusImpl(int32_t aFeature,
if (aOS) if (aOS)
*aOS = os; *aOS = os;
if (mShutdownOccurred) {
return NS_OK;
}
// Don't evaluate special cases when we're evaluating the downloaded blocklist. // Don't evaluate special cases when we're evaluating the downloaded blocklist.
if (!aDriverInfo.Length()) { if (!aDriverInfo.Length()) {
if (aFeature == nsIGfxInfo::FEATURE_WEBGL_MSAA) { if (aFeature == nsIGfxInfo::FEATURE_WEBGL_MSAA) {

View file

@ -175,6 +175,10 @@ GfxInfo::GetFeatureStatusImpl(int32_t aFeature,
if (aOS) if (aOS)
*aOS = OperatingSystem::Ios; *aOS = OperatingSystem::Ios;
if (mShutdownOccurred) {
return NS_OK;
}
// OpenGL layers are never blacklisted on iOS. // OpenGL layers are never blacklisted on iOS.
// This early return is so we avoid potentially slow // This early return is so we avoid potentially slow
// GLStrings initialization on startup when we initialize GL layers. // GLStrings initialization on startup when we initialize GL layers.

View file

@ -1163,6 +1163,10 @@ GfxInfo::GetFeatureStatusImpl(int32_t aFeature,
if (aOS) if (aOS)
*aOS = os; *aOS = os;
if (mShutdownOccurred) {
return NS_OK;
}
// Don't evaluate special cases if we're checking the downloaded blocklist. // Don't evaluate special cases if we're checking the downloaded blocklist.
if (!aDriverInfo.Length()) { if (!aDriverInfo.Length()) {
nsAutoString adapterVendorID; nsAutoString adapterVendorID;