Commit dc990b30 authored by Austin Eng's avatar Austin Eng Committed by Chromium LUCI CQ

WebGPU: resolve requestAdapter to null if we fail to get an adapter

This is the correct behavior instead of rejecting the Promise.

Bug: 852089
Change-Id: I847ff4103084be35696705af8bb06bb1ecb701a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2617499Reviewed-by: default avatarKai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842143}
parent b458963f
......@@ -18,14 +18,9 @@
}
async function init(canvas, color) {
let adapter = null;
try {
adapter = await navigator.gpu.requestAdapter();
} catch (err) {
// TODO: remove try and catch here once we no longer expect rejections here.
// According to the spec, rejection should only happen when invalid stuff is passed in.
console.warn("request adapter failed:", err);
let adapter = await navigator.gpu.requestAdapter();
if (!adapter) {
console.warn('Failed to get WebGPU adapter');
}
let device = await adapter.requestDevice();
......@@ -152,4 +147,4 @@
<div id='container'></div>
</body>
</html>
\ No newline at end of file
</html>
......@@ -184,8 +184,7 @@ ScriptPromise GPU::requestAdapter(ScriptState* script_state,
// Failed to create context provider, won't be able to request adapter
// TODO(crbug.com/973017): Collect GPU info and surface context creation
// error.
resolver->Reject(MakeGarbageCollected<DOMException>(
DOMExceptionCode::kOperationError, "Fail to request GPUAdapter"));
resolver->Resolve(v8::Null(script_state->GetIsolate()));
return promise;
} else {
// Make a new DawnControlClientHolder with the context provider we just
......@@ -209,8 +208,7 @@ ScriptPromise GPU::requestAdapter(ScriptState* script_state,
WTF::Bind(&GPU::OnRequestAdapterCallback, WrapPersistent(this),
WrapPersistent(script_state), WrapPersistent(options),
WrapPersistent(resolver)))) {
resolver->Reject(MakeGarbageCollected<DOMException>(
DOMExceptionCode::kOperationError, "Fail to request GPUAdapter"));
resolver->Resolve(v8::Null(script_state->GetIsolate()));
}
return promise;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment