Add telemetry for reporting graphics driver startup states. (bug 1168935 part 2, r=vdjeric,mattwoodrow)

This commit is contained in:
David Anderson 2015-06-10 21:59:05 -07:00
parent e69b790a90
commit 47c272ce2e
3 changed files with 95 additions and 6 deletions

View File

@ -10,6 +10,7 @@
#include "nsString.h"
#include "nsXULAppAPI.h"
#include "mozilla/Preferences.h"
#include "mozilla/Telemetry.h"
#include "mozilla/gfx/Logging.h"
namespace mozilla {
@ -28,13 +29,16 @@ DriverInitCrashDetection::DriverInitCrashDetection()
return;
}
if (sDisableAcceleration) {
// We already disabled acceleration earlier.
return;
}
if (RecoverFromDriverInitCrash()) {
if (!sDisableAcceleration) {
// 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;
}
// 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;
}
@ -53,6 +57,8 @@ DriverInitCrashDetection::DriverInitCrashDetection()
sEnvironmentHasBeenUpdated = true;
return;
}
RecordTelemetry(TelemetryState::Okay);
}
DriverInitCrashDetection::~DriverInitCrashDetection()
@ -96,6 +102,10 @@ DriverInitCrashDetection::AllowDriverInitAttempt()
// Flush preferences, so if we crash, we don't think the environment has changed again.
FlushPreferences();
// If we crash, we'll just lose this. Not a big deal, next startup we'll
// record the failure.
RecordTelemetry(TelemetryState::EnvironmentChanged);
}
bool
@ -113,11 +123,13 @@ DriverInitCrashDetection::RecoverFromDriverInitCrash()
gfxPrefs::SetDriverInitStatus(int32_t(DriverInitStatus::Recovered));
UpdateEnvironment();
FlushPreferences();
RecordTelemetry(TelemetryState::RecoveredFromCrash);
return true;
}
if (gfxPrefs::DriverInitStatus() == int32_t(DriverInitStatus::Recovered)) {
// If we get here, we crashed in the current environment and have already
// disabled acceleration.
RecordTelemetry(TelemetryState::DriverUseDisabled);
return true;
}
return false;
@ -204,5 +216,25 @@ DriverInitCrashDetection::FlushPreferences()
}
}
void
DriverInitCrashDetection::RecordTelemetry(TelemetryState aState)
{
// Since we run this in each child process, we only want the initial results
// from the chrome process.
if (XRE_GetProcessType() != GeckoProcessType_Default) {
return;
}
// Since we instantiate this class more than once, make sure we only record
// the first state (since that is really all we care about).
static bool sTelemetryStateRecorded = false;
if (sTelemetryStateRecorded) {
return;
}
Telemetry::Accumulate(Telemetry::GRAPHICS_DRIVER_STARTUP_TEST, int32_t(aState));
sTelemetryStateRecorded = true;
}
} // namespace gfx
} // namespace mozilla

View File

@ -38,6 +38,53 @@ public:
return sDisableAcceleration;
}
// NOTE: These are the values reported to Telemetry (GRAPHICS_DRIVER_STARTUP_TEST).
// Values should not change; add new values to the end.
//
// We report exactly one of these values on every startup. The only exception
// is when we crash during driver initialization; the relevant value will be
// reported on the next startup. The value can change from startup to startup.
//
// The initial value for any profile is "EnvironmentChanged"; this means we
// have not seen the environment before. The environment includes graphics
// driver versions, adpater IDs, the MOZ_APP version, and blacklisting
// information.
//
// If the user crashes, the next startup will have the "RecoveredFromCrash"
// state. Graphics acceleration will be disabled. Subsequent startups will
// have the "DriverUseDisabled" state.
//
// If the user does not crash, subsequent startups will have the "Okay"
// state.
//
// If the environment changes, the state (no matter what it is) will
// transition back to "EnvironmentChanged".
enum class TelemetryState {
// Environment is the same as before, and we detected no crash at that time.
//
// Valid state transitions: Okay -> EnvironmentChanged.
Okay = 0,
// Environment has changed since the last time we checked drivers. If we
// detected a crash before, we re-enable acceleration to see if it will
// work in the new environment.
//
// Valid state transitions: EnvironmentChanged -> RecoveredFromCrash | Okay
EnvironmentChanged = 1,
// The last startup crashed trying to enable graphics acceleration, and
// acceleration has just been disabled.
//
// Valid state transitions: RecoveredFromCrash -> DriverUseDisabled | EnvironmentChanged
RecoveredFromCrash = 2,
// A previous session was in the RecoveredFromCrash state, and now graphics
// acceleration is disabled until the environment changes.
//
// Valid state transitions: DriverUseDisabled -> EnvironmentChanged
DriverUseDisabled = 3
};
private:
bool InitLockFilePath();
bool UpdateEnvironment();
@ -48,6 +95,8 @@ private:
bool RecoverFromDriverInitCrash();
void FlushPreferences();
void RecordTelemetry(TelemetryState aState);
private:
static bool sDisableAcceleration;
static bool sEnvironmentHasBeenUpdated;

View File

@ -8158,5 +8158,13 @@
"expires_in_version": "45",
"kind": "boolean",
"description": "Set if media.eme.enabled is false, in a build that supports the Adobe Primetime Content Decryption Module."
},
"GRAPHICS_DRIVER_STARTUP_TEST": {
"alert_emails": ["danderson@mozilla.com"],
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 20,
"releaseChannelCollection": "opt-out",
"description": "Reports the status of graphics driver initialization. 0=Okay, 1=Driver/GPU/Firefox changed, 2=Drivers crashed during last startup, 3=Drivers crashed in a previous startup. State 0 is normal, 1 indicates a system change, 2 indicates a catastrophic crash, 3 indicates a user that experienced state 2 and is now unaccelerated."
}
}