[1.1.59] Can not launch on Wayland compositor

Post your bugs and problems so we can fix them.
Post Reply
User avatar
ptx0
Smart Inserter
Smart Inserter
Posts: 1358
Joined: Wed Jan 01, 2020 7:16 pm
Contact:

[1.1.59] Can not launch on Wayland compositor

Post by ptx0 »

Hello,

Background

The latest Fedora builds are using the Wayland display system instead of Xorg. This has been supported in SDL2 graphics library since around 2016 and then early this year, they enabled by default. This was then reverted just before SDL2 2.0.22 release because it was considered not ready yet with NVIDIA drivers. Fast forward to this week where SDL2 and NVIDIA now play nicely together with the release of open kernel driver version v515. In addition, my AMD integrated GPU with 4GB UMA memory works even better! As it is a laptop with hybrid graphics, I currently have a far greater number of issues with Xorg, than we do with Wayland.

Problem

Launching Factorio on the Weston compositor that is provided by the Wayland project results in the following:

Code: Select all

% ./bin/x64/factorio                 
   0.000 2022-06-11 12:03:13; Factorio 1.1.59 (build 59719, linux64, full)
   0.008 Operating system: Linux (Fedora)
   0.008 Program arguments: "./bin/x64/factorio" 
   0.008 Read data path: /home/U/factorio/Space Exploration/data
   0.008 Write data path: /home/U/factorio/Space Exploration [394105/404129MB]
   0.008 Binaries path: /home/U/factorio/Space Exploration/bin
   0.011 System info: [CPU: AMD Ryzen 7 5800H with Radeon Graphics, 16 cores, RAM: 60123 MB]
   0.011 Environment: DISPLAY=<unset> WAYLAND_DISPLAY=wayland-1 DESKTOP_SESSION=<unset> XDG_SESSION_DESKTOP=<unset> XDG_CURRENT_DESKTOP=<unset> __GL_FSAA_MODE=<unset> __GL_LOG_MAX_ANISO=<unset> 
__GL_SYNC_TO_VBLANK=<unset> __GL_SORT_FBCONFIGS=<unset> __GL_YIELD=<unset>
   0.011 Display options: [FullScreen: 1] [VSync: 0] [UIScale: custom (125.0%)] [Native DPI: 1] [Screen: 255] [Special: lmw] [Lang: en]
Factorio crashed. Generating symbolized stacktrace, please wait ...
/tmp/factorio-build-Xa3JcI/src/Util/Logger.cpp (313): Logger::writeStacktrace(FileWriteStream*, StackTraceInfo*) [clone .constprop.0]
/tmp/factorio-build-Xa3JcI/src/Util/Logging.cpp (101): Logging::logAndAbortOrThrow(char const*, unsigned int, LogLevel, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<ch
ar> > const&) [clone .constprop.0]
/tmp/factorio-build-Xa3JcI/src/Util/Logging.cpp (93): Logging::logAndAbortOrThrow(char const*, unsigned int, LogLevel, char const*, ...) [clone .constprop.0]
/tmp/factorio-build-Xa3JcI/src/Graphics/SDLWindow.cpp (117): SDLWindow::SDLWindow(GraphicsInterface::Type, WindowPositionData) [clone .constprop.0]
/tmp/factorio-build-Xa3JcI/src/Graphics/SDLWindow.cpp (103): SDLWindow::SDLWindow(GraphicsInterface::Type, short, short, bool)
/tmp/factorio-build-Xa3JcI/src/GlobalContext.cpp (923): GlobalContext::loadGraphics(std::optional<WindowPositionData>) [clone .isra.0]
/tmp/factorio-build-Xa3JcI/src/GlobalContext.cpp (450): GlobalContext::init(bool, bool, bool, std::optional<WindowPositionData>) [clone .constprop.0] [clone .isra.0]
/tmp/factorio-build-Xa3JcI/src/MainLoop.cpp (272): MainLoop::run(Filesystem::Path const&, Filesystem::Path const&, bool, bool, std::function<void ()>, Filesystem::Path const&, MainLoop::HeavyMod
e)
/tmp/factorio-build-Xa3JcI/src/Main.cpp (1142): main
0x7fae3fa7d1e9
__libc_start_main
0x76195d
0xffffffffffffffff
Stack trace logging done
   0.090 Error SDLWindow.cpp:117: SDL couldn't be initialized. SDL_Error: No available video device
Logger::writeStacktrace skipped.
   0.090 Error Util.cpp:97: Unexpected error occurred. If you're running the latest version of the game you can help us solve the problem by posting the contents of the log file on the Factorio 
