From fbbf2d1d48e9fb0e24d3e7d5fa6d290aef9f8e9e Mon Sep 17 00:00:00 2001 From: David Woods Date: Thu, 13 Aug 2026 10:53:52 -0400 Subject: [PATCH] Fix blank Flatpak canvas on NVIDIA Wayland On NVIDIA drivers newer than 555 under Wayland, the native NVIDIA GLX path can leave the wxGTK OpenGL canvases in Prepare and Preview blank. The AppImage launcher already avoids this by routing OpenGL through Mesa Zink, but the Flatpak entrypoint only applied the WebKit DMA-BUF workaround. Detect the mounted org.freedesktop.Platform.GL.nvidia-* extension because glxinfo and nvidia-smi are unavailable in the Flatpak runtime. For affected drivers, select Mesa GLX/EGL and Zink so OpenGL is translated to Vulkan and rendered through the NVIDIA Vulkan driver. Keep ZINK_FORCE_OVERRIDE and ZINK_DISABLE_OVERRIDE as explicit controls. Verified on CachyOS KDE Wayland with an NVIDIA RTX 3090 and driver 610.57.04. Prepare and Preview render correctly with the override. --- scripts/flatpak/entrypoint | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/scripts/flatpak/entrypoint b/scripts/flatpak/entrypoint index 96c67c564395..d89410c26890 100644 --- a/scripts/flatpak/entrypoint +++ b/scripts/flatpak/entrypoint @@ -1,7 +1,28 @@ #!/usr/bin/env sh -# Work-around https://gitlab.gnome.org/GNOME/gnome-build-meta/-/issues/754 -grep -q org.freedesktop.Platform.GL.nvidia /.flatpak-info && export WEBKIT_DISABLE_DMABUF_RENDERER=1 +# Work around NVIDIA rendering issues under Wayland. The AppImage launcher uses +# Zink for NVIDIA drivers newer than 555, but glxinfo and nvidia-smi are not +# available in the Flatpak runtime. Derive the driver version from the mounted +# org.freedesktop.Platform.GL.nvidia-* extension instead. +if grep -q 'org.freedesktop.Platform.GL.nvidia-' /.flatpak-info; then + export WEBKIT_DISABLE_DMABUF_RENDERER=1 + + nvidia_driver_major=$(sed -n 's/.*org\.freedesktop\.Platform\.GL\.nvidia-\([0-9][0-9]*\)-.*/\1/p' /.flatpak-info | head -n 1) + if [ "$XDG_SESSION_TYPE" = "wayland" ] && [ "${ZINK_DISABLE_OVERRIDE:-0}" != "1" ] && \ + { [ "${ZINK_FORCE_OVERRIDE:-0}" = "1" ] || { [ -n "$nvidia_driver_major" ] && [ "$nvidia_driver_major" -gt 555 ]; }; }; then + for mesa_egl_vendor in \ + /usr/lib/*-linux-gnu/GL/default/share/glvnd/egl_vendor.d/50_mesa.json \ + /usr/share/glvnd/egl_vendor.d/50_mesa.json; do + if [ -f "$mesa_egl_vendor" ]; then + export __GLX_VENDOR_LIBRARY_NAME=mesa + export __EGL_VENDOR_LIBRARY_FILENAMES="$mesa_egl_vendor" + export MESA_LOADER_DRIVER_OVERRIDE=zink + export GALLIUM_DRIVER=zink + break + fi + done + fi +fi # Work-around https://github.com/bambulab/BambuStudio/issues/3440 export LC_ALL=C.UTF-8