Linux CLI: bundled GLFW 3.3.7 is Wayland-only, so X11/Xvfb exports have no plate thumbnails (and WSLg segfaults)
Summary
On Linux the CLI renders plate thumbnails through GLFW, but deps/GLFW/GLFW.cmake builds GLFW 3.3.7 with -DGLFW_USE_WAYLAND=ON. GLFW 3.3 picks one platform at compile time, so the bundled GLFW is Wayland-only:
- X11-only host (Xorg desktop,
xvfb-runon a build server or CI):glfwInit()fails with65544(GLFW_PLATFORM_ERROR), the log saysinit opengl failed! skip thumbnail generating, and the exported 3MF has no plate thumbnails at all. - A Wayland socket that is not a full desktop compositor (WSLg here): the CLI segfaults in
glfwCreateWindow()(_glfwPlatformCreateWindow->wl_proxy_get_versionin libwayland-client). I hit this on the official v2.4.2-alpha AppImage while testing #1297.
Repro
Two-plate X1 Carbon project from --load-assemble-list, --export-3mf project.3mf, run under xvfb-run -a with WAYLAND_DISPLAY unset and XDG_RUNTIME_DIR pointing at an empty directory (so only X11 exists). Build: upstream/main e8f1aa06d6 plus #1297, WSL2 Ubuntu, Release.
project rc=0
[error] glfwInit return error, code 65544
[error] init opengl failed! skip thumbnail generating
project.3mf pngs: []
What I tried
Branch https://github.com/DesignMaster-Solutions/OrcaSlicer/tree/glfw-34-x11-wayland (4630f8d) ports the GLFW half of upstream OrcaSlicer 3e4af2c (#13197): GLFW 3.4 with -DGLFW_BUILD_WAYLAND=ON -DGLFW_BUILD_X11=ON (platform picked at run time), GL 3.3 requested explicitly (the current code passes the GLFW library version from glfwGetVersion() as the OpenGL version, which would ask for a non-existent GL 3.4 with GLFW 3.4), OSMesa hint dropped, fallback to the driver default, and thumbnails skipped when no window exists.
Same repro with that branch (deps rebuilt with cmake --build deps/build --target dep_GLFW, app rebuilt rc=0):
project rc=0
[error] Unable to init glew library
[error] init opengl failed! skip thumbnail generating
project.3mf pngs: []
So GLFW 3.4 now initializes and creates the hidden window on X11, and the next blocker is glewInit(). Upstream did not stop at GLFW: the same commit 3e4af2c replaced GLEW with glad (src/glad/, OpenGLManager::init_gl uses gladLoadGL), which loads through the current context of whichever platform GLFW picked. A complete fix here looks like the same pair: GLFW 3.4 + glad, or at least a GLEW init that does not depend on the GLX/Wayland mix.
Notes
- Upgrading the dep invalidates the CI deps cache once.
- If you clear only
deps/build/dep_GLFW-prefix/src/dep_GLFW-build, GLFW 3.4 stops withGLFW_USE_WAYLAND has been removed; delete the CMake cache; removingdeps/build/dep_GLFW-prefixand re-runningcmake deps/buildis enough. - I can turn the branch into a PR with the glad part if you want this direction; it touches every file that includes
GL/glew.h, so I would rather ask first.
Follow-up with the cause of the glewInit() failure and the next blocker.
GLEW only initialises on an EGL context. The bundled static GLEW resolves entry points with eglGetProcAddress (linking a test program against deps/build/destdir/usr/local/lib/libGLEW.a without -lEGL fails on exactly that symbol). A 30-line test program with GLFW 3.4, the same hints as the CLI (GL 3.3 compat, hidden window) and that GLEW, under xvfb-run with no Wayland:
== native context (GLX, the GLFW 3.4 default on X11)
platform=X11 ctx api=NATIVE
glewInit=1 Missing GL version
GL_VERSION=4.5 (Compatibility Profile) Mesa 25.2.8
== GLFW_CONTEXT_CREATION_API = GLFW_EGL_CONTEXT_API
platform=X11 ctx api=EGL
glewInit=0 No error
GL_VERSION=4.5 (Compatibility Profile) Mesa 25.2.8
So with GLFW 3.4 the CLI should ask for GLFW_EGL_CONTEXT_API on Linux (that replaces the old OSMesa hint). The branch now has three commits:
4630f8d695GLFW 3.4 with X11 + Wayland, GL 3.3 requested explicitly, fallback and skip when no window.6cee86a166glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API)under__linux__.1268c11dc5the null guard upstream has inCamera::auto_type()(wxApp::GetInstance() == nullptr || wxGetApp().app_config == nullptr): with GL up, the CLI thumbnail render reached it and crashed on the missingapp_config.
With the three, the X11 export gets past GL init and the camera, and then segfaults one step later:
#0 Slic3r::GLShadersManager::get_current_shader()
#1 Slic3r::GUI::GLModel::render(std::pair<unsigned long, unsigned long> const&)
#3 Slic3r::GLVolume::simple_render(...)
#4 Slic3r::GUI::GLCanvas3D::render_thumbnail_internal(...)
#6 Slic3r::CLI::run(int, char**)
GLModel::render asks the GUI app's shader manager for the current shader, and the CLI has no GUI app. So the thumbnail path has never actually run in this CLI on Linux: on X11 it stopped at glfwInit() and on Wayland/WSLg at glfwCreateWindow(). That is why it is not visible today, and also why switching GLFW alone is not a safe PR. I will look at how upstream's CLI gets a shader to GLModel::render before turning this into a PR.
Built in WSL2 Ubuntu 24.04, Release, app rc=0; deps rebuilt with rm -rf deps/build/dep_GLFW-prefix && cmake deps/build && cmake --build deps/build --target dep_GLFW.