Skip to content

Linux/GNOME + NVIDIA with an AMD iGPU: window and HUD crash (wgpu 'Invalid surface', then 'non-existent resource BufferId') #982

Closed as duplicate

Description

@ship-it-mind

What happens

On Ubuntu 26.04 (GNOME, Wayland) with an NVIDIA RTX 5090 driving the displays and an AMD Radeon iGPU (Ryzen 9 9950X) also present, Hex 3.2.0 (.deb) starts, but its Rune app panics as soon as the HUD overlay is created (at launch, or at the first dictation):

ERROR hex::app_paths: panic: panicked at wgpu-30.0.1/src/backend/wgpu_core.rs:3981:18:
wgpu error: Validation Error
  In Surface::configure
    Invalid surface
ERROR hex::linux::app: the Hex window failed; Hex keeps running without it
WARN  hex::linux::rune_hud: HUD unavailable: Rune could not open the overlay (no reason given); dictation still works

Dictation keeps working, but the Settings window dies (or never opens) and there is no HUD. hex status shows Recording HUD unavailable: the overlay could not open (no reason given).

Cause

  1. GNOME has no layer-shell, so the HUD is an override-redirect ARGB X11 window on XWayland (platform/x11/xwayland.rs).
  2. gpu::pick correctly picks the compositor's GPU (NVIDIA, 0000:01:00.0).
  3. NVIDIA's Vulkan driver reports only OPAQUE composite alpha for that X11 surface, so render::translucency::prefer looks for another adapter that claims a translucent mode. RADV (the AMD iGPU) reports PRE_MULTIPLIED | INHERIT and is_surface_supported = true, so the overlay moves to the iGPU, even though the sort prefers the compositor's device.
  4. RADV can't create a swapchain on an XWayland that NVIDIA drives: vkCreateSwapchainKHR returns VK_ERROR_INITIALIZATION_FAILED. wgpu-hal maps that to SurfaceError::Lost, and wgpu-core to ConfigureSurfaceError::InvalidSurface. wgpu's default uncaptured-error handler panics, and the panic takes the whole Rune app down with it.

I reproduced step 4 outside Hex with a small C program. It creates the same depth-32 override-redirect window on XWayland and calls vkCreateSwapchainKHR:

  • NVIDIA: caps alpha=0x1 (opaque only), swapchain VK_SUCCESS
  • RADV: caps alpha=0xa (premultiplied | inherit), swapchain -3 (VK_ERROR_INITIALIZATION_FAILED)

Confirmation in the running app:

  • VK_LOADER_DRIVERS_DISABLE=*radeon* → no panic
  • WGPU_ADAPTER_NAME=nvidia (pins the pick, so prefer is skipped) → no panic at launch; the first HUD show works (but see the second crash below)
  • DISPLAY= (no XWayland) → no panic, no HUD

Second crash once the first is avoided: Cannot get non-existent resource BufferId(3,1)

With the overlay pinned to NVIDIA (WGPU_ADAPTER_NAME=nvidia), the HUD shows once. The next time it shows, the app panics in wgpu-core-30.0.1/src/storage.rs:143 with Cannot get non-existent resource BufferId(3,1).

  • NVIDIA's surface never serves a translucent overlay, so Overlay::attach makes a new Gpu (instance + device) on every show (the None branch).
  • It keeps self.renderer from the previous show and only calls rebuild_renderer (set_format / set_srgb_blend), so the renderer's buffers belong to the old device's hub.
  • Hex's HudCompositor (src/rune_hud.rs) caches its Painter (uniform buffers, bind group, pipeline) keyed only on the target format, so it has the same problem.

So the workaround stops the window from dying at launch, but the HUD still can't be shown twice.

Workaround

# ~/.config/systemd/user/hex.service.d/workaround-hybrid-gpu.conf
[Service]
Environment=WGPU_ADAPTER_NAME=nvidia

then systemctl --user daemon-reload && systemctl --user restart hex.

Proposed fix (Rune)

  • translucency::prefer: when the compositor named its GPU, don't consider adapters on other GPUs (the rule gpu/pick.rs already states: only the compositor's GPU's buffers can be shown). The overlay draws opaque on the compositor's GPU instead of failing.
  • Overlay::attach: configure the surface inside a validation error scope, and fail() the overlay on error instead of letting wgpu's default handler panic the app.
  • Overlay::attach: when it makes a new Gpu, drop the old renderer so it is rebuilt (with the atlases) on the new device. Document on Compositor::render that f.device can change between frames.

Proposed fix (Hex)

  • HudCompositor: rebuild the Painter when f.device changes, not only when the format does.

Environment

  • Hex 3.2.0 (hex_3.2.0-1_amd64.deb), Rune pin f5def6d, wgpu 30.0.1
  • Ubuntu 26.04.1, kernel 7.0.0-42, GNOME (Mutter, experimental scale-monitor-framebuffer, xwayland-native-scaling), Wayland + XWayland
  • NVIDIA GeForce RTX 5090, driver 595.58.03 (displays on this card); AMD Radeon iGPU (RADV, Mesa 26.0.8)

Activity

  1. ship-it-mind commented on Nov 2, 2026

    @ship-it-mind
    Author

    Rune fix: anomalyco/rune#73 (issue anomalyco/rune#72).

    Hex also needs this: the HUD's Painter is cached by format only, so after Rune gives the overlay a new device it draws with the old device's buffers. Proposed change (not compiled here: this machine lacks the native build dependencies):

    diff --git a/src/rune_hud.rs b/src/rune_hud.rs
    index baf3975e..aa877262 100644
    --- a/src/rune_hud.rs
    +++ b/src/rune_hud.rs
    @@ -567,7 +567,10 @@ impl Target {
     }
     
     struct HudCompositor {
    -    gpu: Option<Painter>,
    +    /// The painter and the device it was made on. Rune may give the
    +    /// overlay a new device when it shows again (an opaque-only surface
    +    /// gets a fresh GPU each time), and a painter's buffers live on its own.
    +    gpu: Option<(wgpu::Device, Painter)>,
         animating: Arc<AtomicBool>,
     }
     
    @@ -605,10 +608,14 @@ impl Compositor<Hud> for HudCompositor {
                 drop(clear_pass(f.encoder, f.target));
                 return;
             };
    -        if self.gpu.as_ref().is_none_or(|gpu| gpu.format != f.format) {
    -            self.gpu = Some(Painter::new(f.device, f.format));
    +        if self
    +            .gpu
    +            .as_ref()
    +            .is_none_or(|(device, gpu)| gpu.format != f.format || device != f.device)
    +        {
    +            self.gpu = Some((f.device.clone(), Painter::new(f.device, f.format)));
             }
    -        let gpu = self.gpu.as_ref().expect("created above");
    +        let (_, gpu) = self.gpu.as_ref().expect("created above");
             let uniforms = gpu.write(&drawn, layout, target, |buffer, data| {
                 f.write_buffer(buffer, 0, data)
             });
  2. thdxr commented on Nov 2, 2026

    @thdxr
    Member

    thanks, the swapchain repro on radv vs nvidia was exactly the missing piece. same bug as #979, so closing this as a duplicate.

    fixed in #986 (rune 53c0c9ac), written along the lines you proposed:

    • translucency::prefer only considers adapters on the compositor's gpu once it named one, so the hud stays on nvidia and draws opaque-alpha
    • overlay surface configure runs in an error scope, a refused surface fails that overlay only
    • an overlay keeps its own device across shows instead of making a new one each time, and drops its renderer when it does get a new device, so the BufferId panic on the second show shouldn't happen
    • the hud painter is rebuilt when the device changes

    not tested on a hybrid nvidia machine. once the next dev build is out you should be able to drop the WGPU_ADAPTER_NAME override; if the hud still fails the log will now say why

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

  3. reopened this on Nov 2, 2026
  4. ship-it-mind commented on Nov 2, 2026

    @ship-it-mind
    Author

    Thanks for picking this up so quickly. One correction to the Hex diff I posted above, which #986 adopted: device != f.device in HudCompositor can't detect a device change. wgpu compares Devices by their id alone (impl_eq_ord_hash_proxy!(CoreDevice => .id) in wgpu-30.0.1/src/backend/wgpu_core.rs). Each new Rune Gpu has its own wgpu::Instance, and each instance numbers its devices from the same id, so a new device compares equal to the old one.

    I hit this while testing on the affected machine. With per-show new devices plus that check, the HUD still panicked on its third show with Cannot get non-existent resource RenderPipelineId(1,1). The cached painter was reused because the "different" device compared equal.

    Since 53c0c9ac keeps the overlay's own device across shows, this is dormant now: it only matters if an overlay actually moves to a new device. When that happens, the stale painter comes back. The Compositor doc ("keep resources made on it with the device they belong to") suggests the same comparison, so other compositors would hit it too.

    What worked in my test was an explicit signal instead of a comparison. Rune adds Compositor::new_device(&mut self) {}, which Overlay::attach calls when it makes a new Gpu after an earlier show, and Hex implements it as self.gpu = None. With that change on top of your fix, the HUD showed reliably across repeated dictations on GNOME + RTX 5090 + AMD iGPU, with no panics.

  5. thdxr commented on Nov 2, 2026

    @thdxr
    Member

    you're right, checked it in wgpu 30.0.1: CoreDevice compares by .id only, and every rune gpu has its own instance, so a new gpu's first device equals the old one. the check in #986 could never fire.

    fixed in #993 (rune c8f2888e): rune frames now carry f.device_key(), unique per device for the whole process, and the hud and the sounds preview key their painter on that instead of the device. there's a rune test showing two instances' devices compare equal while their keys differ, and the Compositor docs now say to use the key, not device equality.

    i went with a key over a new_device hook since a compositor can't miss it, it's just part of the frame. not tested on nvidia here. since 53c0c9ac keeps the overlay on one device it should stay dormant, but if you get a chance to run the next dev build without WGPU_ADAPTER_NAME that'd confirm it. leaving this closed as a duplicate of #979, say if it still panics and i'll reopen

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

  6. ship-it-mind commented on Nov 2, 2026

    @ship-it-mind
    Author

    Confirmed on the affected machine (GNOME Wayland, RTX 5090 driving the displays plus an AMD iGPU, NVIDIA 595.58.03): I ran a local release build of dev at 8104af6 (#986 + #993, Rune c8f2888e) as the Hex service, with no WGPU_ADAPTER_NAME override. Rune picks the NVIDIA GPU as the compositor's. With the window open, five dictations through the normal shortcut each showed the HUD, with no panics; the window stayed open and the HUD looks right. Thanks for the quick fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions