-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error handling and panic in observablehq notebook #165
Comments
Just try to change // before
const tmax = 2000.0;
// after
let tmax = 2000.0; Or declare it in module scope: const tmax = 2000.0;
fn main_image() {} I will check if it's a bug relative to naga, since according to WGSL Spec, a const-declaration can be declared in function scope: |
Thank you. Indeed the change you suggested fixes the error:
However, should this be a panic (sometimes just swallowed or displaying |
You're right, I should throw the compiling error message from |
I update both
Now the error message can be shown correctly. For example, in the
But we cannot use
So we have to do some alias work when borrowing shaders from alias int = i32;
alias uint = u32;
alias float = f32;
alias int2 = vec2<i32>;
alias int3 = vec3<i32>;
alias int4 = vec4<i32>;
alias uint2 = vec2<u32>;
alias uint3 = vec3<u32>;
alias uint4 = vec4<u32>;
alias float2 = vec2<f32>;
alias float3 = vec3<f32>;
alias float4 = vec4<f32>;
alias bool2 = vec2<bool>;
alias bool3 = vec3<bool>;
alias bool4 = vec4<bool>;
alias float2x2 = mat2x2<f32>;
alias float2x3 = mat2x3<f32>;
alias float2x4 = mat2x4<f32>;
alias float3x2 = mat3x2<f32>;
alias float3x3 = mat3x3<f32>;
alias float3x4 = mat3x4<f32>;
alias float4x2 = mat4x2<f32>;
alias float4x3 = mat4x3<f32>;
alias float4x4 = mat4x4<f32>; Or use predeclares instead, eg. |
* Fix 165 (#169) * fix: throw error message from naga #165 * chore: commit changeset * fix: remove new URL * chore(release): bump version (#170) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Just use the latest import { WebGPUDeviceContribution } from '@antv/g-device-api';
const deviceContribution = new WebGPUDeviceContribution({
shaderCompilerPath: '/glsl_wgsl_compiler_bg.wasm',
// From CDN
// shaderCompilerPath: 'https://unpkg.com/@antv/[email protected]/rust/pkg/glsl_wgsl_compiler_bg.wasm',
}); Calls device.beginFrame();
const computePass = device.createComputePass();
computePass.setPipeline(computePipeline);
computePass.setBindings(bindings);
computePass.dispatchWorkgroups(1);
device.submitPass(computePass);
device.endFrame(); |
Hi,
Sorry for opening the issue directly on github, but I cannot see this repo in the dropdown menu in https://antv-issue-helper.surge.sh
I created a reproducer in ObservableHQ for a panic when using a specific shader:
https://observablehq.com/d/bece57b91ebd5a40
I'm using a compute-toys notebook fork which pulls in the latest version @antv/[email protected]
The setup works for the origami shader, however when using shader code that compiles and runs fine in compute.toys (see https://compute.toys/view/1079) I can get the following stack trace in the console:
Additional context
Chrome on MacOS
Version 122.0.6261.94 (Official Build) (arm64)
I have noticed the following in regard to errors and error handling in general:
run
function take in the shader string, there are cases where in particular reusing the prelude without binding for instancetime.elapsed
will result in these errors being constantly spammed in the console.Using a trick such as:
Works to bypass that problem and avoid having to reinitialise each cell with a different set of bindings.
Is there a better way to enable using a notebook to progressively build a compute shader? Maybe some variables can be initialised and made available to the page first, like
device
and only runningcreateProgram()
anddevice.createComputePipeline()
on each cell? If you had a example notebook with this approach that would be great to be able to use observablehq to explain shaders step by step.Some code that runs on
compute.toys
doesn't work withg-device-api
. This seems to have to do with type checking.compute.toys
seems able to infer the types but this will spam this error message withg-device-api
:The fix is easy enough, but the error handling and lack of error messages makes it difficult to use.
Thank you very much for the great library, I'm really looking forward to using it more in observablehq and I hope my remarks are helpful to improve the error handling experience!
Cheers,
Jun
The text was updated successfully, but these errors were encountered: