{"record":{"id":"9f52bd6cf7ac369f","repo":"iced-rs/iced","slug":"create-softbuffer-context","errorCode":null,"errorMessage":"Create softbuffer context","messagePattern":"Create softbuffer context","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"tiny_skia/src/window/compositor.rs","lineNumber":128,"sourceCode":"            background_color,\n            on_pre_present,\n        )\n    }\n\n    fn screenshot(\n        &mut self,\n        renderer: &mut Self::Renderer,\n        viewport: &Viewport,\n        background_color: Color,\n    ) -> Vec<u8> {\n        screenshot(renderer, viewport, background_color)\n    }\n}\n\npub fn new(display: impl compositor::Display) -> Compositor {\n    #[allow(unsafe_code)]\n    let context =\n        softbuffer::Context::new(Box::new(display) as _).expect(\"Create softbuffer context\");\n\n    Compositor { context }\n}\n\npub fn present(\n    renderer: &mut Renderer,\n    surface: &mut Surface,\n    viewport: &Viewport,\n    background: Color,\n    on_pre_present: impl FnOnce(),\n) -> Result<(), compositor::SurfaceError> {\n    let physical_size = viewport.physical_size();\n\n    let mut buffer = surface\n        .window\n        .buffer_mut()\n        .map_err(|_| compositor::SurfaceError::Lost)?;\n","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/iced-rs/iced/blob/d146509d893945de5c304cfaf4301335eee278bd/tiny_skia/src/window/compositor.rs#L110-L146","documentation":"`tiny_skia::window::compositor::new` creates a `softbuffer::Context` for the given display and panics via `expect(\"Create softbuffer context\")` if context creation fails. Softbuffer cannot initialize its drawing context on the provided raw display/window handle, so the library treats it as fatal.","triggerScenarios":"`Compositor::new(display)` (used when building the tiny_skia shell) with a display handle the platform backend cannot use — invalid raw window/display handle, unsupported platform, or failed graphics initialization (e.g. no usable X11/Wayland connection).","commonSituations":"Headless environments without a display server; missing X11/Wayland libraries on Linux (missing libxkbcommon, XCB); running on an unsupported/odd platform (e.g. unusual wasm targets); incompatible raw-handle types from custom display integration.","solutions":["Ensure a valid display environment: set `DISPLAY`/`WAYLAND_DISPLAY` or run under Xvfb in CI/headless setups.","Install required system libraries (libxcb, libxkbcommon, Mesa/llvmpipe) for your platform.","Verify the raw display/window handle passed to iced is correct and matches the windowing backend in use.","Try a different renderer backend (wgpu) if softbuffer is unavailable on the target platform."],"exampleFix":"// CI/headless Linux\n// before\ncargo run\n// after\nXvfb :99 &\nexport DISPLAY=:99\ncargo run","handlingStrategy":"fallback","validationCode":"// Check for a usable display before launching\nif std::env::var(\"DISPLAY\").is_err()\n    && std::env::var(\"WAYLAND_DISPLAY\").is_err()\n{\n    eprintln!(\"no display server available\");\n    std::process::exit(1);\n}","typeGuard":"fn display_available() -> bool {\n    std::env::var_os(\"WAYLAND_DISPLAY\").is_some()\n        || std::env::var_os(\"DISPLAY\").is_some()\n}","tryCatchPattern":"// Context creation panics; check env and catch at process boundary\nlet ok = std::panic::catch_unwind(|| iced::application(...).run());\nif ok.is_err() { eprintln!(\"softbuffer context init failed\"); }","preventionTips":["Verify DISPLAY/WAYLAND_DISPLAY are set in the target environment.","Install required Linux system libraries (libxcb, libxkbcommon) in deployment images.","Use Xvfb in CI/headless test pipelines.","Confirm platform support (softbuffer targets) before choosing the tiny_skia backend."],"tags":["rust","tiny-skia","softbuffer","graphics","initialization","panic"],"backgroundTag":"module-init-failed","analyzedSha":"d146509d893945de5c304cfaf4301335eee278bd","analyzedAt":"2026-09-11T16:54:14.229Z","contentChangedAt":"2026-09-11T16:54:14.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}