Add a crash guard for DXVA2D3D9. (bug 1190281 part 8, r=mattwoodrow)

This commit is contained in:
David Anderson 2015-08-11 20:22:20 -07:00
parent 2cfc7d03e0
commit 7f5f270a21
4 changed files with 47 additions and 0 deletions

View File

@ -5193,6 +5193,9 @@ ContentParent::RecvBeginDriverCrashGuard(const uint32_t& aGuardType, bool* aOutC
case gfx::CrashGuardType::D3D11Layers:
guard = MakeUnique<gfx::D3D11LayersCrashGuard>(this);
break;
case gfx::CrashGuardType::D3D9Video:
guard = MakeUnique<gfx::D3D9VideoCrashGuard>(this);
break;
default:
MOZ_ASSERT_UNREACHABLE("unknown crash guard type");
return false;

View File

@ -14,6 +14,7 @@
#include "mozilla/Preferences.h"
#include "mfapi.h"
#include "MFTDecoder.h"
#include "DriverCrashGuard.h"
const CLSID CLSID_VideoProcessorMFT =
{
@ -90,6 +91,12 @@ D3D9DXVA2Manager::Init()
{
MOZ_ASSERT(NS_IsMainThread());
gfx::D3D9VideoCrashGuard crashGuard;
if (crashGuard.Crashed()) {
NS_WARNING("DXVA2D3D9 crash detected");
return E_FAIL;
}
// Create D3D9Ex.
HMODULE d3d9lib = LoadLibraryW(L"d3d9.dll");
NS_ENSURE_TRUE(d3d9lib, E_FAIL);

View File

@ -24,6 +24,7 @@ namespace gfx {
static const size_t NUM_CRASH_GUARD_TYPES = size_t(CrashGuardType::NUM_TYPES);
static const char* sCrashGuardNames[NUM_CRASH_GUARD_TYPES] = {
"d3d11layers",
"d3d9video",
};
DriverCrashGuard::DriverCrashGuard(CrashGuardType aType, dom::ContentParent* aContentParent)
@ -430,5 +431,29 @@ D3D11LayersCrashGuard::RecordTelemetry(TelemetryState aState)
sTelemetryStateRecorded = true;
}
D3D9VideoCrashGuard::D3D9VideoCrashGuard(dom::ContentParent* aContentParent)
: DriverCrashGuard(CrashGuardType::D3D9Video, aContentParent)
{
}
bool
D3D9VideoCrashGuard::UpdateEnvironment()
{
// We don't care about any extra preferences here.
return false;
}
void
D3D9VideoCrashGuard::LogCrashRecovery()
{
gfxCriticalError(CriticalLog::DefaultOptions(false)) << "DXVA2D3D9 just crashed; hardware video will be disabled.";
}
void
D3D9VideoCrashGuard::LogFeatureDisabled()
{
gfxCriticalError(CriticalLog::DefaultOptions(false)) << "DXVA2D3D9 video decoding is disabled due to a previous crash.";
}
} // namespace gfx
} // namespace mozilla

View File

@ -38,6 +38,7 @@ enum class DriverInitStatus
enum class CrashGuardType : uint32_t
{
D3D11Layers,
D3D9Video,
NUM_TYPES
};
@ -130,6 +131,17 @@ class D3D11LayersCrashGuard final : public DriverCrashGuard
void RecordTelemetry(TelemetryState aState);
};
class D3D9VideoCrashGuard final : public DriverCrashGuard
{
public:
explicit D3D9VideoCrashGuard(dom::ContentParent* aContentParent = nullptr);
protected:
bool UpdateEnvironment() override;
void LogCrashRecovery() override;
void LogFeatureDisabled() override;
};
} // namespace gfx
} // namespace mozilla