Make DriverCrashGuard initialization lazy. (bug 1190281 part 3, r=mattwoodrow)
☠☠ backed out by 70c553b37c19 ☠ ☠
authorDavid Anderson <danderson@mozilla.com>
Tue, 11 Aug 2015 00:29:08 -0700
changeset 291478 cf98685302b69af5492477fa3e4434317b9db885
parent 291477 e98a176b4e0b68ed6fd5fc0bd74208dc8fef525c
child 291479 50edbeb8912ef7d66006c67632aaa9430b01af04
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
bugs1190281
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
Make DriverCrashGuard initialization lazy. (bug 1190281 part 3, r=mattwoodrow)
gfx/src/DriverCrashGuard.cpp
gfx/src/DriverCrashGuard.h
gfx/thebes/gfxWindowsPlatform.cpp
--- a/gfx/src/DriverCrashGuard.cpp
+++ b/gfx/src/DriverCrashGuard.cpp
@@ -18,17 +18,34 @@
 #include "mozilla/gfx/Logging.h"
 
 namespace mozilla {
 namespace gfx {
 
 bool DriverCrashGuard::sEnvironmentHasBeenUpdated = false;
 
 DriverCrashGuard::DriverCrashGuard()
- : mIsChromeProcess(XRE_GetProcessType() == GeckoProcessType_Default)
+ : mInitialized(false)
+ , mIsChromeProcess(XRE_GetProcessType() == GeckoProcessType_Default)
+{
+}
+
+void
+DriverCrashGuard::InitializeIfNeeded()
+{
+  if (mInitialized) {
+    return;
+  }
+
+  mInitialized = true;
+  Initialize();
+}
+
+void
+DriverCrashGuard::Initialize()
 {
   if (!mIsChromeProcess) {
     // We assume the parent process already performed crash detection for
     // graphics devices.
     return;
   }
 
   if (!InitLockFilePath()) {
@@ -71,18 +88,19 @@ DriverCrashGuard::~DriverCrashGuard()
     // Remove the crash report annotation.
     CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("GraphicsStartupTest"),
                                        NS_LITERAL_CSTRING(""));
 #endif
   }
 }
 
 bool
-DriverCrashGuard::DisableAcceleration() const
+DriverCrashGuard::Crashed()
 {
+  InitializeIfNeeded();
   return gfxPrefs::DriverInitStatus() == int32_t(DriverInitStatus::Recovered);
 }
 
 bool
 DriverCrashGuard::InitLockFilePath()
 {
   NS_GetSpecialDirectory(NS_APP_USER_PROFILE_LOCAL_50_DIR, getter_AddRefs(mLockFile));
   if (!mLockFile) {
--- a/gfx/src/DriverCrashGuard.h
+++ b/gfx/src/DriverCrashGuard.h
@@ -23,49 +23,61 @@ enum class DriverInitStatus
 
   // Drivers were successfully initialized last run.
   Okay,
 
   // We crashed during driver initialization, and have restarted.
   Recovered
 };
 
+// DriverCrashGuard is used to detect crashes at graphics driver callsites.
+// 
+// If the graphics environment is unrecognized or has changed since the last
+// session, the crash guard will activate and will detect any crashes within
+// the scope of the guard object.
+//
+// If a callsite has a previously encountered crash, and the environment has
+// not changed since the last session, then the guard will set a status flag
+// indicating that the driver should not be used.
 class DriverCrashGuard
 {
 public:
   DriverCrashGuard();
   ~DriverCrashGuard();
 
-  bool DisableAcceleration() const;
+  bool Crashed();
 
   // 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
   };
 
 private:
+  void InitializeIfNeeded();
+  void Initialize();
   bool InitLockFilePath();
   bool UpdateEnvironment();
   bool CheckAndUpdatePref(const char* aPrefName, const nsAString& aCurrentValue);
   bool CheckAndUpdateBoolPref(const char* aPrefName, bool aCurrentValue);
   bool FeatureEnabled(int aFeature);
   void AllowDriverInitAttempt();
   bool RecoverFromDriverInitCrash();
   void FlushPreferences();
 
   void RecordTelemetry(TelemetryState aState);
 
 private:
   static bool sEnvironmentHasBeenUpdated;
 
 private:
+  bool mInitialized;
   bool mIsChromeProcess;
   nsCOMPtr<nsIGfxInfo> mGfxInfo;
   nsCOMPtr<nsIFile> mLockFile;
 };
 
 } // namespace gfx
 } // namespace mozilla
 
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -2179,17 +2179,17 @@ gfxWindowsPlatform::InitializeDevices()
   if (IsFeatureStatusFailure(mAcceleration)) {
     return;
   }
 
   // If we previously crashed initializing devices, bail out now. This is
   // effectively a parent-process only check, since the content process
   // cannot create a lock file.
   DriverCrashGuard detectCrashes;
-  if (detectCrashes.DisableAcceleration()) {
+  if (detectCrashes.Crashed()) {
     mAcceleration = FeatureStatus::Blocked;
     return;
   }
 
   // If we're going to prefer D3D9, stop here. The rest of this function
   // attempts to use D3D11 features.
   if (gfxPrefs::LayersPreferD3D9()) {
     mD3D11Status = FeatureStatus::Disabled;