forums.
Please also include the save file(s), any mods you may be using, and any steps you know of to reproduce the crash.
   0.091 Error MessageDialog.cpp:53: Unable to show message dialog. SDL Error: [No message system available]
The SDL2 project describes parameters we can use to override with wayland backend:

Code: Select all

% SDL_VIDEODRIVER=wayland ./bin/x64/factorio 2>&1
   0.000 2022-06-11 12:05:13; Factorio 1.1.59 (build 59719, linux64, full)
   0.007 Operating system: Linux (Fedora)
   0.007 Program arguments: "./bin/x64/factorio" 
   0.007 Read data path: /home/U/factorio/Space Exploration/data
   0.007 Write data path: /home/U/factorio/Space Exploration [394103/404127MB]
   0.007 Binaries path: /home/U/factorio/Space Exploration/bin
   0.011 System info: [CPU: AMD Ryzen 7 5800H with Radeon Graphics, 16 cores, RAM: 60123 MB]
   0.011 Environment: DISPLAY=<unset> WAYLAND_DISPLAY=wayland-1 DESKTOP_SESSION=<unset> XDG_SESSION_DESKTOP=<unset> XDG_CURRENT_DESKTOP=<unset> __GL_FSAA_MODE=<unset> __GL_LOG_MAX_ANISO=<unset> 
__GL_SYNC_TO_VBLANK=<unset> __GL_SORT_FBCONFIGS=<unset> __GL_YIELD=<unset>
   0.011 Display options: [FullScreen: 1] [VSync: 0] [UIScale: custom (125.0%)] [Native DPI: 1] [Screen: 255] [Special: lmw] [Lang: en]
Factorio crashed. Generating symbolized stacktrace, please wait ...
/tmp/factorio-build-Xa3JcI/src/Util/Logger.cpp (313): Logger::writeStacktrace(FileWriteStream*, StackTraceInfo*) [clone .constprop.0]
/tmp/factorio-build-Xa3JcI/src/Util/Logging.cpp (101): Logging::logAndAbortOrThrow(char const*, unsigned int, LogLevel, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<ch
ar> > const&) [clone .constprop.0]
/tmp/factorio-build-Xa3JcI/src/Util/Logging.cpp (93): Logging::logAndAbortOrThrow(char const*, unsigned int, LogLevel, char const*, ...) [clone .constprop.0]
/tmp/factorio-build-Xa3JcI/src/Graphics/SDLWindow.cpp (117): SDLWindow::SDLWindow(GraphicsInterface::Type, WindowPositionData) [clone .constprop.0]
/tmp/factorio-build-Xa3JcI/src/Graphics/SDLWindow.cpp (103): SDLWindow::SDLWindow(GraphicsInterface::Type, short, short, bool)
/tmp/factorio-build-Xa3JcI/src/GlobalContext.cpp (923): GlobalContext::loadGraphics(std::optional<WindowPositionData>) [clone .isra.0]
/tmp/factorio-build-Xa3JcI/src/GlobalContext.cpp (450): GlobalContext::init(bool, bool, bool, std::optional<WindowPositionData>) [clone .constprop.0] [clone .isra.0]
/tmp/factorio-build-Xa3JcI/src/MainLoop.cpp (272): MainLoop::run(Filesystem::Path const&, Filesystem::Path const&, bool, bool, std::function<void ()>, Filesystem::Path const&, MainLoop::HeavyMod
e)
/tmp/factorio-build-Xa3JcI/src/Main.cpp (1142): main
0x7f9b39b021e9
__libc_start_main
0x76195d
0xffffffffffffffff
Stack trace logging done
   0.088 Error SDLWindow.cpp:117: SDL couldn't be initialized. SDL_Error: wayland not available
Logger::writeStacktrace skipped.
   0.088 Error Util.cpp:97: Unexpected error occurred. If you're running the latest version of the game you can help us solve the problem by posting the contents of the log file on the Factorio 
forums.
Please also include the save file(s), any mods you may be using, and any steps you know of to reproduce the crash.
   0.089 Error MessageDialog.cpp:53: Unable to show message dialog. SDL Error: [No message system available]
The message becomes "wayland not available" when trying this.

I then see that we can try to tell Factorio to use the OS-provided SDL2 build, which can be newer and include wayland backend:

Code: Select all

