{"record":{"id":"ec8a582012ecd405","repo":"zed-industries/zed","slug":"device-lost-err-ec8a58","errorCode":null,"errorMessage":"Device lost: {err}","messagePattern":"Device lost: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/gpui_windows/src/platform.rs","lineNumber":396,"sourceCode":"        let invalidate_devices = self.invalidate_devices.clone();\n\n        std::thread::Builder::new()\n            .name(\"VSyncProvider\".to_owned())\n            .spawn(move || {\n                let vsync_provider = VSyncProvider::new();\n                loop {\n                    vsync_provider.wait_for_vsync();\n                    if check_device_lost(&directx_device.device)\n                        || invalidate_devices.fetch_and(false, Ordering::Acquire)\n                    {\n                        if let Err(err) = handle_gpu_device_lost(\n                            &mut directx_device,\n                            platform_window.as_raw(),\n                            validation_number,\n                            &all_windows,\n                            &text_system,\n                        ) {\n                            panic!(\"Device lost: {err}\");\n                        }\n                    }\n                    let Some(all_windows) = all_windows.upgrade() else {\n                        break;\n                    };\n                    for hwnd in all_windows.read().iter() {\n                        unsafe {\n                            let _ = RedrawWindow(Some(hwnd.as_raw()), None, None, RDW_INVALIDATE);\n                        }\n                    }\n                }\n            })\n            .unwrap();\n    }\n}\n\nfn translate_accelerator(msg: &MSG) -> Option<()> {\n    if msg.message != WM_KEYDOWN && msg.message != WM_SYSKEYDOWN {","sourceCodeStart":378,"sourceCodeEnd":414,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/gpui_windows/src/platform.rs#L378-L414","documentation":"gpui_windows runs a dedicated vsync thread that waits for vertical blank and also watches for DirectX device loss. When loss is detected it calls handle_gpu_device_lost to rebuild device, swapchain, and text-system state; if recovery returns an error the thread panics with 'Device lost'. Because the panic is on a background thread, it tears down the whole process rather than one window.","triggerScenarios":"The vsync thread observes a lost device (check_device_lost or the invalidate-devices flag set by a device-removed notification) and handle_gpu_device_lost fails during re-enumeration, swapchain recreation, or dependent state rebuild on Windows.","commonSituations":"Same family as the message-loop variant: driver reset during heavy rendering, docking/undocking, driver upgrades, failing hardware. Slightly more likely when the loss happens between frames rather than during drawing, since this watcher thread is the one that notices it first.","solutions":["Update GPU drivers; check Event Viewer for the reset that started the recovery attempt","Free VRAM and reduce concurrent GPU work so the recovery has resources to succeed","Reboot to clear wedged driver state if the panic repeats on every launch","Capture the err text from the panic plus surrounding events and report it upstream for the specific GPU/driver pair"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// the panic is on the vsync thread: catch_unwind there is not reachable from main,\n// so record the failure and exit cleanly for an external supervisor to restart\nstd::panic::set_hook(Box::new(|info| {\n    log::error!(\"panic on background thread: {info}\");\n    std::process::exit(101);\n}));","preventionTips":["Treat any 'Device lost' panic as driver-level first: update drivers and check TDR events before changing code","Auto-restart the app under a supervisor in managed deployments while the driver root cause is fixed","Avoid running during driver updates or GPU hot-unplug; schedule restarts after hardware changes"],"tags":["windows","directx","gpu","device-lost","vsync","gpui"],"backgroundTag":"gpu-device-lost","analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}