Remove static vars from DriverInitCrashDetection. (bug 1183910 part 1, r=mattwoodrow)
☠☠ backed out by 70c553b37c19 ☠ ☠
authorDavid Anderson <danderson@mozilla.com>
Tue, 11 Aug 2015 00:29:08 -0700
changeset 291476 e7b3b23bcc8286d117bf07f78b2b7d91af610960
parent 291475 884385e6f556fc07d33ddd790474d459a7e55aab
child 291477 e98a176b4e0b68ed6fd5fc0bd74208dc8fef525c
push id962
push userjlund@mozilla.com
push dateFri, 04 Dec 2015 23:28:54 +0000
treeherdermozilla-release@23a2d286e80f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1183910
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Remove static vars from DriverInitCrashDetection. (bug 1183910 part 1, r=mattwoodrow)
gfx/src/DriverInitCrashDetection.cpp
gfx/src/DriverInitCrashDetection.h
--- a/gfx/src/DriverInitCrashDetection.cpp
+++ b/gfx/src/DriverInitCrashDetection.cpp
@@ -15,44 +15,36 @@
 #include "mozilla/Preferences.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/Services.h"
 #include "mozilla/gfx/Logging.h"
 
 namespace mozilla {
 namespace gfx {
 
-bool DriverInitCrashDetection::sDisableAcceleration = false;
 bool DriverInitCrashDetection::sEnvironmentHasBeenUpdated = false;
 
 DriverInitCrashDetection::DriverInitCrashDetection()
  : mIsChromeProcess(XRE_GetProcessType() == GeckoProcessType_Default)
 {
-  if (sDisableAcceleration) {
-    // We already disabled acceleration earlier.
-    return;
-  }
-
   if (!mIsChromeProcess) {
-    // In child processes we only need to check the pref state set by the
-    // parent process.
-    sDisableAcceleration = (gfxPrefs::DriverInitStatus() == int32_t(DriverInitStatus::Recovered));
+    // We assume the parent process already performed crash detection for
+    // graphics devices.
     return;
   }
 
   if (!InitLockFilePath()) {
     gfxCriticalError(CriticalLog::DefaultOptions(false)) << "Failed to create the graphics startup lockfile.";
     return;
   }
 
   if (RecoverFromDriverInitCrash()) {
     // This is the first time we're checking for a crash recovery, so print
     // a message and disable acceleration for anyone who asks for it.
     gfxCriticalError(CriticalLog::DefaultOptions(false)) << "Recovered from graphics driver startup crash; acceleration disabled.";
-    sDisableAcceleration = true;
     return;
   }
 
   if (UpdateEnvironment() || sEnvironmentHasBeenUpdated) {
     // Something in the environment changed, *or* a previous instance of this
     // class already updated the environment. Allow a fresh attempt at driver
     // acceleration. This doesn't mean the previous attempt failed, it just
     // means we want to detect whether the new environment crashes.
@@ -79,16 +71,22 @@ DriverInitCrashDetection::~DriverInitCra
     // Remove the crash report annotation.
     CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("GraphicsStartupTest"),
                                        NS_LITERAL_CSTRING(""));
 #endif
   }
 }
 
 bool
+DriverInitCrashDetection::DisableAcceleration() const
+{
+  return gfxPrefs::DriverInitStatus() == int32_t(DriverInitStatus::Recovered);
+}
+
+bool
 DriverInitCrashDetection::InitLockFilePath()
 {
   NS_GetSpecialDirectory(NS_APP_USER_PROFILE_LOCAL_50_DIR, getter_AddRefs(mLockFile));
   if (!mLockFile) {
     return false;
   }
   if (!NS_SUCCEEDED(mLockFile->AppendNative(NS_LITERAL_CSTRING("gfxinit.lock")))) {
     return false;
@@ -178,17 +176,16 @@ DriverInitCrashDetection::UpdateEnvironm
   }
 
   // Firefox properties.
   changed |= CheckAndUpdatePref("gfx.driver-init.appVersion", NS_LITERAL_STRING(MOZ_APP_VERSION));
 
   // Finally, mark as changed if the status has been reset by the user.
   changed |= (gfxPrefs::DriverInitStatus() == int32_t(DriverInitStatus::None));
 
-  mGfxInfo = nullptr;
   return changed;
 }
 
 bool
 DriverInitCrashDetection::FeatureEnabled(int aFeature)
 {
   int32_t status;
   if (!NS_SUCCEEDED(mGfxInfo->GetFeatureStatus(aFeature, &status))) {
--- a/gfx/src/DriverInitCrashDetection.h
+++ b/gfx/src/DriverInitCrashDetection.h
@@ -29,19 +29,17 @@ enum class DriverInitStatus
 };
 
 class DriverInitCrashDetection
 {
 public:
   DriverInitCrashDetection();
   ~DriverInitCrashDetection();
 
-  bool DisableAcceleration() const {
-    return sDisableAcceleration;
-  }
+  bool DisableAcceleration() const;
 
   // These are the values reported to Telemetry (GRAPHICS_DRIVER_STARTUP_TEST).
   // Values should not change; add new values to the end.
   enum class TelemetryState {
     Okay = 0,
     EnvironmentChanged = 1,
     RecoveredFromCrash = 2,
     AccelerationDisabled = 3
@@ -55,17 +53,16 @@ private:
   bool FeatureEnabled(int aFeature);
   void AllowDriverInitAttempt();
   bool RecoverFromDriverInitCrash();
   void FlushPreferences();
 
   void RecordTelemetry(TelemetryState aState);
 
 private:
-  static bool sDisableAcceleration;
   static bool sEnvironmentHasBeenUpdated;
 
 private:
   bool mIsChromeProcess;
   nsCOMPtr<nsIGfxInfo> mGfxInfo;
   nsCOMPtr<nsIFile> mLockFile;
 };