% env SDL_VIDEODRIVER=wayland SDL_DYNAMIC_API=/usr/lib64/libSDL2.so ./bin/x64/factorio
   0.000 2022-06-11 12:07:03; Factorio 1.1.59 (build 59719, linux64, full)
   0.007 Operating system: Linux (Fedora)
   0.007 Program arguments: "./bin/x64/factorio" 
   0.007 Read data path: /home/U/factorio/Space Exploration/data
   0.007 Write data path: /home/U/factorio/Space Exploration [394103/404128MB]
   0.007 Binaries path: /home/U/factorio/Space Exploration/bin
   0.011 System info: [CPU: AMD Ryzen 7 5800H with Radeon Graphics, 16 cores, RAM: 60123 MB]
   0.011 Environment: DISPLAY=<unset> WAYLAND_DISPLAY=wayland-1 DESKTOP_SESSION=<unset> XDG_SESSION_DESKTOP=<unset> XDG_CURRENT_DESKTOP=<unset> __GL_FSAA_MODE=<unset> __GL_LOG_MAX_ANISO=<unset> 
__GL_SYNC_TO_VBLANK=<unset> __GL_SORT_FBCONFIGS=<unset> __GL_YIELD=<unset>
   0.011 Display options: [FullScreen: 1] [VSync: 0] [UIScale: custom (125.0%)] [Native DPI: 1] [Screen: 255] [Special: lmw] [Lang: en]
Factorio crashed. Generating symbolized stacktrace, please wait ...
/tmp/factorio-build-Xa3JcI/src/Util/Logger.cpp (313): Logger::writeStacktrace(FileWriteStream*, StackTraceInfo*) [clone .constprop.0]
/tmp/factorio-build-Xa3JcI/src/Util/Logging.cpp (101): Logging::logAndAbortOrThrow(char const*, unsigned int, LogLevel, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<ch
ar> > const&) [clone .constprop.0]
/tmp/factorio-build-Xa3JcI/src/Util/Logging.cpp (93): Logging::logAndAbortOrThrow(char const*, unsigned int, LogLevel, char const*, ...) [clone .constprop.0]
/tmp/factorio-build-Xa3JcI/src/Graphics/SDLWindow.cpp (117): SDLWindow::SDLWindow(GraphicsInterface::Type, WindowPositionData) [clone .constprop.0]
/tmp/factorio-build-Xa3JcI/src/Graphics/SDLWindow.cpp (103): SDLWindow::SDLWindow(GraphicsInterface::Type, short, short, bool)
/tmp/factorio-build-Xa3JcI/src/GlobalContext.cpp (923): GlobalContext::loadGraphics(std::optional<WindowPositionData>) [clone .isra.0]
/tmp/factorio-build-Xa3JcI/src/GlobalContext.cpp (450): GlobalContext::init(bool, bool, bool, std::optional<WindowPositionData>) [clone .constprop.0] [clone .isra.0]
/tmp/factorio-build-Xa3JcI/src/MainLoop.cpp (272): MainLoop::run(Filesystem::Path const&, Filesystem::Path const&, bool, bool, std::function<void ()>, Filesystem::Path const&, MainLoop::HeavyMod
e)
/tmp/factorio-build-Xa3JcI/src/Main.cpp (1142): main
0x7f256bfd01e9
__libc_start_main
0x76195d
0xffffffffffffffff
Stack trace logging done
   0.089 Error SDLWindow.cpp:117: SDL couldn't be initialized. SDL_Error: wayland not available
Logger::writeStacktrace skipped.
   0.089 Error Util.cpp:97: Unexpected error occurred. If you're running the latest version of the game you can help us solve the problem by posting the contents of the log file on the Factorio 
forums.
Please also include the save file(s), any mods you may be using, and any steps you know of to reproduce the crash.
   0.089 Error MessageDialog.cpp:53: Unable to show message dialog. SDL Error: [No message system available]
Same error. I began wondering whether the OS SDL2 build even worked, so I compiled a test programme:

Code: Select all

% cat sdl_test_wayland.c 
#include <stdio.h>
#include <SDL.h>
int main( int argc, char *argv[] ) {
    if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) {
        printf( "SDL_Init() error: %s\n", SDL_GetError() );
        return 1;
    }
    printf( "SDL_Init() succeeded.\n" );
    printf( "SDL_GetCurrentVideoDriver(): %s\n", SDL_GetCurrentVideoDriver() );
    return 0;
}
Compiled:

Code: Select all

% gcc -o sdl_test_wayland sdl_test_wayland.c -g -lSDL2 -lGL -I/usr/include/SDL2
Ran:

Code: Select all

% ./sdl_test_wayland
SDL_Init() succeeded.
SDL_GetCurrentVideoDriver(): wayland
so the OS-provided SDL2 does work.

for further experimentation, I've added the OS-provided SDL2 to LD_PRELOAD, but I guess that doesn't work for overriding statically bundled libraries.

