Skip to content

Commit

Permalink
Change GPUDeviceLostReason undefined to "unknown"
Browse files Browse the repository at this point in the history
Spec change resolved here:
gpuweb/gpuweb#3894 (comment)

Fixed: 1424883
Change-Id: I316fbaf443a396fc993e0ac9e0d2c0fb9fa1ba42
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4342174
Auto-Submit: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1119661}
  • Loading branch information
kainino0x authored and Chromium LUCI CQ committed Mar 20, 2023
1 parent 5fca205 commit 2a30628
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 22 deletions.
4 changes: 2 additions & 2 deletions content/test/data/gpu/webgpu-domain-not-blocked.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
// NOT result in the domain being blocked.
console.log('Waiting for GPU termination to cause device loss');
const lost = await device.lost;
if (lost.reason !== undefined) {
console.log('TEST FAILED - Expected undefined device lost reason');
if (lost.reason !== 'unknown') {
console.log('TEST FAILED - Expected device lost reason "unknown"');
reportProgress('FAILED');
return;
}
Expand Down
4 changes: 2 additions & 2 deletions content/test/data/gpu/webgpu-domain-unblocking.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
// this should result in the domain being blocked.
console.log('Iteration ' + idx + ': Waiting for GPU crash to cause device loss');
const lost = await device.lost;
if (lost.reason !== undefined) {
console.log('TEST FAILED - Expected undefined device lost reason');
if (lost.reason !== 'unknown') {
console.log('TEST FAILED - Expected device lost reason "unknown"');
reportProgress('FAILED');
return;
}
Expand Down
22 changes: 11 additions & 11 deletions third_party/blink/renderer/modules/webgpu/gpu_device_lost_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@ namespace blink {

GPUDeviceLostInfo::GPUDeviceLostInfo(const WGPUDeviceLostReason reason,
const String& message) {
message_ = message;
switch (reason) {
case WGPUDeviceLostReason_Undefined:
reason_ = "unknown";
break;
case WGPUDeviceLostReason_Destroyed:
reason_ = "destroyed";
break;
default:
// Leave the reason as null indicating that it is not an expected scenario
// for the device to be lost.
// If this is hit, Dawn gave us a reason we haven't implemented here yet.
NOTREACHED();
reason_ = "unknown";
break;
}
}

const String& GPUDeviceLostInfo::message() const {
return message_;
message_ = message;
}

const ScriptValue GPUDeviceLostInfo::reason(ScriptState* script_state) const {
if (reason_.IsNull()) {
v8::Isolate* isolate = script_state->GetIsolate();
return ScriptValue(isolate, v8::Undefined(isolate));
}
return ScriptValue::From(script_state, reason_);
}

const String& GPUDeviceLostInfo::message() const {
return message_;
}

} // namespace blink
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ class GPUDeviceLostInfo : public ScriptWrappable {
GPUDeviceLostInfo& operator=(const GPUDeviceLostInfo&) = delete;

// gpu_device_lost_info.idl
const String& message() const;
const ScriptValue reason(ScriptState* script_state) const;
const String& message() const;

private:
String message_;
String reason_;
String message_;
};

} // namespace blink
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@
// https://gpuweb.github.io/gpuweb/

enum GPUDeviceLostReason {
"unknown",
"destroyed"
};

[
Exposed(Window WebGPU, DedicatedWorker WebGPU),
SecureContext
] interface GPUDeviceLostInfo {
[CallWith=ScriptState] readonly attribute GPUDeviceLostReason reason;
readonly attribute DOMString message;
// TODO: The type should be (GPUDeviceLostReason or undefined) but
// the bindings can't handle it now although it should be valid type.
// As a workaround we make the type any and do custom handling in Blink
// until the bindings supports it. Refer to crbug.com/1293259.
[CallWith=ScriptState] readonly attribute any reason;
};

0 comments on commit 2a30628

Please sign in to comment.