Make DriverCrashGuard initialization lazy. (bug 1190281 part 3, r=mattwoodrow)

This commit is contained in:
David Anderson 2015-08-11 00:29:08 -07:00
parent c70534a3cb
commit 6e5a461ad7
3 changed files with 34 additions and 4 deletions

View File

@ -23,7 +23,24 @@ 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
@ -76,8 +93,9 @@ DriverCrashGuard::~DriverCrashGuard()
}
bool
DriverCrashGuard::DisableAcceleration() const
DriverCrashGuard::Crashed()
{
InitializeIfNeeded();
return gfxPrefs::DriverInitStatus() == int32_t(DriverInitStatus::Recovered);
}

View File

@ -28,13 +28,22 @@ enum class DriverInitStatus
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.
@ -46,6 +55,8 @@ public:
};
private:
void InitializeIfNeeded();
void Initialize();
bool InitLockFilePath();
bool UpdateEnvironment();
bool CheckAndUpdatePref(const char* aPrefName, const nsAString& aCurrentValue);
@ -61,6 +72,7 @@ private:
static bool sEnvironmentHasBeenUpdated;
private:
bool mInitialized;
bool mIsChromeProcess;
nsCOMPtr<nsIGfxInfo> mGfxInfo;
nsCOMPtr<nsIFile> mLockFile;

View File

@ -2184,7 +2184,7 @@ gfxWindowsPlatform::InitializeDevices()
// 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;
}