deno
deno copied to clipboard
WebGPU errors are not reported
Failures are not reported to the user and lets the program sliently proceed. This is true for shader creation, pipeline and pipeline layout creation as well as device queue submission.
It's not possible to debug without re compiling Deno with a println in gfx_put! and gfx_ok! macros.
println is not a viable solution. errors are mostly handled correctly, however the API sucks, and pushErrorScope & popErrorScope should be used for error handling. webgpu method calls themselves usually don't throw errors (with some minor exceptions)
Ok, I think we still need to implement getCompilationInfo for shader errors
shader errors should already show up in error scopes.
also, getCompilationInfo is blocked by upstream wgpu.
Anything?
@sudokit are you using the pushErrorScope & popErrorScope APIs and not getting any errors? if so, could you share the code?
I had no idea those existsed!? No idea on how to use them either :p. I assume something like device.pushErrorScope("validation"); for example, and then it should error on invalid shader code when calling device.createShaderModule for example? Might have understood it wrongly. Something like this, i guess?
async getModule(device: GPUDevice): Promise<Result<GPUShaderModule, Error>> {
let code;
code = await this.getCode();
if (code.isErr()) return Err(code.unwrapErr());
code = code.unwrap();
device.pushErrorScope("validation");
const shaderModule = device.createShaderModule({ code: code });
device.popErrorScope(); // would error?
return Ok(shaderModule);
}
EDIT: ah no never miiind! device.popErrorScope(); returns with the error if it has one! And its beautiful hahaha. Thanks!! Do you constantly before every operation need to push an error scope, or can you just push it once and then pop errors as they come? And do you need to pop errors after every operation, or else they stack up (idk if im understanding this correctly)?
ok so this is something I dont 100% understand either, but i believe it is as follows:
can you just push it once and then pop errors as they come?
yes
And do you need to pop errors after every operation, or else they stack up
they stack up
however, you need to a scope for every time you might pop an error scope.
Also from your code:
device.popErrorScope(); // would error?
popErrorScope is async, and it returns the error, it doesnt throw it
Ah so everytime you might want to check for an potential error, you need to push a scope... And do they stack up even if you dont push a scope?
And yeah figured that it returned the error. So changed it to const err = await device.popErrorScope();
Wrapping my code within an error scope solves the issue for me. Here's how I did it:
await device.pushErrorScope("validation");
const shaderModule = device.createShaderModule({
code: "<foo bar>",
});
const error = await device.popErrorScope();
console.log(error);
Closing the issue because the (awkward) error management is intended as per spec