Repository navigation
Conversation
|
Apologies for getting this out late, but here's the next revision of this part of error handling. We might be able to talk about this at the next meeting if people do have a chance to look. |
| `device.getLastOperationStatus()` always resolves to the status of the most recent void-returning operation. | ||
| If called multiple times in a row, it returns the same result (but not the same object). | ||
|
|
||
| `getLastOperationStatus` returns a Promise that resolves to a `GPUOperationStatus` object describing the status of the last operation on this object. |
There was a problem hiding this comment.
For testing we would also like to make sure no errors happened in previous operations and not just the current operation.
| Regardless of any recovery efforts the application makes, if creation fails, | ||
| the resulting object is invalid (and subject to error propagation). | ||
| - `getOperationStatuses`: returns a sequence of statuses for past operations. | ||
| Con: sequence will grow unboundedly unless there is some arbitrary limit. |
There was a problem hiding this comment.
I think that's ok, in general we only care about whether at least one error happened or none happened.
|
It is nice that this approach unifies OOM and validation errors but I have some concerns, and maybe an alternative. One concern is that in the proposal the interactions of Another concern is that it makes it easy to call Finally it adds a lot of different mechanisms to handle different types of errors when it feels like they could all be unified (except device lost). The alternative below tries to make OOM, telemetry, createReady and testing all use the same mechanism. // GPUErrorStatus is the same as this proposal's GPUObjectStatus
partial interface GPUDevice : EventTarget {
void pushErrorScope();
Promise<GPUStatus> popErrorScope();
attribute EventHandler unscopederror; // The event is essentially a GPUErrorStatus
};The idea being that scopes capture the first error that is triggered while they are active as the innermost scope (or no error) and resolve the promise with that status. The promise reject on device loss and if an error is generated with no error scope present then the event is fired (with errors being skipped after a while). Checking for OOM is the following: device.pushErrorScope();
const texture = device.createTexture({
// descriptor
});
const textureStatus = await device.popErrorScope();
if (!textureStatus.succeeded) {
// stuff depending on OOM, testing
}
device.pushErrorScope();
const pipeline = device.createPipeline({
// descriptor
});
const pipelineStatus = await device.popErrorScope();
if (!pipelineStatus.succeeded) {
// Forward to telemetry
}
// Object is created.Testing error happens exactly in a function call looks like the following: device.pushErrorScope();
// Do stuff that shouldn't produce errors.
{
device.pushErrorScope();
device.doOperationThatErrors();
device.popErrorScope().then(status => assert(!status.succeeded));
}
// More stuff that doesn't produce errors
device.popErrorScope().then(status => assert(status.succeeded));For applications that handle error scoping only for particular object (OOM or waiting for the object to be created), then telemetry would use the event handler for unscoped errors: device.addEventListener('unscopederror', (event) => {
appendToTelemetryReport(event.message);
});Questions:
|
|
I strongly agree that the interactions of the various error mechanisms is unclear. It's one of the reasons that it took me a long time to even get to this proposal. I'll read and consider the rest of your comment as soon as I have a chance. |
| a `"recoverable-out-of-memory"` error for the object creation, and `"validation-error"`s for any subsequent uses of the invalid object. | ||
| The application may need to understand whether such error log entries were part of a recovered allocation (e.g. to avoid sending telemetry for those errors). | ||
| To facilitate this filtering, the handle to the invalid object (including "expando" JavaScript properties) is attached to the error log entry (see above). | ||
| - Instead of `device.getStatus(obj)`, have `obj.getStatus()`. Con: Pollutes objects with rarely-used methods. Pro: Maybe slightly more clear to users. |
There was a problem hiding this comment.
Nit: This is the first time in the document where you mention device.getStatus(obj) vs. obj.getStatus(). All this time, I thought the proposal was the latter. I suggest having this discussion earlier in the document.
There was a problem hiding this comment.
That is because I changed it and didn't do a good job of fixing up the references. Thanks for catching this.
There was a problem hiding this comment.
Con: Pollutes objects with rarely-used methods.
Have we thought about having GPUStatusableObject as a base class object (that has getStatus() method) for the GPU* objects in the typedef?
There was a problem hiding this comment.
I considered it, but I'm more concerned with polluting actual objects, not polluting the IDL. This would still put one on every object.
I think I will be moving away from getStatus in the next iteration though.
| Through this mechanism, allocation failure ("out-of-memory") can also be expressed. | ||
|
|
||
| Object status can be queried with `getStatus`. | ||
| `getStatus` returns a Promise which resolves to a `GPUObjectStatus` object that reports the status of the object. |
There was a problem hiding this comment.
I do not think a promise returning getStatus is the right thing to do.
Having getStatus return a promise means code which used to run completely inside one requestAnimationFrame callback now runs across multiple task boundaries, thus delaying frames and changing the behavior of the application. This is particularly troubling for WebXR applications where pose information sent to its requestAnimationFrame callback becomes invalid outside of the callback.
I suggest we either make getStatus be synchronous or add a debug mode of the API where errors throw exceptions.
There was a problem hiding this comment.
The explainer should make lifetimes of each promise instance clear. For instance, if I call device.getStatus(object) multiple times in a row with the same object, do I get back the same promise instance or is a brand new promise returned for each call? If the latter, I presume the only time the promise from getStatus will ever reject is for contextLost?
The same issue also applies to getLastOperationStatus().
There was a problem hiding this comment.
Like with the rest of the API, I'm trying to avoid adding any synchronous stuff. What use case do you have in mind that would make it necessary to getObjectStatus synchronously?
E.g. for pose data, the app can use (1) an existing buffer with setSubData, (2) an existing, already mapped buffer, or (3) createBufferMapped
There was a problem hiding this comment.
I think we'll probably have a Dev Tools option to (synchronously) "break on WebGPU error" as the dev mode.
There was a problem hiding this comment.
Re: Use case:
The purpose of the PR is to add mechanisms whereby developers can easily debug their code when things go wrong. To that end, using the testing APIs should not change the behavior of the application with regard to the sequencing of RAFs in relation to one another or other events/callbacks running in the application.
There was a problem hiding this comment.
I am actually not trying to design these mechanisms for debugging, since Dev Tools would hopefully provide good tools.
But it's a good point that sometimes you do want more programmatic debugging tools (printf style). I'll keep it in mind.
| - `GPU*Encoder.*` | ||
|
|
||
| These commands do not report errors. | ||
| Instead, any error is reported by `GPUCommandEncoder.finish`. |
There was a problem hiding this comment.
When you say "any error is reported by GPUCommendEncoder.finish", does this mean GPUCommandEncoder.finish will be changed to return an error? I would expect to see an IDL change if that's the case.
There was a problem hiding this comment.
GPUCommandEncoder.finish returns a GPUCommandBuffer, and that GPUCommandBuffer is invalid.
|
Thanks Rafael and Corentin for all the feedback. I'll look at all of it together while trying to revise. |
This replaces #197 (tryCreate) and should also solve our conformance testing needs.