Bug 1664560 - Expose yet more WebRender initialization failure error messages to telemetry. r=kvark

Differential Revision: https://phabricator.services.mozilla.com/D89966
This commit is contained in:
Andrew Osmond 2020-09-11 22:40:40 +00:00
Родитель 4820139e53
Коммит a9c24fabba
15 изменённых файлов: 73 добавлений и 61 удалений

Просмотреть файл

@ -34,16 +34,17 @@ UniquePtr<DCLayerTree> DCLayerTree::Create(gl::GLContext* aGL,
EGLConfig aEGLConfig,
ID3D11Device* aDevice,
ID3D11DeviceContext* aCtx,
HWND aHwnd) {
HWND aHwnd, nsACString& aError) {
RefPtr<IDCompositionDevice2> dCompDevice =
gfx::DeviceManagerDx::Get()->GetDirectCompositionDevice();
if (!dCompDevice) {
aError.Assign("DCLayerTree(no device)"_ns);
return nullptr;
}
auto layerTree =
MakeUnique<DCLayerTree>(aGL, aEGLConfig, aDevice, aCtx, dCompDevice);
if (!layerTree->Initialize(aHwnd)) {
if (!layerTree->Initialize(aHwnd, aError)) {
return nullptr;
}
@ -79,35 +80,38 @@ void DCLayerTree::ReleaseNativeCompositorResources() {
}
}
bool DCLayerTree::Initialize(HWND aHwnd) {
bool DCLayerTree::Initialize(HWND aHwnd, nsACString& aError) {
HRESULT hr;
RefPtr<IDCompositionDesktopDevice> desktopDevice;
hr = mCompositionDevice->QueryInterface(
(IDCompositionDesktopDevice**)getter_AddRefs(desktopDevice));
if (FAILED(hr)) {
gfxCriticalNote << "Failed to get IDCompositionDesktopDevice: "
<< gfx::hexa(hr);
aError.Assign(nsPrintfCString(
"DCLayerTree(get IDCompositionDesktopDevice failed %x)", hr));
return false;
}
hr = desktopDevice->CreateTargetForHwnd(aHwnd, TRUE,
getter_AddRefs(mCompositionTarget));
if (FAILED(hr)) {
gfxCriticalNote << "Could not create DCompositionTarget: " << gfx::hexa(hr);
aError.Assign(nsPrintfCString(
"DCLayerTree(create DCompositionTarget failed %x)", hr));
return false;
}
hr = mCompositionDevice->CreateVisual(getter_AddRefs(mRootVisual));
if (FAILED(hr)) {
gfxCriticalNote << "Failed to create DCompositionVisual: " << gfx::hexa(hr);
aError.Assign(nsPrintfCString(
"DCLayerTree(create root DCompositionVisual failed %x)", hr));
return false;
}
hr =
mCompositionDevice->CreateVisual(getter_AddRefs(mDefaultSwapChainVisual));
if (FAILED(hr)) {
gfxCriticalNote << "Failed to create DCompositionVisual: " << gfx::hexa(hr);
aError.Assign(nsPrintfCString(
"DCLayerTree(create swap chain DCompositionVisual failed %x)", hr));
return false;
}

Просмотреть файл

@ -57,7 +57,8 @@ class DCLayerTree {
public:
static UniquePtr<DCLayerTree> Create(gl::GLContext* aGL, EGLConfig aEGLConfig,
ID3D11Device* aDevice,
ID3D11DeviceContext* aCtx, HWND aHwnd);
ID3D11DeviceContext* aCtx, HWND aHwnd,
nsACString& aError);
explicit DCLayerTree(gl::GLContext* aGL, EGLConfig aEGLConfig,
ID3D11Device* aDevice, ID3D11DeviceContext* aCtx,
IDCompositionDevice2* aCompositionDevice);
@ -108,7 +109,7 @@ class DCLayerTree {
GLuint GetOrCreateFbo(int aWidth, int aHeight);
protected:
bool Initialize(HWND aHwnd);
bool Initialize(HWND aHwnd, nsACString& aError);
bool InitializeVideoOverlaySupport();
bool MaybeUpdateDebugCounter();
bool MaybeUpdateDebugVisualRedrawRegions();

Просмотреть файл

@ -127,25 +127,25 @@ void wr_compositor_unmap_tile(void* aCompositor) {
/* static */
UniquePtr<RenderCompositor> RenderCompositor::Create(
RefPtr<widget::CompositorWidget>&& aWidget) {
RefPtr<widget::CompositorWidget>&& aWidget, nsACString& aError) {
if (gfx::gfxVars::UseSoftwareWebRender()) {
#ifdef XP_MACOSX
// Mac uses NativeLayerCA
return RenderCompositorNativeSWGL::Create(std::move(aWidget));
return RenderCompositorNativeSWGL::Create(std::move(aWidget), aError);
#else
return RenderCompositorSWGL::Create(std::move(aWidget));
return RenderCompositorSWGL::Create(std::move(aWidget), aError);
#endif
}
#ifdef XP_WIN
if (gfx::gfxVars::UseWebRenderANGLE()) {
return RenderCompositorANGLE::Create(std::move(aWidget));
return RenderCompositorANGLE::Create(std::move(aWidget), aError);
}
#endif
#if defined(MOZ_WAYLAND) || defined(MOZ_WIDGET_ANDROID)
UniquePtr<RenderCompositor> eglCompositor =
RenderCompositorEGL::Create(aWidget);
RenderCompositorEGL::Create(aWidget, aError);
if (eglCompositor) {
return eglCompositor;
}
@ -156,9 +156,9 @@ UniquePtr<RenderCompositor> RenderCompositor::Create(
return nullptr;
#elif defined(XP_MACOSX)
// Mac uses NativeLayerCA
return RenderCompositorNativeOGL::Create(std::move(aWidget));
return RenderCompositorNativeOGL::Create(std::move(aWidget), aError);
#else
return RenderCompositorOGL::Create(std::move(aWidget));
return RenderCompositorOGL::Create(std::move(aWidget), aError);
#endif
}

Просмотреть файл

@ -32,7 +32,7 @@ namespace wr {
class RenderCompositor {
public:
static UniquePtr<RenderCompositor> Create(
RefPtr<widget::CompositorWidget>&& aWidget);
RefPtr<widget::CompositorWidget>&& aWidget, nsACString& aError);
RenderCompositor(RefPtr<widget::CompositorWidget>&& aWidget);
virtual ~RenderCompositor();

Просмотреть файл

@ -42,16 +42,16 @@ namespace wr {
/* static */
UniquePtr<RenderCompositor> RenderCompositorANGLE::Create(
RefPtr<widget::CompositorWidget>&& aWidget) {
RefPtr<widget::CompositorWidget>&& aWidget, nsACString& aError) {
const auto& gl = RenderThread::Get()->SharedGL();
if (!gl) {
gfxCriticalNote << "Failed to get shared GL context";
aError.Assign("RcANGLE(no shared GL)"_ns);
return nullptr;
}
UniquePtr<RenderCompositorANGLE> compositor =
MakeUnique<RenderCompositorANGLE>(std::move(aWidget));
if (!compositor->Initialize()) {
if (!compositor->Initialize(aError)) {
return nullptr;
}
return compositor;
@ -74,15 +74,17 @@ RenderCompositorANGLE::~RenderCompositorANGLE() {
MOZ_ASSERT(!mEGLSurface);
}
ID3D11Device* RenderCompositorANGLE::GetDeviceOfEGLDisplay() {
ID3D11Device* RenderCompositorANGLE::GetDeviceOfEGLDisplay(nsACString& aError) {
const auto& gl = RenderThread::Get()->SharedGL();
if (!gl) {
aError.Assign("RcANGLE(no shared GL in get device)"_ns);
return nullptr;
}
const auto& gle = gl::GLContextEGL::Cast(gl);
const auto& egl = gle->mEgl;
MOZ_ASSERT(egl);
if (!egl || !egl->IsExtensionSupported(gl::EGLExtension::EXT_device_query)) {
aError.Assign("RcANGLE(no EXT_device_query support)"_ns);
return nullptr;
}
@ -94,16 +96,16 @@ ID3D11Device* RenderCompositorANGLE::GetDeviceOfEGLDisplay() {
egl->mLib->fQueryDeviceAttribEXT(eglDevice, LOCAL_EGL_D3D11_DEVICE_ANGLE,
(EGLAttrib*)&device);
if (!device) {
gfxCriticalNote << "Failed to get D3D11Device from EGLDisplay";
aError.Assign("RcANGLE(get D3D11Device from EGLDisplay failed)"_ns);
return nullptr;
}
return device;
}
bool RenderCompositorANGLE::ShutdownEGLLibraryIfNecessary() {
const auto& displayDevice = GetDeviceOfEGLDisplay();
bool RenderCompositorANGLE::ShutdownEGLLibraryIfNecessary(nsACString& aError) {
const auto& displayDevice = GetDeviceOfEGLDisplay(aError);
if (!displayDevice) {
return true;
return false;
}
RefPtr<ID3D11Device> device =
@ -123,19 +125,20 @@ bool RenderCompositorANGLE::ShutdownEGLLibraryIfNecessary() {
return true;
}
bool RenderCompositorANGLE::Initialize() {
bool RenderCompositorANGLE::Initialize(nsACString& aError) {
if (RenderThread::Get()->IsHandlingDeviceReset()) {
gfxCriticalNote << "Waiting for handling device reset";
aError.Assign("RcANGLE(waiting device reset)"_ns);
return false;
}
// Update device if necessary.
if (!ShutdownEGLLibraryIfNecessary()) {
if (!ShutdownEGLLibraryIfNecessary(aError)) {
aError.Assign("RcANGLE(shutdown EGL failed)"_ns);
return false;
}
const auto gl = RenderThread::Get()->SharedGL();
if (!gl) {
gfxCriticalNote << "[WR] failed to get shared GL context.";
aError.Assign("RcANGLE(no shared GL post maybe shutdown)"_ns);
return false;
}
@ -145,20 +148,20 @@ bool RenderCompositorANGLE::Initialize() {
const auto& egl = gle->mEgl;
if (!gl::CreateConfig(*egl, &mEGLConfig, /* bpp */ 32,
/* enableDepthBuffer */ true, gl->IsGLES())) {
gfxCriticalNote << "Failed to create EGLConfig for WebRender";
aError.Assign("RcANGLE(create EGLConfig failed)"_ns);
return false;
}
MOZ_ASSERT(mEGLConfig);
mDevice = GetDeviceOfEGLDisplay();
mDevice = GetDeviceOfEGLDisplay(aError);
if (!mDevice) {
gfxCriticalNote << "[WR] failed to get compositor device.";
return false;
}
mDevice->GetImmediateContext(getter_AddRefs(mCtx));
if (!mCtx) {
gfxCriticalNote << "[WR] failed to get immediate context.";
aError.Assign("RcANGLE(get immediate context failed)"_ns);
return false;
}
@ -166,21 +169,20 @@ bool RenderCompositorANGLE::Initialize() {
if (gfx::gfxVars::UseWebRenderDCompWin()) {
HWND compositorHwnd = GetCompositorHwnd();
if (compositorHwnd) {
mDCLayerTree =
DCLayerTree::Create(gl, mEGLConfig, mDevice, mCtx, compositorHwnd);
mDCLayerTree = DCLayerTree::Create(gl, mEGLConfig, mDevice, mCtx,
compositorHwnd, aError);
if (!mDCLayerTree) {
gfxCriticalNote << "Failed to create DCLayerTree";
return false;
}
} else {
gfxCriticalNote << "Compositor window was not created";
aError.Assign("RcANGLE(no compositor window)"_ns);
return false;
}
}
// Create SwapChain when compositor is not used
if (!UseCompositor()) {
if (!CreateSwapChain()) {
if (!CreateSwapChain(aError)) {
// SwapChain creation failed.
return false;
}
@ -190,6 +192,7 @@ bool RenderCompositorANGLE::Initialize() {
if (!mSyncObject->Init()) {
// Some errors occur. Clear the mSyncObject here.
// Then, there will be no texture synchronization.
aError.Assign("RcANGLE(create SyncObject failed)"_ns);
return false;
}
@ -218,7 +221,7 @@ HWND RenderCompositorANGLE::GetCompositorHwnd() {
return hwnd;
}
bool RenderCompositorANGLE::CreateSwapChain() {
bool RenderCompositorANGLE::CreateSwapChain(nsACString& aError) {
MOZ_ASSERT(!UseCompositor());
HWND hwnd = mWidget->AsWindows()->GetHwnd();
@ -245,7 +248,7 @@ bool RenderCompositorANGLE::CreateSwapChain() {
CreateSwapChainForDCompIfPossible(dxgiFactory2);
if (gfx::gfxVars::UseWebRenderDCompWin() && !mSwapChain) {
MOZ_ASSERT(GetCompositorHwnd());
gfxCriticalNote << "Failed to create SwapChain for DComp";
aError.Assign("RcANGLE(create swapchain for dcomp failed)"_ns);
return false;
}
@ -286,7 +289,8 @@ bool RenderCompositorANGLE::CreateSwapChain() {
mUseTripleBuffering = useTripleBuffering;
} else if (gfx::gfxVars::UseWebRenderFlipSequentialWin()) {
MOZ_ASSERT(GetCompositorHwnd());
gfxCriticalNote << "Failed to create flip mode SwapChain";
aError.Assign(
nsPrintfCString("RcANGLE(swap chain hwnd create failed %x)", hr));
return false;
}
}
@ -310,7 +314,8 @@ bool RenderCompositorANGLE::CreateSwapChain() {
HRESULT hr = dxgiFactory->CreateSwapChain(dxgiDevice, &swapDesc,
getter_AddRefs(mSwapChain));
if (FAILED(hr)) {
gfxCriticalNote << "Could not create swap chain: " << gfx::hexa(hr);
aError.Assign(
nsPrintfCString("RcANGLE(swap chain create failed %x)", hr));
return false;
}
@ -326,6 +331,7 @@ bool RenderCompositorANGLE::CreateSwapChain() {
dxgiFactory->MakeWindowAssociation(hwnd, DXGI_MWA_NO_WINDOW_CHANGES);
if (!ResizeBufferIfNeeded()) {
aError.Assign("RcANGLE(resize buffer failed)"_ns);
return false;
}

Просмотреть файл

@ -33,11 +33,11 @@ class DCLayerTree;
class RenderCompositorANGLE : public RenderCompositor {
public:
static UniquePtr<RenderCompositor> Create(
RefPtr<widget::CompositorWidget>&& aWidget);
RefPtr<widget::CompositorWidget>&& aWidget, nsACString& aError);
explicit RenderCompositorANGLE(RefPtr<widget::CompositorWidget>&& aWidget);
virtual ~RenderCompositorANGLE();
bool Initialize();
bool Initialize(nsACString& aError);
bool BeginFrame() override;
RenderedFrameId EndFrame(const nsTArray<DeviceIntRect>& aDirtyRects) final;
@ -110,12 +110,12 @@ class RenderCompositorANGLE : public RenderCompositor {
bool ResizeBufferIfNeeded();
bool CreateEGLSurface();
void DestroyEGLSurface();
ID3D11Device* GetDeviceOfEGLDisplay();
bool CreateSwapChain();
ID3D11Device* GetDeviceOfEGLDisplay(nsACString& aError);
bool CreateSwapChain(nsACString& aError);
void CreateSwapChainForDCompIfPossible(IDXGIFactory2* aDXGIFactory2);
RefPtr<IDXGISwapChain1> CreateSwapChainForDComp(bool aUseTripleBuffering,
bool aUseAlpha);
bool ShutdownEGLLibraryIfNecessary();
bool ShutdownEGLLibraryIfNecessary(nsACString& aError);
RefPtr<ID3D11Query> GetD3D11Query();
void ReleaseNativeCompositorResources();
HWND GetCompositorHwnd();

Просмотреть файл

@ -33,7 +33,7 @@ namespace mozilla::wr {
/* static */
UniquePtr<RenderCompositor> RenderCompositorEGL::Create(
RefPtr<widget::CompositorWidget> aWidget) {
RefPtr<widget::CompositorWidget> aWidget, nsACString& aError) {
#ifdef MOZ_WAYLAND
if (!gdk_display_get_default() ||
GDK_IS_X11_DISPLAY(gdk_display_get_default())) {

Просмотреть файл

@ -17,7 +17,7 @@ namespace wr {
class RenderCompositorEGL : public RenderCompositor {
public:
static UniquePtr<RenderCompositor> Create(
RefPtr<widget::CompositorWidget> aWidget);
RefPtr<widget::CompositorWidget> aWidget, nsACString& aError);
explicit RenderCompositorEGL(RefPtr<widget::CompositorWidget> aWidget);
virtual ~RenderCompositorEGL();

Просмотреть файл

@ -374,7 +374,7 @@ CompositorCapabilities RenderCompositorNative::GetCompositorCapabilities() {
/* static */
UniquePtr<RenderCompositor> RenderCompositorNativeOGL::Create(
RefPtr<widget::CompositorWidget>&& aWidget) {
RefPtr<widget::CompositorWidget>&& aWidget, nsACString& aError) {
RefPtr<gl::GLContext> gl = RenderThread::Get()->SharedGL();
if (!gl) {
gl = gl::GLContextProvider::CreateForCompositorWidget(
@ -491,7 +491,7 @@ void RenderCompositorNativeOGL::Unbind() {
/* static */
UniquePtr<RenderCompositor> RenderCompositorNativeSWGL::Create(
RefPtr<widget::CompositorWidget>&& aWidget) {
RefPtr<widget::CompositorWidget>&& aWidget, nsACString& aError) {
void* ctx = wr_swgl_create_context();
if (!ctx) {
gfxCriticalNote << "Failed SWGL context creation for WebRender";

Просмотреть файл

@ -142,7 +142,7 @@ static inline bool operator==(const RenderCompositorNative::TileKey& a0,
class RenderCompositorNativeOGL : public RenderCompositorNative {
public:
static UniquePtr<RenderCompositor> Create(
RefPtr<widget::CompositorWidget>&& aWidget);
RefPtr<widget::CompositorWidget>&& aWidget, nsACString& aError);
RenderCompositorNativeOGL(RefPtr<widget::CompositorWidget>&& aWidget,
RefPtr<gl::GLContext>&& aGL);
@ -176,7 +176,7 @@ class RenderCompositorNativeOGL : public RenderCompositorNative {
class RenderCompositorNativeSWGL : public RenderCompositorNative {
public:
static UniquePtr<RenderCompositor> Create(
RefPtr<widget::CompositorWidget>&& aWidget);
RefPtr<widget::CompositorWidget>&& aWidget, nsACString& aError);
RenderCompositorNativeSWGL(RefPtr<widget::CompositorWidget>&& aWidget,
void* aContext);

Просмотреть файл

@ -17,7 +17,7 @@ namespace wr {
/* static */
UniquePtr<RenderCompositor> RenderCompositorOGL::Create(
RefPtr<widget::CompositorWidget>&& aWidget) {
RefPtr<widget::CompositorWidget>&& aWidget, nsACString& aError) {
RefPtr<gl::GLContext> gl = RenderThread::Get()->SharedGL();
if (!gl) {
gl = gl::GLContextProvider::CreateForCompositorWidget(

Просмотреть файл

@ -16,7 +16,7 @@ namespace wr {
class RenderCompositorOGL : public RenderCompositor {
public:
static UniquePtr<RenderCompositor> Create(
RefPtr<widget::CompositorWidget>&& aWidget);
RefPtr<widget::CompositorWidget>&& aWidget, nsACString& aError);
RenderCompositorOGL(RefPtr<gl::GLContext>&& aGL,
RefPtr<widget::CompositorWidget>&& aWidget);

Просмотреть файл

@ -13,7 +13,7 @@ namespace wr {
/* static */
UniquePtr<RenderCompositor> RenderCompositorSWGL::Create(
RefPtr<widget::CompositorWidget>&& aWidget) {
RefPtr<widget::CompositorWidget>&& aWidget, nsACString& aError) {
void* ctx = wr_swgl_create_context();
if (!ctx) {
gfxCriticalNote << "Failed SWGL context creation for WebRender";

Просмотреть файл

@ -16,7 +16,7 @@ namespace wr {
class RenderCompositorSWGL : public RenderCompositor {
public:
static UniquePtr<RenderCompositor> Create(
RefPtr<widget::CompositorWidget>&& aWidget);
RefPtr<widget::CompositorWidget>&& aWidget, nsACString& aError);
RenderCompositorSWGL(RefPtr<widget::CompositorWidget>&& aWidget,
void* aContext);

Просмотреть файл

@ -84,10 +84,11 @@ class NewRenderer : public RendererEvent {
layers::AutoCompleteTask complete(mTask);
UniquePtr<RenderCompositor> compositor =
RenderCompositor::Create(std::move(mCompositorWidget));
RenderCompositor::Create(std::move(mCompositorWidget), *mError);
if (!compositor) {
// RenderCompositor::Create puts a message into gfxCriticalNote if it is
// nullptr
if (!mError->IsEmpty()) {
gfxCriticalNote << mError->BeginReading();
}
return;
}