{"record":{"id":"b3614777e708cdf0","repo":"gfx-rs/wgpu","slug":"timestamp-query-inside-encoders-feature-must-be-en","errorCode":null,"errorMessage":"TIMESTAMP_QUERY_INSIDE_ENCODERS feature must be enabled to call write_timestamp on a command encoder.","messagePattern":"TIMESTAMP_QUERY_INSIDE_ENCODERS feature must be enabled to call write_timestamp on a command encoder\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"wgpu/src/backend/webgpu.rs","lineNumber":3552,"sourceCode":"        }\n    }\n\n    fn insert_debug_marker(&self, label: &str) {\n        self.inner.insert_debug_marker(label)\n    }\n\n    fn push_debug_group(&self, group_label: &str) {\n        self.inner.push_debug_group(group_label)\n    }\n\n    fn pop_debug_group(&self) {\n        self.inner.pop_debug_group()\n    }\n\n    fn write_timestamp(&self, _query_set: &dispatch::DispatchQuerySet, _query_index: u32) {\n        // Not available on WebGPU.\n        // This was part of the spec originally but got removed, see https://github.com/gpuweb/gpuweb/pull/4370\n        panic!(\"TIMESTAMP_QUERY_INSIDE_ENCODERS feature must be enabled to call write_timestamp on a command encoder.\")\n    }\n\n    fn resolve_query_set(\n        &self,\n        query_set: &dispatch::DispatchQuerySet,\n        first_query: u32,\n        query_count: u32,\n        destination: &dispatch::DispatchBuffer,\n        destination_offset: crate::BufferAddress,\n    ) {\n        let query_set = &query_set.as_webgpu().inner;\n        let destination = &destination.as_webgpu().inner;\n\n        self.inner.resolve_query_set_with_u32(\n            query_set,\n            first_query,\n            query_count,\n            destination,","sourceCodeStart":3534,"sourceCodeEnd":3570,"githubUrl":"https://github.com/gfx-rs/wgpu/blob/3e11ff59bf3f9795d285ecc045014089640d7248/wgpu/src/backend/webgpu.rs#L3534-L3570","documentation":"On the WebGPU backend, CommandEncoder::write_timestamp is unconditionally unsupported: the write-timestamp-on-encoder capability was removed from the WebGPU spec (gpuweb PR #4370). wgpu panics to signal that this backend can never service the call.","triggerScenarios":"Calling command_encoder.write_timestamp(query_set, query_index) when running on the WebGPU (browser/wasm) backend, regardless of feature flags.","commonSituations":"wasm builds of an app using GPU timestamp profiling on native; shared profiling code paths that call write_timestamp on encoders without checking the backend; assuming TIMESTAMP_QUERY_INSIDE_ENCODERS makes the call valid on web.","solutions":["Guard encoder-level write_timestamp calls behind a runtime backend check and skip them on WebGPU.","Move timestamp writes into render/compute passes via pass-level write_timestamp where TIMESTAMP_QUERY_INSIDE_PASSES is supported.","Fall back to CPU-side timing on web.","Gate the profiling feature on adapter.features() at startup."],"exampleFix":"// before\nencoder.write_timestamp(&query_set, 0);\n// after\nif features.contains(Features::TIMESTAMP_QUERY_INSIDE_ENCODERS) && !is_webgpu {\n    encoder.write_timestamp(&query_set, 0);\n}","handlingStrategy":"validation","validationCode":"let ok = device.features().contains(Features::TIMESTAMP_QUERY_INSIDE_ENCODERS)\n    && adapter.get_info().backend != wgpu::Backend::Browser;\nif ok { encoder.write_timestamp(&qs, 0); }","typeGuard":"fn supports_encoder_timestamps(f: Features, b: Backend) -> bool {\n    f.contains(Features::TIMESTAMP_QUERY_INSIDE_ENCODERS) && b != Backend::Browser\n}","tryCatchPattern":null,"preventionTips":["Check adapter.features() and backend before any timestamp API.","Use pass-level timestamps only where the spec supports them.","Centralize capability queries in one helper used by profiling code.","Provide CPU timing fallbacks for web builds."],"tags":["panic","webgpu","timestamps","unsupported-feature"],"backgroundTag":"unsupported-feature-panic","analyzedSha":"3e11ff59bf3f9795d285ecc045014089640d7248","analyzedAt":"2026-09-03T01:43:21.459Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}