Skip to content

Add opt-in native Wayland support on Linux - #11821

Open
mindrunner wants to merge 5 commits into
bambulab:masterfrom
mindrunner:linux-wayland-support
Open

Add opt-in native Wayland support on Linux#11821
mindrunner wants to merge 5 commits into
bambulab:masterfrom
mindrunner:linux-wayland-support

Conversation

@mindrunner

@mindrunner mindrunner commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Work in progress — not ready to merge. Native Wayland support mostly works now, but the 3D viewport still turns blank after loading a model in some configurations (see the status comment below). Testing on other distros, compositors and GPUs is very welcome.

Fixes #2595

Adds native Wayland support on Linux, opt-in for now. Three commits:

1. Enable opt-in native Wayland support

  • wxWidgets dep is built with wxUSE_GLCANVAS_EGL=ON so wxGLCanvas uses EGL and works on both X11 and native Wayland.
  • GDK_BACKEND is no longer force-overridden (replace changed to false). The default remains x11 (XWayland), so nothing changes for existing users, but launching with GDK_BACKEND=wayland now gives a native Wayland session instead of being silently reverted.
  • glewInit() tolerates GLEW_ERROR_NO_GLX_DISPLAY: GLX-built GLEW returns it when no GLX display exists (native Wayland/EGL, and the CLI's OSMesa offscreen context used for thumbnails). Core GL entry points are already resolved at that point. GLEW intentionally stays a GLX build (GLEW_EGL would break the CLI/OSMesa path).
  • WEBKIT_DISABLE_DMABUF_RENDERER=1 is set (non-overriding) on Wayland sessions to avoid blank/garbled WebKitGTK views on NVIDIA and VMs.
  • linux.d/debian gains libwayland-dev, wayland-protocols, libegl-dev.

2. Port wxWidgets 3.2.11 EGL canvas into the wxWidgets dep
The fork's 3.1-era wxGLCanvasEGL mishandles the Wayland subsurface lifecycle (subsurface created against a not-yet-mapped parent, never repositioned after layout, eglSwapBuffers() can stall on withheld frame callbacks). deps/wxWidgets/0002-fix-wayland-egl-subsurface.patch ports the upstream 3.2.11 implementation, adapted to the fork: subsurface created on map-event and destroyed on unmap, geometry refreshed from the live GtkAllocation/widget-tree coordinates on size-allocate and scale changes, swap interval 0.

3. Do not initialize OpenGL without the canvas context current
GCodeViewer::get_renderer() force-called OpenGLManager::init_gl() during startup before the canvas GL context had ever been made current. On Wayland this compiled every shader program into GTK's internal EGL context, so all later glUseProgram() calls in the render context failed with GL_INVALID_VALUE and the 3D viewport stayed blank. On X11 the app context happened to be current by then, masking the bug. Renderer creation is now deferred until GL has been initialized by the (properly guarded) render path.

Tested on Arch Linux under Hyprland (Wayland session, mixed-DPI monitors, Intel + NVIDIA): with GDK_BACKEND=wayland the AppImage runs as a native Wayland client (compositor reports xwayland: false); the 3D viewport (build plate, models, toolbars, gizmos), WebKit webviews and the rest of the UI render correctly and track window resizes. Default launch (X11/XWayland) is unchanged. Built via DockerBuild.sh (ubu24), clean deps + app build.

Known follow-ups under native Wayland: window move/resize can feel slightly laggy (subsurface repositioning), and gtk_window_resize assertion warnings from the dropdown popup sizing code (src/slic3r/GUI/Widgets/DropDown.cpp).

…d) (bambulab#2595)

- Build wxWidgets dep with wxUSE_GLCANVAS_EGL=ON so wxGLCanvas works on Wayland
- Stop force-overriding GDK_BACKEND; default stays x11, a user-set
  GDK_BACKEND=wayland is now honored
- Set WEBKIT_DISABLE_DMABUF_RENDERER=1 on Wayland sessions (overridable)
  to avoid blank WebKitGTK views on NVIDIA/VMs
- Treat GLEW_ERROR_NO_GLX_DISPLAY from glewInit as non-fatal: GLX-built
  GLEW reports it under native Wayland/EGL and under the CLI's OSMesa
  context; core GL entry points are already resolved at that point
- Add libwayland-dev, wayland-protocols, libegl-dev to debian deps
@mindrunner
mindrunner marked this pull request as draft August 6, 2026 15:42
…subsurfaces

The fork's 3.1-era wxGLCanvasEGL mishandles the Wayland subsurface
lifecycle: the subsurface is created against a not-yet-mapped parent,
never repositioned after layout, and eglSwapBuffers() can stall on frame
callbacks the compositor withholds for occluded surfaces.

Port the wxWidgets 3.2.11 src/unix/glegl.cpp + include/wx/unix/glegl.h
wholesale, adapted to the fork:
- subsurface created on map-event, destroyed on unmap
- geometry refreshed on size-allocate/scale change from the current
  GtkAllocation and widget-tree coordinates (gdk_window_get_origin can
  report stale positions after compositor-driven resizes)
- swap interval 0 so eglSwapBuffers() never blocks the UI thread
- shims for wrapgdk/backend/elfversion headers the fork predates, and
  wxABI version guards removed

Applied via ExternalProject PATCH_COMMAND with an idempotency guard.
GCodeViewer::get_renderer() force-called OpenGLManager::init_gl() during
startup, before the canvas GL context had ever been made current. On
Wayland this compiles every shader program into GTK's internal EGL
context; all later glUseProgram() calls in the app's render context fail
with GL_INVALID_VALUE and the 3D viewport stays blank (white). On X11
the app context happens to be current by then, which masked the bug.

Defer renderer creation until GL has been initialized by the render
path, which is guarded by _set_current(). Adds
OpenGLManager::is_gl_initialized() for that check.
@mindrunner
mindrunner force-pushed the linux-wayland-support branch from 1f0db03 to 74b2593 Compare August 6, 2026 18:58
@mindrunner
mindrunner marked this pull request as ready for review August 6, 2026 19:00
@mindrunner

Copy link
Copy Markdown
Contributor Author

Status: not finished — please treat this as work in progress, and testers are very welcome.

Since opening this PR I found (and partly fixed) two further problems, and one known problem remains open. Summary of where things actually stand:

Fixed since the initial push

  • Blank 3D viewport on native Wayland. GCodeViewer::get_renderer() force-called OpenGLManager::init_gl() before the canvas GL context had ever been made current, so shaders were compiled into GTK's internal EGL context and every later glUseProgram() failed with GL_INVALID_VALUE. On X11 the app context happened to be current by then, which masked it.
  • Wayland subsurface handling. The fork's 3.1-era wxGLCanvasEGL is ported to the wxWidgets 3.2.11 implementation (subsurface created on map-event / destroyed on unmap, geometry refreshed from the live GtkAllocation, swap interval 0).
  • Blank 3D viewport on X11 with the NVIDIA driver (a regression introduced by turning on wxUSE_GLCANVAS_EGL). On X11, NVIDIA only creates an EGL window surface when the EGLConfig's EGL_NATIVE_VISUAL_ID matches the X window's visual; Mesa does not enforce this. wxWidgets aligns the widget visual for the GLX path but never for the EGL path, so eglCreatePlatformWindowSurface() failed with EGL_BAD_ALLOC — silently, because wx is built with asserts off. Measured on an RTX 4090 (driver 610.43.03): window visual 0x2ec, all offered configs wanted 0x71, surface creation failed; after aligning the widget's visual with the config, surface creation succeeds and rendering works. The dep patch now installs a visual-matching hook for the EGL X11 path.

Still broken / needs work

  • The 3D view renders correctly at startup but turns blank again after loading a model (reproduced on NVIDIA + X11). Not yet diagnosed; it looks like the model-load path leaves a different GL context/surface current, but that is not confirmed.
  • Window move/resize feels laggy under native Wayland (subsurface repositioning on every frame of the drag).
  • gtk_window_resize assertion warnings from the dropdown popup sizing code (src/slic3r/GUI/Widgets/DropDown.cpp) under native Wayland.
  • Only tested on Arch Linux + Hyprland so far, with Intel/Mesa and NVIDIA (RTX 4090, proprietary driver). GNOME, KDE, AMD and pure-X11 sessions are completely untested, as is the CLI thumbnail path on real hardware.

Testers wanted. The default backend is unchanged (X11/XWayland), so a normal launch should behave exactly as before — that part needs regression testing as much as the new path does. To try native Wayland:

GDK_BACKEND=wayland ./BambuStudio.AppImage

Useful reports: your distro, compositor, GPU and driver, whether you launched with or without GDK_BACKEND=wayland, and whether the 3D view renders (a) at startup, (b) after importing a model, (c) after switching to Preview and slicing. Screenshots of a blank viewport plus the output of GDK_BACKEND=wayland ./BambuStudio.AppImage 2>&1 | tail -40 are the most useful thing you can attach.

@mindrunner mindrunner changed the title Add opt-in native Wayland support on Linux WIP: Add opt-in native Wayland support on Linux Aug 6, 2026
@mindrunner
mindrunner marked this pull request as draft August 6, 2026 20:28
@SR-G

SR-G commented Aug 6, 2026

Copy link
Copy Markdown

Sorry for this dumb question, but is there a precompiled AppImage somewhere and corresponding to this PR, or is it expected for testers to build it from source ?

On X11 the EGL window surface can only be created when the EGLConfig's
EGL_NATIVE_VISUAL_ID matches the visual of the X window. Mesa tolerates
a mismatch; the NVIDIA driver rejects it with EGL_BAD_ALLOC, and because
wx is built with asserts disabled the failure is silent: the GL context
reports 4.6 and shaders compile, but there is no surface to draw into,
so the 3D viewport stays blank.

wxWidgets aligns the widget's visual with the chosen visual for the GLX
path (parent_set_hook) but never does so for the EGL path. Install the
equivalent hook for EGL on X11.

Measured on an RTX 4090 (driver 610.43.03): window visual 0x2ec, all
five offered configs report native visual 0x71, eglCreatePlatformWindow-
Surface fails; after aligning the widget visual with the config the
surface is created and glReadPixels returns the cleared color.
@mindrunner

Copy link
Copy Markdown
Contributor Author

I can provide an appimage from the latest sources if there is interest.

@SR-G

SR-G commented Aug 6, 2026

Copy link
Copy Markdown

I can provide an appimage from the latest sources if there is interest.

If easy enough for you to upload it somewhere, would be easier to test, indeed.

@mindrunner

Copy link
Copy Markdown
Contributor Author

@SR-G

SR-G commented Aug 6, 2026

Copy link
Copy Markdown

Will have to test again tomorrow (have a awaiting reboot with new kernel and DKMS NVIDIA driver), but for now, i have the blank viewport right after opening a model.

image

Stack : ArchLinux + COSMIC (wayland) + 3 identical HDMI monitors (same resolution on each of them)

                 .o+`                   ----------- 
                 `ooo/                   OS: Arch Linux x86_64 
                `+oooo:                  Kernel: 7.1.5-arch1-2 
               `+oooooo:                 Uptime: 2 days, 8 hours, 33 mins 
               -+oooooo+:                Packages: 2025 (pacman), 14 (flatpak) 
             `/:-:++oooo+:               Shell: zsh 5.9.2 
            `/++++/+++++++:              Resolution: 1920x1080 
           `/++++++++++++++:             DE: COSMIC 
          `/+++ooooooooooooo/`           Theme: Adwaita [GTK2] 
         ./ooosssso++osssssso+`          Icons: Adwaita [GTK2] 
        .oossssso-````/ossssss+`         Terminal: terminator 
       -osssssso.      :ssssssso.        CPU: 11th Gen Intel i7-11700K (16) @ 2.500GHz 
      :osssssss/        osssso+++.       GPU: NVIDIA T600 
     /ossssssss/        +ssssooo/-       GPU: Intel RocketLake-S GT1 [UHD Graphics 750] 
   `/ossssso+/:-        -:/+osssso+-     Memory: 21761MiB / 31819MiB 
  `+sso+:-`                 `.-/+oso:
 `++:.                           `-/+/                           
 .`                                 `/                           

Logs :

GDK_BACKEND=wayland ./BambuStudio_wayland-test_ubu24_a96dc5ad7.AppImage
[2026-08-07 00:31:26.017504] [0x00007f13562fef80] [trace]   Initializing StaticPrintConfigs
libEGL warning: pci id for fd 35: 10de:1fb1, driver (null)

pci id for fd 34: 10de:1fb1, driver (null)
pci id for fd 36: 10de:1fb1, driver (null)
libEGL warning: egl: failed to create dri2 screen
pci id for fd 34: 10de:1fb1, driver (null)
pci id for fd 36: 10de:1fb1, driver (null)
libEGL warning: egl: failed to create dri2 screen

(bambu-studio:1750224): Gtk-CRITICAL **: 00:31:34.214: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:1750224): Gtk-CRITICAL **: 00:31:34.215: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:1750224): Gtk-CRITICAL **: 00:31:34.216: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:1750224): Gtk-CRITICAL **: 00:31:34.218: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:1750224): Gtk-CRITICAL **: 00:31:34.219: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:1750224): Gtk-CRITICAL **: 00:31:34.221: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:1750224): Gtk-CRITICAL **: 00:31:34.234: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:1750224): Gtk-CRITICAL **: 00:31:34.236: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:1750224): Gtk-CRITICAL **: 00:31:34.238: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:1750224): Gtk-CRITICAL **: 00:31:34.240: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:1750224): Gtk-CRITICAL **: 00:31:34.242: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:1750224): Gtk-CRITICAL **: 00:31:34.245: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:1750224): Gtk-CRITICAL **: 00:31:34.246: gtk_window_resize: assertion 'width > 0' failed
libEGL warning: pci id for fd 23: 10de:1fb1, driver (null)

libEGL warning: pci id for fd 23: 10de:1fb1, driver (null)

libEGL warning: pci id for fd 23: 10de:1fb1, driver (null)

pci id for fd 24: 10de:1fb1, driver (null)
pci id for fd 24: 10de:1fb1, driver (null)
pci id for fd 24: 10de:1fb1, driver (null)
pci id for fd 25: 10de:1fb1, driver (null)
libEGL warning: egl: failed to create dri2 screen
libEGL warning: DRI2: failed to create screen
libEGL warning: pci id for fd 23: 10de:1fb1, driver (null)

pci id for fd 25: 10de:1fb1, driver (null)
libEGL warning: egl: failed to create dri2 screen
libEGL warning: DRI2: failed to create screen
pci id for fd 25: 10de:1fb1, driver (null)
libEGL warning: egl: failed to create dri2 screen
libEGL warning: DRI2: failed to create screen
libEGL warning: pci id for fd 23: 10de:1fb1, driver (null)

libEGL warning: pci id for fd 23: 10de:1fb1, driver (null)

libEGL warning: pci id for fd 23: 10de:1fb1, driver (null)

pci id for fd 24: 10de:1fb1, driver (null)
pci id for fd 25: 10de:1fb1, driver (null)
libEGL warning: egl: failed to create dri2 screen
libEGL warning: DRI2: failed to create screen
pci id for fd 24: 10de:1fb1, driver (null)
libEGL warning: pci id for fd 23: 10de:1fb1, driver (null)

pci id for fd 24: 10de:1fb1, driver (null)
pci id for fd 24: 10de:1fb1, driver (null)
libEGL warning: pci id for fd 23: 10de:1fb1, driver (null)

pci id for fd 25: 10de:1fb1, driver (null)
pci id for fd 25: 10de:1fb1, driver (null)
pci id for fd 25: 10de:1fb1, driver (null)
libEGL warning: egl: failed to create dri2 screen
libEGL warning: egl: failed to create dri2 screen
libEGL warning: DRI2: failed to create screen
libEGL warning: DRI2: failed to create screen
libEGL warning: egl: failed to create dri2 screen
libEGL warning: DRI2: failed to create screen
libEGL warning: pci id for fd 23: 10de:1fb1, driver (null)

libEGL warning: pci id for fd 23: 10de:1fb1, driver (null)

libEGL warning: pci id for fd 23: 10de:1fb1, driver (null)

libEGL warning: pci id for fd 23: 10de:1fb1, driver (null)

pci id for fd 24: 10de:1fb1, driver (null)
pci id for fd 24: 10de:1fb1, driver (null)
pci id for fd 25: 10de:1fb1, driver (null)
libEGL warning: egl: failed to create dri2 screen
libEGL warning: DRI2: failed to create screen
pci id for fd 25: 10de:1fb1, driver (null)
libEGL warning: egl: failed to create dri2 screen
libEGL warning: DRI2: failed to create screen
pci id for fd 24: 10de:1fb1, driver (null)
libEGL warning: pci id for fd 23: 10de:1fb1, driver (null)

pci id for fd 25: 10de:1fb1, driver (null)
libEGL warning: egl: failed to create dri2 screen
libEGL warning: DRI2: failed to create screen
libEGL warning: pci id for fd 23: 10de:1fb1, driver (null)

libEGL warning: pci id for fd 23: 10de:1fb1, driver (null)

pci id for fd 24: 10de:1fb1, driver (null)
libEGL warning: pci id for fd 23: 10de:1fb1, driver (null)

pci id for fd 24: 10de:1fb1, driver (null)
pci id for fd 24: 10de:1fb1, driver (null)
pci id for fd 25: 10de:1fb1, driver (null)
libEGL warning: egl: failed to create dri2 screen
libEGL warning: DRI2: failed to create screen
pci id for fd 25: 10de:1fb1, driver (null)
libEGL warning: egl: failed to create dri2 screen
libEGL warning: DRI2: failed to create screen
pci id for fd 25: 10de:1fb1, driver (null)
libEGL warning: egl: failed to create dri2 screen
libEGL warning: DRI2: failed to create screen
libEGL warning: pci id for fd 23: 10de:1fb1, driver (null)

libEGL warning: pci id for fd 23: 10de:1fb1, driver (null)

libEGL warning: pci id for fd 23: 10de:1fb1, driver (null)

pci id for fd 24: 10de:1fb1, driver (null)
pci id for fd 25: 10de:1fb1, driver (null)
libEGL warning: egl: failed to create dri2 screen
libEGL warning: DRI2: failed to create screen
libEGL warning: pci id for fd 23: 10de:1fb1, driver (null)

libEGL warning: pci id for fd 23: 10de:1fb1, driver (null)

pci id for fd 24: 10de:1fb1, driver (null)
pci id for fd 25: 10de:1fb1, driver (null)
libEGL warning: egl: failed to create dri2 screen
libEGL warning: DRI2: failed to create screen
libEGL warning: pci id for fd 23: 10de:1fb1, driver (null)

pci id for fd 24: 10de:1fb1, driver (null)
pci id for fd 25: 10de:1fb1, driver (null)
libEGL warning: egl: failed to create dri2 screen
libEGL warning: DRI2: failed to create screen
libEGL warning: pci id for fd 23: 10de:1fb1, driver (null)

1. lo    : 127.0.0.1
2. enp5s0: 192.168.8.5
3. docker0: 172.17.0.1

use_count = 4

@SR-G

SR-G commented Aug 7, 2026

Copy link
Copy Markdown

After a reboot (now kernel 7.1.6-arch1-1 + NVIDIA 610.57.04), still same behavior, however the log is cleaner

GDK_BACKEND=wayland ./BambuStudio_wayland-test_ubu24_a96dc5ad7.AppImage

[0x00007f9e5488ff80] [trace]   Initializing StaticPrintConfigs

(bambu-studio:6881): Gtk-CRITICAL **: 09:02:30.416: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:6881): Gtk-CRITICAL **: 09:02:30.416: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:6881): Gtk-CRITICAL **: 09:02:30.417: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:6881): Gtk-CRITICAL **: 09:02:30.418: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:6881): Gtk-CRITICAL **: 09:02:30.418: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:6881): Gtk-CRITICAL **: 09:02:30.419: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:6881): Gtk-CRITICAL **: 09:02:30.423: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:6881): Gtk-CRITICAL **: 09:02:30.424: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:6881): Gtk-CRITICAL **: 09:02:30.425: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:6881): Gtk-CRITICAL **: 09:02:30.425: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:6881): Gtk-CRITICAL **: 09:02:30.426: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:6881): Gtk-CRITICAL **: 09:02:30.427: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:6881): Gtk-CRITICAL **: 09:02:30.427: gtk_window_resize: assertion 'width > 0' failed
1. lo    : 127.0.0.1
2. enp5s0: 192.168.8.5
3. docker0: 172.17.0.1

use_count = 4

When BambuStudio starts without input files, post_init() disables canvas
rendering, switches to the 3D tab and eagerly initializes OpenGL — but
only if the canvas passes IsShownOnScreen() && make_current_for_postinit()
at that instant. On Wayland this guard can never pass: the EGL canvas's
IsShownOnScreen() requires its wl_subsurface, which is only created when
the widget is mapped, and mapping cannot happen within the same event-loop
turn that just switched the tab. The "postpone the init" branch then left
rendering disabled with no retry anywhere, so GLCanvas3D::render()
returned at the !m_enable_render guard for the rest of the session. An
EGL interposer confirmed the process never issued a single
eglMakeCurrent/eglSwapBuffers; the "blank viewport after loading a model"
reported on PR bambulab#11821 is this dead render loop becoming visible the first
time the user opens the Prepare tab. Starting with a file on the command
line sets switch_to_3d and skips the block entirely, which is why that
path always rendered and why the bug looked load-related.

Two changes:

- GUI_App::post_init(): when the eager init is postponed, re-enable
  rendering so the normal render path — which is fully guarded by
  _is_shown_on_screen(), _set_current() and init_opengl() — performs the
  same initialization lazily on the first paint after the canvas is
  actually mapped. This is exactly the sequence the (working)
  start-with-a-file path already uses.

- GLCanvas3D::init(): if model objects were loaded while GL init was
  still deferred, the reload_scene() calls made during that load were
  no-ops (reload_scene early-returns when !m_initialized), leaving the
  scene empty after the deferred init. Rebuild the scene at the end of
  init() in that case (deferred refresh; init() runs inside render()).

Verified on NVIDIA RTX 4090 / driver 610.43.03 / Hyprland, native
Wayland: start without file → load model at runtime now shows plate and
model (was: grey viewport); second runtime load also renders; start with
file unchanged. X11 (XWayland): start with file renders identically to
the unpatched build; post_init still takes the eager branch there.
@mindrunner

Copy link
Copy Markdown
Contributor Author

The "viewport blank after loading a model" bug is diagnosed and fixed — commit a8beca8, new test build: wayland-test-a8beca80b (AppImage is uploading from CI and appears on the release shortly).

Root cause

It was never a load-path or rendering bug — the render loop was dead from startup. When the app starts without a file argument, GUI_App::post_init() disables canvas rendering, switches to the 3D tab and tries to initialize OpenGL eagerly, guarded by IsShownOnScreen() && make_current_for_postinit(). On Wayland that guard can never pass: the EGL canvas's IsShownOnScreen() requires its wl_subsurface, which only exists after the widget is mapped — impossible in the same event-loop turn that just switched the tab. The code then takes the "postpone the init" branch, which never re-enables rendering, and there is no retry. GLCanvas3D::render() returns at the !m_enable_render guard for the rest of the session; an LD_PRELOAD EGL tracer confirmed the process never issues a single eglMakeCurrent/eglSwapBuffers. The grey viewport is the GTK parent surface behind a subsurface that never receives a buffer — users first see it after loading a model, hence the "blank after load" symptom.

Starting with a file on the command line sets switch_to_3d, skips that block entirely, and renders fine on Wayland — including further models loaded into the running instance. That's why the bug looked load-related and intermittent.

Fix (2 small changes)

  1. GUI_App::post_init(): the postpone branch now re-enables rendering, so the fully-guarded render path performs the same GL initialization lazily on the first paint after the canvas is mapped — the exact sequence the working start-with-file path already uses.
  2. GLCanvas3D::init(): if model objects were loaded while GL init was still deferred, the reload_scene() calls made during the load were no-ops; the scene is now rebuilt at the end of init() so those objects appear.

Verified (screenshots, NVIDIA RTX 4090 / driver 610.43.03 / Hyprland)

Scenario Before After
native Wayland, start w/o file → import model grey viewport plate + model render
native Wayland, second import into same instance renders
native Wayland, start with file renders renders (unchanged)
X11 (XWayland), start with file renders renders (pixel-identical)

Not yet re-verified on Intel/Mesa with this commit — covered by the earlier commits' testing, will re-check with the new AppImage.

Related find

While debugging this I found that Linux single-instance file passing (handing a file to an already-running instance) has never worked on any backend — a DBus name case mismatch makes the message vanish silently. Fixed separately in #11826.

@SR-G

SR-G commented Aug 7, 2026

Copy link
Copy Markdown

Still ARCH + COSMIC + same NVIDIA drivers, still launching with GDK_BACKEND variable.
Seems way better now.
I have the viewport properly displayed (after opening a file through the UI).

image
GDK_BACKEND=wayland ./BambuStudio_wayland-test_ubu24_a8beca80b.AppImage 
(bambu-studio:311520): Gtk-CRITICAL **: 14:42:28.675: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:311520): Gtk-CRITICAL **: 14:42:28.677: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:311520): Gtk-CRITICAL **: 14:42:28.678: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:311520): Gtk-CRITICAL **: 14:42:28.680: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:311520): Gtk-CRITICAL **: 14:42:28.682: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:311520): Gtk-CRITICAL **: 14:42:28.684: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:311520): Gtk-CRITICAL **: 14:42:28.695: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:311520): Gtk-CRITICAL **: 14:42:28.697: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:311520): Gtk-CRITICAL **: 14:42:28.700: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:311520): Gtk-CRITICAL **: 14:42:28.701: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:311520): Gtk-CRITICAL **: 14:42:28.703: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:311520): Gtk-CRITICAL **: 14:42:28.705: gtk_window_resize: assertion 'width > 0' failed

(bambu-studio:311520): Gtk-CRITICAL **: 14:42:28.706: gtk_window_resize: assertion 'width > 0' failed
1. lo    : 127.0.0.1
2. enp5s0: 192.168.8.5
3. docker0: 172.17.0.1

use_count = 4

@mindrunner
mindrunner marked this pull request as ready for review August 7, 2026 12:58
@mindrunner

mindrunner commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for testing this @SR-G . Works for me on both nvidia and intel/mesa. marking the PR ready to review again

@mindrunner mindrunner changed the title WIP: Add opt-in native Wayland support on Linux Add opt-in native Wayland support on Linux Aug 7, 2026
@phisch

phisch commented Aug 10, 2026

Copy link
Copy Markdown

I just tested your latest AppImage for this, and it already runs so much smoother and less buggy than the X11 client for me! It scales properly, I see no long black screens, it loads the printer device status and video preview, and it seems like starting prints works reliably, unlike the x11 client that permanently freezes often when trying to start a print.

The only 2 things I noticed in that quick test:

  • no splash
  • resizing the sidebar in prepare/preview is very sluggish, and also rotates the 3d preview somewhat

Recorded a short video of it:

1786379406.mp4

It still has some issues, but is already much more usable, and I will start using it over the xwayland client already! 👍

mtharpe added a commit to mtharpe/BambuStudio that referenced this pull request Aug 10, 2026
v3 revision consolidating what we learned executing Phases 0-2:

- Environment: concrete details (Fedora 44, GNOME 50, Intel Arc LNL, xe
  driver, Mesa 26.1.6)
- Communication policy: hard rule that tooling never publishes to
  bambulab/*; drafts stay local, user posts manually
- Category C: seven build-system / Fedora ergonomic issues discovered
  during Phase 1 (apt-not-dnf, missing perl-FindBin/nasm/libquadmath-devel,
  lib vs lib64 split, silent-failure cascade, missing +x)
- Category D: two issues surfaced by Phase 2 pr/11821 testing (no SSD
  under GNOME Wayland, XWayland hang whose regression-status is TBD)
- Build recipe: what actually works on Fedora 44 today, until Cat C
  fixes land
- Phase 2.5 proposed: master-build comparison to determine whether
  the XWayland hang (D2) is a bambulab#11821 regression or pre-existing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linux Wayland support

3 participants