Skip to content

Commit

Permalink
Bug 1135408 - Report device resets and their reasons through telemetr…
Browse files Browse the repository at this point in the history
…y. r=vladan, a=lmandel
  • Loading branch information
Bas-moz committed Feb 22, 2015
1 parent b66ed46 commit 8da17e8
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 5 deletions.
12 changes: 11 additions & 1 deletion gfx/thebes/gfxPlatform.h
Expand Up @@ -158,6 +158,16 @@ GetBackendName(mozilla::gfx::BackendType aBackend)
MOZ_CRASH("Incomplete switch");
}

enum class DeviceResetReason
{
OK = 0,
HUNG,
REMOVED,
RESET,
DRIVER_ERROR,
INVALID_CALL
};

class gfxPlatform {
public:
typedef mozilla::gfx::Color Color;
Expand Down Expand Up @@ -432,7 +442,7 @@ class gfxPlatform {
// check whether format is supported on a platform or not (if unclear, returns true)
virtual bool IsFontFormatSupported(nsIURI *aFontURI, uint32_t aFormatFlags) { return false; }

virtual bool DidRenderingDeviceReset() { return false; }
virtual bool DidRenderingDeviceReset(DeviceResetReason* aResetReason = nullptr) { return false; }

void GetPrefFonts(nsIAtom *aLanguage, nsString& array, bool aAppendUnicode = true);

Expand Down
34 changes: 31 additions & 3 deletions gfx/thebes/gfxWindowsPlatform.cpp
Expand Up @@ -18,6 +18,7 @@
#include "mozilla/WindowsVersion.h"
#include "nsServiceManagerUtils.h"
#include "nsTArray.h"
#include "mozilla/Telemetry.h"

#include "nsIWindowsRegKey.h"
#include "nsIFile.h"
Expand Down Expand Up @@ -464,7 +465,9 @@ gfxWindowsPlatform::UpdateRenderMode()
* desktop.
*/
bool didReset = false;
if (DidRenderingDeviceReset()) {
DeviceResetReason resetReason = DeviceResetReason::OK;
if (DidRenderingDeviceReset(&resetReason)) {
Telemetry::Accumulate(Telemetry::DEVICE_RESET_REASON, uint32_t(resetReason));
mD3D11DeviceInitialized = false;
mD3D11Device = nullptr;
mD3D11ContentDevice = nullptr;
Expand Down Expand Up @@ -1133,10 +1136,35 @@ gfxWindowsPlatform::IsFontFormatSupported(nsIURI *aFontURI, uint32_t aFormatFlag
}

bool
gfxWindowsPlatform::DidRenderingDeviceReset()
gfxWindowsPlatform::DidRenderingDeviceReset(DeviceResetReason* aResetReason)
{
if (aResetReason) {
*aResetReason = DeviceResetReason::OK;
}

if (mD3D11Device) {
if (mD3D11Device->GetDeviceRemovedReason() != S_OK) {
HRESULT hr = mD3D11Device->GetDeviceRemovedReason();
if (hr != S_OK) {
if (aResetReason) {
switch (hr) {
case DXGI_ERROR_DEVICE_HUNG:
*aResetReason = DeviceResetReason::HUNG;
break;
case DXGI_ERROR_DEVICE_REMOVED:
*aResetReason = DeviceResetReason::REMOVED;
break;
case DXGI_ERROR_DEVICE_RESET:
*aResetReason = DeviceResetReason::RESET;
break;
case DXGI_ERROR_DRIVER_INTERNAL_ERROR:
*aResetReason = DeviceResetReason::DRIVER_ERROR;
break;
case DXGI_ERROR_INVALID_CALL:
*aResetReason = DeviceResetReason::INVALID_CALL;
default:
MOZ_ASSERT(false);
}
}
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion gfx/thebes/gfxWindowsPlatform.h
Expand Up @@ -210,7 +210,7 @@ class gfxWindowsPlatform : public gfxPlatform {
*/
virtual bool IsFontFormatSupported(nsIURI *aFontURI, uint32_t aFormatFlags);

virtual bool DidRenderingDeviceReset();
virtual bool DidRenderingDeviceReset(DeviceResetReason* aResetReason = nullptr);

/* Find a FontFamily/FontEntry object that represents a font on your system given a name */
gfxFontFamily *FindFontFamily(const nsAString& aName);
Expand Down
6 changes: 6 additions & 0 deletions toolkit/components/telemetry/Histograms.json
Expand Up @@ -210,6 +210,12 @@
"n_buckets": 50,
"description": "Time spent on one asynchronous SnowWhite freeing (ms)"
},
"DEVICE_RESET_REASON": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 10,
"description": "GPU Device Reset Reason (ok, hung, removed, reset, internal error, invalid call)"
},
"FORGET_SKIPPABLE_MAX": {
"expires_in_version": "never",
"kind": "exponential",
Expand Down

0 comments on commit 8da17e8

Please sign in to comment.