Bug 1629955 - Don't fail WebGPU Instance creation r=jgilbert

we can't fail at Navigator.gpu
Instead, we reject the promise of requestAdapter

Differential Revision: https://phabricator.services.mozilla.com/D70903

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dzmitry Malyshau 2020-04-14 21:11:10 +00:00
parent 86ff5eeab6
commit 8238a62e51

View File

@ -19,14 +19,13 @@ GPU_IMPL_CYCLE_COLLECTION(Instance, mBridge, mOwner)
/*static*/
already_AddRefed<Instance> Instance::Create(nsIGlobalObject* aOwner) {
if (!gfx::gfxConfig::IsEnabled(gfx::Feature::WEBGPU)) {
return nullptr;
}
RefPtr<WebGPUChild> bridge;
RefPtr<WebGPUChild> bridge =
layers::CompositorBridgeChild::Get()->GetWebGPUChild();
if (NS_WARN_IF(!bridge)) {
MOZ_CRASH("Failed to create an IPDL bridge for WebGPU!");
if (gfx::gfxConfig::IsEnabled(gfx::Feature::WEBGPU)) {
bridge = layers::CompositorBridgeChild::Get()->GetWebGPUChild();
if (NS_WARN_IF(!bridge)) {
MOZ_CRASH("Failed to create an IPDL bridge for WebGPU!");
}
}
RefPtr<Instance> result = new Instance(aOwner, bridge);
@ -51,6 +50,10 @@ already_AddRefed<dom::Promise> Instance::RequestAdapter(
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}
if (!mBridge) {
promise->MaybeRejectWithInvalidStateError("WebGPU is not enabled!");
return promise.forget();
}
RefPtr<Instance> instance = this;