gfx-rs/wgpu · error

Display pointer is not set.

Error message

Display pointer is not set.

What it means

Panic in the Vulkan instance's create_surface: the raw display handle variant (e.g. Display) carried a null display pointer, so a Vulkan display surface cannot be created from it. The faulty input is the empty/null raw display handle from the windowing layer.

Source

Thrown at wgpu-hal/src/vulkan/instance.rs:1077

    unsafe fn init(desc: &crate::InstanceDescriptor<'_>) -> Result<Self, crate::InstanceError> {
        unsafe { Self::init_with_callback(desc, None) }
    }

    unsafe fn create_surface(
        &self,
        display_handle: raw_window_handle::RawDisplayHandle,
        window_handle: raw_window_handle::RawWindowHandle,
    ) -> Result<super::Surface, crate::InstanceError> {
        use raw_window_handle::{RawDisplayHandle as Rdh, RawWindowHandle as Rwh};

        // TODO: Replace with ash-window, which also lazy-loads the extension based on handle type

        match (window_handle, display_handle) {
            (Rwh::Wayland(handle), Rdh::Wayland(display)) => {
                self.create_surface_from_wayland(display.display.as_ptr(), handle.surface.as_ptr())
            }
            (Rwh::Xlib(handle), Rdh::Xlib(display)) => {
                let display = display.display.expect("Display pointer is not set.");
                self.create_surface_from_xlib(display.as_ptr(), handle.window)
            }
            (Rwh::Xcb(handle), Rdh::Xcb(display)) => {
                let connection = display.connection.expect("Pointer to X-Server is not set.");
                self.create_surface_from_xcb(connection.as_ptr(), handle.window.get())
            }
            #[cfg(drm)]
            (Rwh::Drm(handle), Rdh::Drm(display)) => {
                self.create_surface_from_drm_plane(display.fd, handle.plane)
            }
            (Rwh::AndroidNdk(handle), _) => {
                self.create_surface_android(handle.a_native_window.as_ptr())
            }
            #[cfg(target_env = "ohos")]
            (Rwh::OhosNdk(handle), _) => self.create_surface_ohos(handle.native_window.as_ptr()),
            (Rwh::Win32(handle), _) => {
                let hinstance = handle.hinstance.ok_or_else(|| {
                    crate::InstanceError::new(String::from(

View on GitHub (pinned to 3e11ff59bf)

Solutions

  1. Supply a non-null raw display pointer via the windowing integration
  2. Use the appropriate handle type (X11/Wayland) for the platform
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at wgpu-hal/src/vulkan/instance.rs:1077 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of gfx-rs/wgpu@3e11ff59bf (2026-09-03). Data as JSON: /api/errors/67b7bf99c8834839. Report an issue: GitHub.