Move telemetry recording into D3D11LayersCrashGuard. (bug 1190281 part 5, r=mattwoodrow)

This commit is contained in:
David Anderson 2015-08-11 20:22:19 -07:00
parent ce1e93ce2f
commit f577fd034f
2 changed files with 39 additions and 30 deletions

View File

@ -46,9 +46,6 @@ DriverCrashGuard::Initialize()
}
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.";
return;
}
@ -57,10 +54,7 @@ DriverCrashGuard::Initialize()
// class already updated the environment in this session. Enable the
// guard.
AllowDriverInitAttempt();
return;
}
RecordTelemetry(TelemetryState::Okay);
}
DriverCrashGuard::~DriverCrashGuard()
@ -117,10 +111,6 @@ DriverCrashGuard::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);
#ifdef MOZ_CRASHREPORTER
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("GraphicsStartupTest"),
NS_LITERAL_CSTRING("1"));
@ -142,13 +132,12 @@ DriverCrashGuard::RecoverFromDriverInitCrash()
gfxPrefs::SetDriverInitStatus(int32_t(DriverInitStatus::Recovered));
UpdateEnvironment();
FlushPreferences();
RecordTelemetry(TelemetryState::RecoveredFromCrash);
LogCrashRecovery();
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::AccelerationDisabled);
// If we get here, we crashed in a previous session.
LogFeatureDisabled();
return true;
}
return false;
@ -168,7 +157,9 @@ DriverCrashGuard::PrepareToGuard()
}
// Always update the full environment, even if the base info didn't change.
return UpdateEnvironment() || sBaseInfoChanged;
return UpdateEnvironment() ||
sBaseInfoChanged ||
gfxPrefs::DriverInitStatus() == int32_t(DriverInitStatus::None);
}
bool
@ -234,12 +225,6 @@ DriverCrashGuard::FlushPreferences()
}
}
void
DriverCrashGuard::RecordTelemetry(TelemetryState aState)
{
// No default telemetry handling yet.
}
D3D11LayersCrashGuard::D3D11LayersCrashGuard()
{
}
@ -254,6 +239,10 @@ D3D11LayersCrashGuard::Initialize()
}
DriverCrashGuard::Initialize();
// If no telemetry states have been recorded, this will set the state to okay.
// Otherwise, it will have no effect.
RecordTelemetry(TelemetryState::Okay);
}
bool
@ -283,18 +272,33 @@ D3D11LayersCrashGuard::UpdateEnvironment()
#endif
}
// Finally, mark as changed if the status has been reset by the user.
changed |= (gfxPrefs::DriverInitStatus() == int32_t(DriverInitStatus::None));
if (!changed) {
return false;
}
return changed;
RecordTelemetry(TelemetryState::EnvironmentChanged);
return true;
}
void
D3D11LayersCrashGuard::LogCrashRecovery()
{
RecordTelemetry(TelemetryState::RecoveredFromCrash);
gfxCriticalError(CriticalLog::DefaultOptions(false)) << "D3D11 layers just crashed; D3D11 will be disabled.";
}
void
D3D11LayersCrashGuard::LogFeatureDisabled()
{
RecordTelemetry(TelemetryState::FeatureDisabled);
gfxCriticalError(CriticalLog::DefaultOptions(false)) << "D3D11 layers disabled due to a prior crash.";
}
void
D3D11LayersCrashGuard::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) {
// D3D11LayersCrashGuard is a no-op in the child process.
if (!XRE_IsParentProcess()) {
return;
}

View File

@ -51,13 +51,14 @@ public:
Okay = 0,
EnvironmentChanged = 1,
RecoveredFromCrash = 2,
AccelerationDisabled = 3
FeatureDisabled = 3
};
protected:
virtual void RecordTelemetry(TelemetryState aState);
virtual bool UpdateEnvironment() = 0;
virtual void Initialize() = 0;
virtual void LogCrashRecovery() = 0;
virtual void LogFeatureDisabled() = 0;
// Helper functions.
bool FeatureEnabled(int aFeature);
@ -90,7 +91,11 @@ class D3D11LayersCrashGuard final : public DriverCrashGuard
protected:
void Initialize() override;
bool UpdateEnvironment() override;
void RecordTelemetry(TelemetryState aState) override;
void LogCrashRecovery() override;
void LogFeatureDisabled() override;
private:
void RecordTelemetry(TelemetryState aState);
};
} // namespace gfx