Skip to content
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

WebGPU: Deno Panics when a destroyed texture is used in a render pass #25870

Open
matthew-wong1 opened this issue Sep 25, 2024 · 2 comments
Open
Labels
webgpu WebGPU API

Comments

@matthew-wong1
Copy link

Hi!

The following WebGPU program panics when a destroyed texture is used in a render pass. I think the correct behaviour is to throw some sort of validation error instead.

I've tested this on v1.46.3 and 2.0.0-rc.5, and both versions produce the same error. I've only tested this on macOS.

Here is the WebGPU program:

const adapter = await navigator.gpu.requestAdapter();
const device = await adapter.requestDevice();
const encoder = device.createCommandEncoder();
const texture = device.createTexture({
  dimension: "2d",
  format: "rg16float",
  size: {
    width: 1540,
  },
  usage: GPUTextureUsage.RENDER_ATTACHMENT,
});

const textureView = texture.createView();
const renderPassEncoder = encoder.beginRenderPass({
  colorAttachments: [
    {
      r: 1.0,
      loadOp: "load",
      storeOp: "store",
      view: textureView,
    },
  ],
});
texture.destroy();

renderPassEncoder.end();

This is how I ran the program:

RUST_BACKTRACE=1 DENO_WEBGPU_BACKEND=metal deno run --allow-read --unstable-webgpu --allow-write webgpu.js

And here is the backtrace:

thread 'main' panicked at /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-core-0.21.1/src/storage.rs:113:39:
TextureView[Id(0,1,mtl)] does not exist
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: wgpu_core::storage::Storage<T>::get
   3: wgpu_core::track::stateless::StatelessTracker<T>::add_single
   4: wgpu_core::command::render::<impl wgpu_core::global::Global>::command_encoder_run_render_pass_impl
   5: wgpu_core::command::render::<impl wgpu_core::global::Global>::command_encoder_run_render_pass
   6: deno_webgpu::render_pass::op_webgpu_render_pass_end::op_webgpu_render_pass_end::v8_fn_ptr
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
@matthew-wong1
Copy link
Author

The same panic (same line) also occurs if you create a query set and then destroy it (in a similar manner to the texture view above).

@crowlKats crowlKats added bug Something isn't working correctly webgpu WebGPU API labels Sep 25, 2024
@crowlKats
Copy link
Member

This might be fixed in recent wgpu (the rust crate) releases. After 2.0 I will take a look into doing an update of the crates and will see if this is then fixed. else if this is still present upstream, i'll see to it that this gets fixed

@crowlKats crowlKats removed the bug Something isn't working correctly label Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
webgpu WebGPU API
Projects
None yet
Development

No branches or pull requests

2 participants