{"record":{"id":"456cc18ffb8584cf","repo":"emilk/egui","slug":"failed-to-get-window-handle","errorCode":null,"errorMessage":"Failed to get window handle","messagePattern":"Failed to get window handle","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/eframe/src/native/glow_integration.rs","lineNumber":1140,"sourceCode":"                        );\n                        config\n                    },\n                )\n                .map_err(|e| crate::Error::NoGlutinConfigs(config_template_builder.build(), e))?\n        };\n        if let Some(window) = &window {\n            egui_winit::apply_viewport_builder_to_window(egui_ctx, window, &viewport_builder);\n        }\n\n        let gl_display = gl_config.display();\n        log::debug!(\n            \"successfully created GL Display with version: {} and supported features: {:?}\",\n            gl_display.version_string(),\n            gl_display.supported_features()\n        );\n        let glutin_raw_window_handle = window.as_ref().map(|w| {\n            w.window_handle()\n                .expect(\"Failed to get window handle\")\n                .as_raw()\n        });\n        log::debug!(\"creating gl context using raw window handle: {glutin_raw_window_handle:?}\");\n\n        // create gl context. if core context cannot be created, try gl es context as fallback.\n        let context_attributes =\n            glutin::context::ContextAttributesBuilder::new().build(glutin_raw_window_handle);\n        let fallback_context_attributes = glutin::context::ContextAttributesBuilder::new()\n            .with_context_api(glutin::context::ContextApi::Gles(None))\n            .build(glutin_raw_window_handle);\n\n        let gl_context_result = unsafe {\n            profiling::scope!(\"create_context\");\n            gl_config\n                .display()\n                .create_context(&gl_config, &context_attributes)\n        };\n","sourceCodeStart":1122,"sourceCodeEnd":1158,"githubUrl":"https://github.com/emilk/egui/blob/441971a776322a482e371775219380eca812cfa9/crates/eframe/src/native/glow_integration.rs#L1122-L1158","documentation":"After creating the glutin window, eframe calls `w.window_handle()` on it via the `HasWindowHandle` trait (raw-window-handle). The returned `Result` is unwrapped with `.expect`, so if the windowing backend cannot produce a raw window handle, the process panics with 'Failed to get window handle'. This happens inside `map` over the optional window, when a raw window handle is needed to build the GL context.","triggerScenarios":"Creating a glutin window whose platform backend fails `window_handle()` — e.g. headless environments, window destroyed before this point, or a platform/backend whose handle conversion is unsupported.","commonSituations":"Running on X11/Wayland in minimal containers without a real compositor; exotic windowing backends; calling into eframe from a non-main thread where window creation half-failed; broken graphics drivers.","solutions":["Run on a machine with a functioning windowing system (DISPLAY/WAYLAND_DISPLAY set, or Wayland/X11 running); use Xvfb for CI.","Verify the window was actually created before context creation — check earlier logs for window-creation errors.","Update eframe/winit/glutin/raw-window-handle versions in lockstep; version mismatch of the raw-window-handle traits can break handle retrieval.","Ensure window creation happens on the main thread as required by most platform window systems."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// preflight: ensure a display server is reachable before starting eframe\nfn has_display() -> bool {\n    std::env::var_os(\"WAYLAND_DISPLAY\").is_some()\n        || std::env::var_os(\"DISPLAY\").is_some()\n        || cfg!(target_os = \"windows\")\n        || cfg!(target_os = \"macos\")\n}","typeGuard":null,"tryCatchPattern":"// Rust panics cannot be caught normally; instead preflight-check the environment\nif !has_display() {\n    eprintln!(\"No windowing system available (set DISPLAY or WAYLAND_DISPLAY)\");\n    std::process::exit(1);\n}\nlet result = eframe::run_native(...);","preventionTips":["Run on a machine with a real display server; use Xvfb/xvfb-run in CI.","Set DISPLAY/WAYLAND_DISPLAY correctly before launching.","Keep eframe, winit, glutin and raw-window-handle on compatible versions.","Create windows only on the main thread as platform APIs require."],"tags":["eframe","glutin","winit","raw-window-handle","panic"],"backgroundTag":"missing-dependency","analyzedSha":"441971a776322a482e371775219380eca812cfa9","analyzedAt":"2026-09-12T04:29:21.500Z","contentChangedAt":"2026-09-12T04:29:21.500Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}