{"record":{"id":"cf3b960636dec145","repo":"zed-industries/zed","slug":"failed-to-create-surface-e","errorCode":null,"errorMessage":"Failed to create surface: {e}","messagePattern":"Failed to create surface: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui_wgpu/src/wgpu_renderer.rs","lineNumber":293,"sourceCode":"            raw_window_handle: window_handle.as_raw(),\n        };\n\n        // Use the existing context's instance if available, otherwise create a new one.\n        // The surface must be created with the same instance that will be used for\n        // adapter selection, otherwise wgpu will panic.\n        let instance = gpu_context\n            .borrow()\n            .as_ref()\n            .map(|ctx| ctx.instance.clone())\n            .unwrap_or_else(|| WgpuContext::instance(Box::new(window.clone())));\n\n        // Safety: The caller guarantees that the window handle is valid for the\n        // lifetime of this renderer. In practice, the RawWindow struct is created\n        // from the native window handles and the surface is dropped before the window.\n        let surface = unsafe {\n            instance\n                .create_surface_unsafe(target)\n                .map_err(|e| anyhow::anyhow!(\"Failed to create surface: {e}\"))?\n        };\n\n        let mut ctx_ref = gpu_context.borrow_mut();\n        let context = match ctx_ref.as_mut() {\n            Some(context) => {\n                context.check_compatible_with_surface(&surface)?;\n                context\n            }\n            None => ctx_ref.insert(WgpuContext::new(instance, &surface, compositor_gpu)?),\n        };\n\n        let atlas = Arc::new(WgpuAtlas::from_context(context));\n\n        Self::new_internal(\n            Some(Rc::clone(&gpu_context)),\n            context,\n            surface,\n            config,","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/gpui_wgpu/src/wgpu_renderer.rs#L275-L311","documentation":"Raised in `WgpuRenderer::new` when `instance.create_surface(window_handle)` fails, meaning wgpu rejected the raw window/display handle combination (unsupported platform, handle belonging to a different display, or already-invalid handle). {e} is the wgpu CreateSurfaceError.","triggerScenarios":"Thrown at crates/gpui_wgpu/src/wgpu_renderer.rs:293 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the raw display/window handle pair is valid and matches the platform backend in the instance.","Ensure the surface is created from the same instance used for adapter selection (as this code does) to avoid wgpu panics.","Recreate the renderer after the window is re-created rather than reusing a stale handle.","Check the CreateSurfaceError variant to distinguish unsupported handle from invalid handle."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}