User avatar
ptx0
Smart Inserter
Smart Inserter
Posts: 1358
Joined: Wed Jan 01, 2020 7:16 pm
Contact:

Re: [1.1.59] Can not launch on Wayland compositor

Post by ptx0 »

it would be nice of Oxyd could maybe look into this one, because it's severely impacting performance on Linux systems now that Wayland is default in Ubuntu and Fedora.

unfortunately, though X11 is an option at the login menu, it has other performance issues and cannot be used for day-to-day use on modern hardware.

User avatar
jodokus31
Smart Inserter
Smart Inserter
Posts: 1394
Joined: Sun Feb 26, 2017 4:13 pm
Contact:

Re: [1.1.59] Can not launch on Wayland compositor

Post by jodokus31 »

Just one small idea.
Is the problem connected with the Weston compositor or wayland itself?
I used desktop env Cinnamon before, but switched to Xfce to be able to switch off the compositor (still on X11, though). This made factorio a bit smoother.

User avatar
ptx0
Smart Inserter
Smart Inserter
Posts: 1358
Joined: Wed Jan 01, 2020 7:16 pm
Contact:

Re: [1.1.59] Can not launch on Wayland compositor

Post by ptx0 »

jodokus31 wrote:
Sat Jun 18, 2022 7:48 am
Just one small idea.
Is the problem connected with the Weston compositor or wayland itself?
I used desktop env Cinnamon before, but switched to Xfce to be able to switch off the compositor (still on X11, though). This made factorio a bit smoother.
yeah that's completely different.

i have a hybrid graphics laptop with AMDGPU and NVIDIA. so in Xorg or Xwayland, it just feels and looks like unplayable garbage.

but for native Wayland games where SDL2 allows me to override the backend, Wayland gaming is quite excellent on this laptop.

User avatar
ptx0
Smart Inserter
Smart Inserter
Posts: 1358
Joined: Wed Jan 01, 2020 7:16 pm
Contact:

use-flip-presentation-model fixes XWayland on hybrid graphics

Post by ptx0 »

i've spent the last 2 hours testing this in various configurations inside Xwayland using hybrid graphics (AMDGPU primary, NVIDIA 3070 8GB secondary)

I've made a few observations. The AMDGPU and NVIDIA both struggle in different/similar ways.

AMDGPU caps out at 50-53 FPS, 60 UPS. it is consistently stuttery, but more playable.
NVIDIA caps out at 56-60 FPS, 60 UPS. it is terrible. even with DRI_PRIME=1 to fix screen tearing, it is unplayable. i notice that the loading bar goes BACKWARDS when the game loads. it flickers and appears to go backwards. then, there is EXTREME screen tearing.

I've modified the Sprite Resolution, the Atlas size, the Colour depth, pretty much every single option inside the main Graphics menu. nothing really helped. even disabling all decorations/clouds/smoke/everything, still kept me capped at 53FPS.

one thing I then tried was flip-presentation-model = true, which resolved the performance issues in XWayland for both NVIDIA and AMDGPU.

in fact, with flip-presentation-model, the game is more smooth than I've ever seen it on Linux before. no more periodic hitching, and FreeSync / G-Sync are working properly.
NVIDIA: 60FPS/60UPS, unless I have a YouTube video playing on my 2ndary display. This makes the game feel like every other or every third frame is missing.
AMDGPU: 60FPS/60UPS even if I have YouTube playing on my 2ndary display. Super smooth, no matter what.

I disabled flip-presentation-model and the performance went back to the way it was before. constant, stuttery, hiccups. Enabled the option again, and we're back to 60/60. I restored default settings for everything, and enabled only this option. Still smooth as glass.

this isn't a real solution for the long-term because it should ideally be possible to disable XWayland and run in native SDL2<->Wayland. I had to update everything on my system to "unstable" versions to get all of the latest compatibility layers:

[*] Plasma 5.25 that came out 4 days ago, a new version of KDE Plasma with more Wayland fixes.
[*] NVIDIA driver 515.48.07 with the newly-released open source kernel module, published on the 2nd of this month

however, on Ubuntu 22.04, none of this is available. the versions lag behind on 5.24 and version 510 of the NVIDIA drivers, without jumping through many hoops.

User avatar
ptx0
Smart Inserter
Smart Inserter
Posts: 1358
Joined: Wed Jan 01, 2020 7:16 pm
Contact:

Re: [1.1.59] Can not launch on Wayland compositor

Post by ptx0 »

I forgot to mention I had also tried __GL_YIELD="USLEEP" and that didn't change much about the problem. it might have, but it was hard to tell.

Post Reply

Return to “Bug Reports”