Open ErichDonGubler opened 5 hours ago
Copying my comment from bug 1930015:
I was able to reproduce this crash stack on my M1 MacBook Pro by running the following script:
const adapter = await navigator.gpu.requestAdapter() const device = await adapter.requestDevice({ requiredFeatures: ["timestamp-query"] }) device.createQuerySet({ type: "timestamp", count: 8192 })
I feel safe in saying that this must be the issue, since
count
is really the only knob to turn in this API usage. It seems we're not correctly checking a platform limit of some sort. Perhaps the relevant one to apply isGPUSupportedLimits.maxBufferSize
? @teoxoy and @jimblandy, do you have any ideas?WGPU enforces a limit of 8192 queries, but it's not exposed in standard WebGPU/Firefox in any way. It's also a compile-time constant, which seems incorrect in the face of dynamic buffer size limitations.
Description
WGPU panics on this line when some large number of query sets are requested with
Device::create_query_set
(exact threshold unknown still):https://github.com/gfx-rs/wgpu/blob/6a75a73300053f6b6b786f3f650c135120139471/wgpu-core/src/device/resource.rs#L3608
Repro steps
MVRE `main.rs` based on `wgpu` 23.0.0:
```rust use pollster::FutureExt as _; fn main() { let instance = wgpu::Instance::default(); let adapter = instance .request_adapter(&Default::default()) .block_on() .unwrap(); let (device, _queue) = adapter .request_device( &wgpu::DeviceDescriptor { required_features: wgpu::Features::all_webgpu_mask() | wgpu::Features::TIMESTAMP_QUERY, ..Default::default() }, None, ) .block_on() .unwrap(); // Kaboom! let _ = device.create_query_set(&wgpu::QuerySetDescriptor { ty: wgpu::QueryType::Timestamp, count: 8192, label: None, }); } ```Expected vs observed behavior
We should not panic here, nor is even an internal error acceptable. We should be able to respect platform limits and enforce them via validation.
Extra materials
-
Platform
Originally reported as a Firefox crash in bug 1930015.
I was able to reproduce this on my M1 MacBook Pro. Current reports from also only originate from macOS devices. It is unclear whether this is reproducible in other environments.