Bug 1662836 - Expose detailed initialization failure reason for WebRender. r=kvark

We don't know why we see initialization failures in the telemetry which
makes it hard to investigate why users aren't getting WebRender and
instead fallback to basic. Let's expose the detailed error message
WebRender already generates and puts in the critical log.

Differential Revision: https://phabricator.services.mozilla.com/D89185
This commit is contained in:
Andrew Osmond 2020-09-08 02:03:26 +00:00
Родитель 0acd64c691
Коммит c45c3ac881
14 изменённых файлов: 59 добавлений и 30 удалений

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

@ -2700,9 +2700,10 @@ bool BrowserChild::CreateRemoteLayerManager(
success = mPuppetWidget->CreateRemoteLayerManager( success = mPuppetWidget->CreateRemoteLayerManager(
[&](LayerManager* aLayerManager) -> bool { [&](LayerManager* aLayerManager) -> bool {
MOZ_ASSERT(aLayerManager->AsWebRenderLayerManager()); MOZ_ASSERT(aLayerManager->AsWebRenderLayerManager());
nsCString error;
return aLayerManager->AsWebRenderLayerManager()->Initialize( return aLayerManager->AsWebRenderLayerManager()->Initialize(
aCompositorChild, wr::AsPipelineId(mLayersId), aCompositorChild, wr::AsPipelineId(mLayersId),
&mTextureFactoryIdentifier); &mTextureFactoryIdentifier, error);
}); });
} else { } else {
nsTArray<LayersBackend> ignored; nsTArray<LayersBackend> ignored;

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

@ -446,7 +446,8 @@ void GPUProcessManager::SimulateDeviceReset() {
} }
} }
void GPUProcessManager::DisableWebRender(wr::WebRenderError aError) { void GPUProcessManager::DisableWebRender(wr::WebRenderError aError,
const nsCString& aMsg) {
if (!gfx::gfxVars::UseWebRender()) { if (!gfx::gfxVars::UseWebRender()) {
return; return;
} }
@ -454,8 +455,7 @@ void GPUProcessManager::DisableWebRender(wr::WebRenderError aError) {
if (aError == wr::WebRenderError::INITIALIZE) { if (aError == wr::WebRenderError::INITIALIZE) {
gfx::gfxConfig::GetFeature(gfx::Feature::WEBRENDER) gfx::gfxConfig::GetFeature(gfx::Feature::WEBRENDER)
.ForceDisable(gfx::FeatureStatus::Unavailable, .ForceDisable(gfx::FeatureStatus::Unavailable,
"WebRender initialization failed", "WebRender initialization failed", aMsg);
"FEATURE_FAILURE_WEBRENDER_INITIALIZE"_ns);
} else if (aError == wr::WebRenderError::MAKE_CURRENT) { } else if (aError == wr::WebRenderError::MAKE_CURRENT) {
gfx::gfxConfig::GetFeature(gfx::Feature::WEBRENDER) gfx::gfxConfig::GetFeature(gfx::Feature::WEBRENDER)
.ForceDisable(gfx::FeatureStatus::Unavailable, .ForceDisable(gfx::FeatureStatus::Unavailable,
@ -493,7 +493,7 @@ void GPUProcessManager::DisableWebRender(wr::WebRenderError aError) {
} }
void GPUProcessManager::NotifyWebRenderError(wr::WebRenderError aError) { void GPUProcessManager::NotifyWebRenderError(wr::WebRenderError aError) {
DisableWebRender(aError); DisableWebRender(aError, nsCString());
} }
void GPUProcessManager::OnInProcessDeviceReset() { void GPUProcessManager::OnInProcessDeviceReset() {

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

@ -149,7 +149,7 @@ class GPUProcessManager final : public GPUProcessHost::Listener {
void OnProcessLaunchComplete(GPUProcessHost* aHost) override; void OnProcessLaunchComplete(GPUProcessHost* aHost) override;
void OnProcessUnexpectedShutdown(GPUProcessHost* aHost) override; void OnProcessUnexpectedShutdown(GPUProcessHost* aHost) override;
void SimulateDeviceReset(); void SimulateDeviceReset();
void DisableWebRender(wr::WebRenderError aError); void DisableWebRender(wr::WebRenderError aError, const nsCString& aMsg);
void NotifyWebRenderError(wr::WebRenderError aError); void NotifyWebRenderError(wr::WebRenderError aError);
void OnInProcessDeviceReset(); void OnInProcessDeviceReset();
void OnRemoteProcessDeviceReset(GPUProcessHost* aHost) override; void OnRemoteProcessDeviceReset(GPUProcessHost* aHost) override;

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

@ -1951,10 +1951,13 @@ PWebRenderBridgeParent* CompositorBridgeParent::AllocPWebRenderBridgeParent(
// Same, but for the OMTA sampler. // Same, but for the OMTA sampler.
mOMTASampler->SetWebRenderWindowId(windowId); mOMTASampler->SetWebRenderWindowId(windowId);
} }
nsCString error;
RefPtr<wr::WebRenderAPI> api = RefPtr<wr::WebRenderAPI> api =
wr::WebRenderAPI::Create(this, std::move(widget), windowId, aSize); wr::WebRenderAPI::Create(this, std::move(widget), windowId, aSize, error);
if (!api) { if (!api) {
mWrBridge = WebRenderBridgeParent::CreateDestroyed(aPipelineId); mWrBridge =
WebRenderBridgeParent::CreateDestroyed(aPipelineId, std::move(error));
mWrBridge.get()->AddRef(); // IPDL reference mWrBridge.get()->AddRef(); // IPDL reference
return mWrBridge; return mWrBridge;
} }

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

@ -237,8 +237,9 @@ ContentCompositorBridgeParent::AllocPWebRenderBridgeParent(
nsPrintfCString("Created child without a matching parent? root %p", nsPrintfCString("Created child without a matching parent? root %p",
root.get()) root.get())
.get()); .get());
nsCString error("NO_PARENT");
WebRenderBridgeParent* parent = WebRenderBridgeParent* parent =
WebRenderBridgeParent::CreateDestroyed(aPipelineId); WebRenderBridgeParent::CreateDestroyed(aPipelineId, std::move(error));
parent->AddRef(); // IPDL reference parent->AddRef(); // IPDL reference
return parent; return parent;
} }

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

@ -41,7 +41,7 @@ sync protocol PWebRenderBridge
parent: parent:
sync EnsureConnected() sync EnsureConnected()
returns (TextureFactoryIdentifier textureFactoryIdentifier, MaybeIdNamespace maybeIdNamespace); returns (TextureFactoryIdentifier textureFactoryIdentifier, MaybeIdNamespace maybeIdNamespace, nsCString error);
async NewCompositable(CompositableHandle handle, TextureInfo info); async NewCompositable(CompositableHandle handle, TextureInfo info);
async ReleaseCompositable(CompositableHandle compositable); async ReleaseCompositable(CompositableHandle compositable);

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

@ -365,13 +365,15 @@ WebRenderBridgeParent::WebRenderBridgeParent(
UpdateQualitySettings(); UpdateQualitySettings();
} }
WebRenderBridgeParent::WebRenderBridgeParent(const wr::PipelineId& aPipelineId) WebRenderBridgeParent::WebRenderBridgeParent(const wr::PipelineId& aPipelineId,
nsCString&& aError)
: mCompositorBridge(nullptr), : mCompositorBridge(nullptr),
mPipelineId(aPipelineId), mPipelineId(aPipelineId),
mChildLayersObserverEpoch{0}, mChildLayersObserverEpoch{0},
mParentLayersObserverEpoch{0}, mParentLayersObserverEpoch{0},
mWrEpoch{0}, mWrEpoch{0},
mIdNamespace{0}, mIdNamespace{0},
mInitError(aError),
mPaused(false), mPaused(false),
mDestroyed(true), mDestroyed(true),
mReceivedDisplayList(false), mReceivedDisplayList(false),
@ -384,17 +386,18 @@ WebRenderBridgeParent::~WebRenderBridgeParent() {}
/* static */ /* static */
WebRenderBridgeParent* WebRenderBridgeParent::CreateDestroyed( WebRenderBridgeParent* WebRenderBridgeParent::CreateDestroyed(
const wr::PipelineId& aPipelineId) { const wr::PipelineId& aPipelineId, nsCString&& aError) {
return new WebRenderBridgeParent(aPipelineId); return new WebRenderBridgeParent(aPipelineId, std::move(aError));
} }
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvEnsureConnected( mozilla::ipc::IPCResult WebRenderBridgeParent::RecvEnsureConnected(
TextureFactoryIdentifier* aTextureFactoryIdentifier, TextureFactoryIdentifier* aTextureFactoryIdentifier,
MaybeIdNamespace* aMaybeIdNamespace) { MaybeIdNamespace* aMaybeIdNamespace, nsCString* aError) {
if (mDestroyed) { if (mDestroyed) {
*aTextureFactoryIdentifier = *aTextureFactoryIdentifier =
TextureFactoryIdentifier(LayersBackend::LAYERS_NONE); TextureFactoryIdentifier(LayersBackend::LAYERS_NONE);
*aMaybeIdNamespace = Nothing(); *aMaybeIdNamespace = Nothing();
*aError = std::move(mInitError);
return IPC_OK(); return IPC_OK();
} }

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

@ -113,7 +113,7 @@ class WebRenderBridgeParent final : public PWebRenderBridgeParent,
TimeDuration aVsyncRate); TimeDuration aVsyncRate);
static WebRenderBridgeParent* CreateDestroyed( static WebRenderBridgeParent* CreateDestroyed(
const wr::PipelineId& aPipelineId); const wr::PipelineId& aPipelineId, nsCString&& aError);
wr::PipelineId PipelineId() { return mPipelineId; } wr::PipelineId PipelineId() { return mPipelineId; }
already_AddRefed<wr::WebRenderAPI> GetWebRenderAPI() { already_AddRefed<wr::WebRenderAPI> GetWebRenderAPI() {
@ -134,7 +134,7 @@ class WebRenderBridgeParent final : public PWebRenderBridgeParent,
mozilla::ipc::IPCResult RecvEnsureConnected( mozilla::ipc::IPCResult RecvEnsureConnected(
TextureFactoryIdentifier* aTextureFactoryIdentifier, TextureFactoryIdentifier* aTextureFactoryIdentifier,
MaybeIdNamespace* aMaybeIdNamespace) override; MaybeIdNamespace* aMaybeIdNamespace, nsCString* aError) override;
mozilla::ipc::IPCResult RecvNewCompositable( mozilla::ipc::IPCResult RecvNewCompositable(
const CompositableHandle& aHandle, const TextureInfo& aInfo) override; const CompositableHandle& aHandle, const TextureInfo& aInfo) override;
@ -335,7 +335,7 @@ class WebRenderBridgeParent final : public PWebRenderBridgeParent,
private: private:
class ScheduleSharedSurfaceRelease; class ScheduleSharedSurfaceRelease;
explicit WebRenderBridgeParent(const wr::PipelineId& aPipelineId); WebRenderBridgeParent(const wr::PipelineId& aPipelineId, nsCString&& aError);
virtual ~WebRenderBridgeParent(); virtual ~WebRenderBridgeParent();
bool ProcessEmptyTransactionUpdates(TransactionData& aData, bool ProcessEmptyTransactionUpdates(TransactionData& aData,
@ -507,6 +507,7 @@ class WebRenderBridgeParent final : public PWebRenderBridgeParent,
wr::Epoch mWrEpoch; wr::Epoch mWrEpoch;
wr::IdNamespace mIdNamespace; wr::IdNamespace mIdNamespace;
CompositionOpportunityId mCompositionOpportunityId; CompositionOpportunityId mCompositionOpportunityId;
nsCString mInitError;
VsyncId mSkippedCompositeId; VsyncId mSkippedCompositeId;
TimeStamp mMostRecentComposite; TimeStamp mMostRecentComposite;

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

@ -58,7 +58,7 @@ KnowsCompositor* WebRenderLayerManager::AsKnowsCompositor() { return mWrChild; }
bool WebRenderLayerManager::Initialize( bool WebRenderLayerManager::Initialize(
PCompositorBridgeChild* aCBChild, wr::PipelineId aLayersId, PCompositorBridgeChild* aCBChild, wr::PipelineId aLayersId,
TextureFactoryIdentifier* aTextureFactoryIdentifier) { TextureFactoryIdentifier* aTextureFactoryIdentifier, nsCString& aError) {
MOZ_ASSERT(mWrChild == nullptr); MOZ_ASSERT(mWrChild == nullptr);
MOZ_ASSERT(aTextureFactoryIdentifier); MOZ_ASSERT(aTextureFactoryIdentifier);
@ -71,13 +71,14 @@ bool WebRenderLayerManager::Initialize(
// reinitialization. We can expect to be notified again to reinitialize // reinitialization. We can expect to be notified again to reinitialize
// (which may or may not be using WebRender). // (which may or may not be using WebRender).
gfxCriticalNote << "Failed to create WebRenderBridgeChild."; gfxCriticalNote << "Failed to create WebRenderBridgeChild.";
aError.AssignLiteral("FEATURE_FAILURE_WEBRENDER_INITIALIZE_IPDL");
return false; return false;
} }
TextureFactoryIdentifier textureFactoryIdentifier; TextureFactoryIdentifier textureFactoryIdentifier;
wr::MaybeIdNamespace idNamespace; wr::MaybeIdNamespace idNamespace;
// Sync ipc // Sync ipc
bridge->SendEnsureConnected(&textureFactoryIdentifier, &idNamespace); bridge->SendEnsureConnected(&textureFactoryIdentifier, &idNamespace, &aError);
if (textureFactoryIdentifier.mParentBackend == LayersBackend::LAYERS_NONE || if (textureFactoryIdentifier.mParentBackend == LayersBackend::LAYERS_NONE ||
idNamespace.isNothing()) { idNamespace.isNothing()) {
gfxCriticalNote << "Failed to connect WebRenderBridgeChild."; gfxCriticalNote << "Failed to connect WebRenderBridgeChild.";

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

@ -52,7 +52,8 @@ class WebRenderLayerManager final : public LayerManager {
public: public:
explicit WebRenderLayerManager(nsIWidget* aWidget); explicit WebRenderLayerManager(nsIWidget* aWidget);
bool Initialize(PCompositorBridgeChild* aCBChild, wr::PipelineId aLayersId, bool Initialize(PCompositorBridgeChild* aCBChild, wr::PipelineId aLayersId,
TextureFactoryIdentifier* aTextureFactoryIdentifier); TextureFactoryIdentifier* aTextureFactoryIdentifier,
nsCString& aError);
void Destroy() override; void Destroy() override;

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

@ -63,7 +63,7 @@ class NewRenderer : public RendererEvent {
bool* aUseANGLE, bool* aUseDComp, bool* aUseTripleBuffering, bool* aUseANGLE, bool* aUseDComp, bool* aUseTripleBuffering,
RefPtr<widget::CompositorWidget>&& aWidget, RefPtr<widget::CompositorWidget>&& aWidget,
layers::SynchronousTask* aTask, LayoutDeviceIntSize aSize, layers::SynchronousTask* aTask, LayoutDeviceIntSize aSize,
layers::SyncHandle* aHandle) layers::SyncHandle* aHandle, nsACString* aError)
: mDocHandle(aDocHandle), : mDocHandle(aDocHandle),
mMaxTextureSize(aMaxTextureSize), mMaxTextureSize(aMaxTextureSize),
mUseANGLE(aUseANGLE), mUseANGLE(aUseANGLE),
@ -73,7 +73,8 @@ class NewRenderer : public RendererEvent {
mCompositorWidget(std::move(aWidget)), mCompositorWidget(std::move(aWidget)),
mTask(aTask), mTask(aTask),
mSize(aSize), mSize(aSize),
mSyncHandle(aHandle) { mSyncHandle(aHandle),
mError(aError) {
MOZ_COUNT_CTOR(NewRenderer); MOZ_COUNT_CTOR(NewRenderer);
} }
@ -110,6 +111,7 @@ class NewRenderer : public RendererEvent {
StaticPrefs::gfx_webrender_enable_low_priority_pool(); StaticPrefs::gfx_webrender_enable_low_priority_pool();
bool supportPictureCaching = isMainWindow; bool supportPictureCaching = isMainWindow;
wr::Renderer* wrRenderer = nullptr; wr::Renderer* wrRenderer = nullptr;
char* errorMessage = nullptr;
if (!wr_window_new( if (!wr_window_new(
aWindowId, mSize.width, mSize.height, aWindowId, mSize.width, mSize.height,
supportLowPriorityTransactions, supportLowPriorityThreadpool, supportLowPriorityTransactions, supportLowPriorityThreadpool,
@ -138,10 +140,13 @@ class NewRenderer : public RendererEvent {
compositor->GetMaxUpdateRects(), compositor->GetMaxUpdateRects(),
compositor->GetMaxPartialPresentRects(), compositor->GetMaxPartialPresentRects(),
compositor->ShouldDrawPreviousPartialPresentRegions(), mDocHandle, compositor->ShouldDrawPreviousPartialPresentRegions(), mDocHandle,
&wrRenderer, mMaxTextureSize, &wrRenderer, mMaxTextureSize, &errorMessage,
StaticPrefs::gfx_webrender_enable_gpu_markers_AtStartup(), StaticPrefs::gfx_webrender_enable_gpu_markers_AtStartup(),
panic_on_gl_error)) { panic_on_gl_error)) {
// wr_window_new puts a message into gfxCriticalNote if it returns false // wr_window_new puts a message into gfxCriticalNote if it returns false
MOZ_ASSERT(errorMessage);
mError->AssignASCII(errorMessage);
wr_api_free_error_msg(errorMessage);
return; return;
} }
MOZ_ASSERT(wrRenderer); MOZ_ASSERT(wrRenderer);
@ -176,6 +181,7 @@ class NewRenderer : public RendererEvent {
layers::SynchronousTask* mTask; layers::SynchronousTask* mTask;
LayoutDeviceIntSize mSize; LayoutDeviceIntSize mSize;
layers::SyncHandle* mSyncHandle; layers::SyncHandle* mSyncHandle;
nsACString* mError;
}; };
class RemoveRenderer : public RendererEvent { class RemoveRenderer : public RendererEvent {
@ -324,7 +330,7 @@ void TransactionWrapper::UpdateIsTransformAsyncZooming(uint64_t aAnimationId,
already_AddRefed<WebRenderAPI> WebRenderAPI::Create( already_AddRefed<WebRenderAPI> WebRenderAPI::Create(
layers::CompositorBridgeParent* aBridge, layers::CompositorBridgeParent* aBridge,
RefPtr<widget::CompositorWidget>&& aWidget, const wr::WrWindowId& aWindowId, RefPtr<widget::CompositorWidget>&& aWidget, const wr::WrWindowId& aWindowId,
LayoutDeviceIntSize aSize) { LayoutDeviceIntSize aSize, nsACString& aError) {
MOZ_ASSERT(aBridge); MOZ_ASSERT(aBridge);
MOZ_ASSERT(aWidget); MOZ_ASSERT(aWidget);
static_assert( static_assert(
@ -342,9 +348,10 @@ already_AddRefed<WebRenderAPI> WebRenderAPI::Create(
// created on the render thread. If need be we could delay waiting on this // created on the render thread. If need be we could delay waiting on this
// task until the next time we need to access the DocumentHandle object. // task until the next time we need to access the DocumentHandle object.
layers::SynchronousTask task("Create Renderer"); layers::SynchronousTask task("Create Renderer");
auto event = MakeUnique<NewRenderer>( auto event = MakeUnique<NewRenderer>(&docHandle, aBridge, &maxTextureSize,
&docHandle, aBridge, &maxTextureSize, &useANGLE, &useDComp, &useANGLE, &useDComp,
&useTripleBuffering, std::move(aWidget), &task, aSize, &syncHandle); &useTripleBuffering, std::move(aWidget),
&task, aSize, &syncHandle, &aError);
RenderThread::Get()->RunEvent(aWindowId, std::move(event)); RenderThread::Get()->RunEvent(aWindowId, std::move(event));
task.Wait(); task.Wait();

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

@ -231,7 +231,8 @@ class WebRenderAPI final {
static already_AddRefed<WebRenderAPI> Create( static already_AddRefed<WebRenderAPI> Create(
layers::CompositorBridgeParent* aBridge, layers::CompositorBridgeParent* aBridge,
RefPtr<widget::CompositorWidget>&& aWidget, RefPtr<widget::CompositorWidget>&& aWidget,
const wr::WrWindowId& aWindowId, LayoutDeviceIntSize aSize); const wr::WrWindowId& aWindowId, LayoutDeviceIntSize aSize,
nsACString& aError);
already_AddRefed<WebRenderAPI> Clone(); already_AddRefed<WebRenderAPI> Clone();

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

@ -1430,6 +1430,7 @@ pub extern "C" fn wr_window_new(
out_handle: &mut *mut DocumentHandle, out_handle: &mut *mut DocumentHandle,
out_renderer: &mut *mut Renderer, out_renderer: &mut *mut Renderer,
out_max_texture_size: *mut i32, out_max_texture_size: *mut i32,
out_err: &mut *mut c_char,
enable_gpu_markers: bool, enable_gpu_markers: bool,
panic_on_gl_error: bool, panic_on_gl_error: bool,
) -> bool { ) -> bool {
@ -1578,6 +1579,7 @@ pub extern "C" fn wr_window_new(
unsafe { unsafe {
gfx_critical_note(msg.as_ptr()); gfx_critical_note(msg.as_ptr());
} }
*out_err = msg.into_raw();
return false; return false;
} }
}; };
@ -1598,6 +1600,13 @@ pub extern "C" fn wr_window_new(
return true; return true;
} }
#[no_mangle]
pub unsafe extern "C" fn wr_api_free_error_msg(msg: *mut c_char) {
if msg != ptr::null_mut() {
CString::from_raw(msg);
}
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn wr_api_delete_document(dh: &mut DocumentHandle) { pub unsafe extern "C" fn wr_api_delete_document(dh: &mut DocumentHandle) {
dh.api.delete_document(dh.document_id); dh.api.delete_document(dh.document_id);

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

@ -1222,16 +1222,17 @@ already_AddRefed<LayerManager> nsBaseWidget::CreateCompositorSession(
if (lm->AsWebRenderLayerManager() && mCompositorSession) { if (lm->AsWebRenderLayerManager() && mCompositorSession) {
TextureFactoryIdentifier textureFactoryIdentifier; TextureFactoryIdentifier textureFactoryIdentifier;
nsCString error;
lm->AsWebRenderLayerManager()->Initialize( lm->AsWebRenderLayerManager()->Initialize(
mCompositorSession->GetCompositorBridgeChild(), mCompositorSession->GetCompositorBridgeChild(),
wr::AsPipelineId(mCompositorSession->RootLayerTreeId()), wr::AsPipelineId(mCompositorSession->RootLayerTreeId()),
&textureFactoryIdentifier); &textureFactoryIdentifier, error);
if (textureFactoryIdentifier.mParentBackend != LayersBackend::LAYERS_WR) { if (textureFactoryIdentifier.mParentBackend != LayersBackend::LAYERS_WR) {
retry = true; retry = true;
DestroyCompositor(); DestroyCompositor();
// gfxVars::UseDoubleBufferingWithCompositor() is also disabled. // gfxVars::UseDoubleBufferingWithCompositor() is also disabled.
gfx::GPUProcessManager::Get()->DisableWebRender( gfx::GPUProcessManager::Get()->DisableWebRender(
wr::WebRenderError::INITIALIZE); wr::WebRenderError::INITIALIZE, error);
} }
} else if (lm->AsClientLayerManager() && mCompositorSession) { } else if (lm->AsClientLayerManager() && mCompositorSession) {
bool shouldAccelerate = ComputeShouldAccelerate(); bool shouldAccelerate = ComputeShouldAccelerate();