FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
Running under Wayland

FhVis and FhSimUI open an SDL2 window and render into it with Ogre3D's OpenGL 3+ render system. On Linux, that window comes from an X11 server or from a Wayland compositor. This page says what works today, how to run without X11, and what the known problems are.

Warning
Running on pure Wayland is experimental. By default the FhSim packages are built with an Ogre that renders through X11. On a Wayland desktop, they run through XWayland, which almost every Wayland desktop (GNOME, KDE Plasma, WSLg) provides. You do not have to do anything for that. To run without X11, build with the options in Building for Wayland.

Status

Ogre build Session Result
X11 (the FhSim packages, ogre3d @sintef/stable) X11, or Wayland with XWayland Works. SDL chooses its X11 driver when DISPLAY is set.
X11 Wayland, SDL_VIDEODRIVER=wayland Fails: "SDL opened a Wayland window, but this Ogre renders only through X11". Unset SDL_VIDEODRIVER.
Wayland (the options in Building for Wayland) Wayland Works. FhSim asks SDL for its Wayland driver unless SDL_VIDEODRIVER is set.
Wayland X11 only (no WAYLAND_DISPLAY) Fails: an Ogre built for Wayland has no X11 support.

On Linux, Ogre's OpenGL support is built for either X11 or Wayland, not for both. A Wayland Ogre therefore needs a Wayland session.

An application that embeds the renderer in a window of its own (fhVisDll, with a visualization panel other than 0) passes an X11 window handle. It works only with an X11 Ogre. With a Wayland Ogre, the run stops with an error that says so. Pass visualization panel 0, so that FhSim opens a window of its own.

Which window system is used

At startup, FhVis and FhSimUI write one line to the FhSim log (level Info, so use -c 3 to see it on the console) and to ogre.log:

SDL video driver: wayland; Ogre window system: wayland

The SDL driver is the window system of the window. The Ogre window system is the one that Ogre was built for. These two must be the same.

If Ogre cannot create its window, the error message gives this line, Ogre's own message, the likely cause and a reference to this page.

Building for Wayland

ogre3d/14.6.2@sintef/stable, which ogrederived/2.9.1 uses, has the options for a Wayland build; no other channel is needed. No CI job builds these binaries, so the first build makes Ogre, SDL, xkbcommon and wayland locally (-b missing). Put the options in a profile:

include(default)
[options]
ogre3d/*:with_wayland=True
ogre3d/*:with_x11=False

With these two, ogre3d sets the rest itself: wayland and xkbcommon as shared libraries, SDL's Wayland driver, xkbcommon's Wayland support, and none of the X11 options of SDL and xkbcommon.

conan build . -pr:h wayland.profile -pr:b default -b missing -o "fhsim/*:with_visualization=True"
source build/Release/generators/conanrun.sh
./build/Release/src/apps/fhExe/FhVis model.xml

conanrun.sh puts the Conan libwayland-client, libxkbcommon and Ogre on the library path and sets XLOCALEDIR. The two shared libraries are needed:

  • wayland: with a static wayland, SDL and Ogre each contain a copy of libwayland-client, and Mesa's EGL loads another. A Wayland connection opened by one copy is not valid in another, so Ogre stops with Couldn't get EGLDisplay.
  • xkbcommon: SDL loads its Wayland libraries at run time by file name. With a static xkbcommon, the name is libxkbcommon.a, which cannot be loaded, and FhVis crashes in SDL's Wayland_VideoInit.

ogrederived needs no build of its own: its stable binary serves both window systems.

Environment variables

Variable Effect
SDL_VIDEODRIVER x11 or wayland selects SDL's video driver. When it is not set, SDL 2 uses X11 if DISPLAY is set. A Wayland Ogre makes FhSim ask SDL for Wayland.
WAYLAND_DISPLAY, XDG_RUNTIME_DIR Identify the Wayland session. The desktop sets them.
DISPLAY Identifies the X server or XWayland.
XLOCALEDIR Set by conanrun.sh. XLOCALEDIR=/usr/share/X11/locale stops the xkbcommon: ERROR: ... No Compose file for locale messages that a Wayland window can print on systems where libxkbcommon looks for the compose files elsewhere. The messages are harmless.

Testing

A test build registers two smoke tests with the label gui. No test tier runs them, so you must ask for them:

source build/Release/generators/conanrun.sh
ctest --test-dir build/Release -R fhvis-window --output-on-failure

fhvis-window-x11 and fhvis-window-wayland run FhVis with that SDL driver. Each test is skipped if there is no session for it or if Ogre renders through the other window system.

Remaining work

  • Wayland binaries from CI. Today, a Wayland build is a local -b missing build with the options above.
  • A way for fhVisDll hosts to pass a Wayland display and surface instead of an X11 window handle.
  • Without a display, FhSimUI --headless still needs an X11 or Wayland session; SDL's offscreen driver is not supported.