{"record":{"id":"322e7be7079f8e0f","repo":"gfx-rs/wgpu","slug":"device-lost","errorCode":null,"errorMessage":"Device lost","messagePattern":"Device lost","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"wgpu-hal/src/vulkan/mod.rs","lineNumber":1854,"sourceCode":"/// feature flag is enabled.\nfn get_unexpected_err(_err: vk::Result) -> crate::DeviceError {\n    #[cfg(feature = \"internal_error_panic\")]\n    panic!(\"Unexpected Vulkan error: {_err:?}\");\n\n    #[allow(unreachable_code)]\n    crate::DeviceError::Unexpected\n}\n\n/// Returns [`crate::DeviceError::OutOfMemory`].\nfn get_oom_err(_err: vk::Result) -> crate::DeviceError {\n    crate::DeviceError::OutOfMemory\n}\n\n/// Returns [`crate::DeviceError::Lost`] or panics if the `device_lost_panic`\n/// feature flag is enabled.\nfn get_lost_err() -> crate::DeviceError {\n    #[cfg(feature = \"device_lost_panic\")]\n    panic!(\"Device lost\");\n\n    #[allow(unreachable_code)]\n    crate::DeviceError::Lost\n}\n\n#[derive(Clone, Copy, Pod, Zeroable)]\n#[repr(C)]\nstruct RawTlasInstance {\n    transform: [f32; 12],\n    custom_data_and_mask: u32,\n    shader_binding_table_record_offset_and_flags: u32,\n    acceleration_structure_reference: u64,\n}\n\n/// Arguments to the [`CreateDeviceCallback`].\n#[derive(Debug)]\npub struct CreateDeviceCallbackArgs<'arg, 'pnext, 'this>\nwhere","sourceCodeStart":1836,"sourceCodeEnd":1872,"githubUrl":"https://github.com/gfx-rs/wgpu/blob/3e11ff59bf3f9795d285ecc045014089640d7248/wgpu-hal/src/vulkan/mod.rs#L1836-L1872","documentation":"When the Vulkan logical device is lost (e.g. the GPU reset, driver crash, or device was destroyed), wgpu-hal returns `DeviceError::Lost`. With the `device_lost_panic` feature flag enabled, this helper panics with \"Device lost\" instead, so that lost devices fail loudly in testing. Normally callers get a recoverable `DeviceError::Lost` that they must handle by recreating the device.","triggerScenarios":"Any Vulkan call returning VK_ERROR_DEVICE_LOST and routed through `get_lost_err` at wgpu-hal/src/vulkan/mod.rs:1854, e.g. during queue submit, present, or map operations.","commonSituations":"GPU timeouts (TDR) on Windows from long shaders; driver crashes; overheating/overclocked hardware; virtualized or remote GPU environments; tests built with device_lost_panic.","solutions":["Handle `DeviceError::Lost` in the application: drop the device and recreate device + all dependent resources.","Investigate root cause: shorten long-running shaders/launches to avoid TDR, update drivers, check thermals.","Rebuild without the `device_lost_panic` feature to get the recoverable error instead of a panic.","Check that a previous submit didn't trigger a validation/robustness violation leading to device removal."],"exampleFix":"// before\nqueue.submit(Some(encoder.finish()));\n// after\nif let Err(wgpu::DeviceError::Lost) = queue.submit(Some(encoder.finish())).map_err(|e| *e) {\n    // drop and recreate the device and all resources\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":"fn is_device_lost(res: &Result<(), wgpu::Error>) -> bool {\n    matches!(res.as_ref().err().map(|e| e.inner()), Some(wgpu::DeviceError::Lost))\n}","tryCatchPattern":"// Do not retry on DeviceError::Lost with the same device; rebuild first.\nmatch queue.submit(Some(encoder.finish())) {\n    Ok(()) => {}\n    Err(e) if matches!(*e, wgpu::DeviceError::Lost) => {\n        drop(device); // release all resources\n        let (device, queue) = adapter.request_device(&desc, None)?;\n        rebuild_all_resources(&device);\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Bound shader execution time to avoid OS GPU resets (TDR).","Keep drivers updated; check thermals/overclocking on affected machines.","Avoid enabling device_lost_panic in production builds.","Structure the app so device + resources can be recreated from a single recovery path."],"tags":["vulkan","device-lost","gpu-reset","panic"],"backgroundTag":"device-lost","analyzedSha":"3e11ff59bf3f9795d285ecc045014089640d7248","analyzedAt":"2026-09-03T01:43:21.459Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}