flightlessmango / MangoHud

A Vulkan and OpenGL overlay for monitoring FPS, temperatures, CPU/GPU load and more. Discord: https://discordapp.com/invite/Gj5YmBb
MIT License
6.13k stars 262 forks source link

Does not work with Factorio on wayland #937

Open obj-obj opened 1 year ago

obj-obj commented 1 year ago

Have tried both with and without dlsym, works fine if I remove SDL_VIDEODRIVER=wayland

fakhraldin commented 9 months ago

Seems to be related to bug report #477 dating back to Feb 6, 2021 Quite annoying

fakhraldin commented 9 months ago

Try gallium hud alternatively. It should work for opengl. Add this environment variable.: GALLIUM_HUD=.x300fps,simple ".x300" will put FPS pane 300 pixels to the left. For more options type in terminal.: GALLIUM_HUD=help glxgears

Lassebq commented 6 months ago

I tried Celeste with SDL_VIDEODRIVER=wayland and --dlsym and it works fine? Is it specific to certain games? The window is wayland native, I did check that.

matrikslee commented 4 months ago

I encountered the same problem, but if I use the zink driver, mangohud can display correctly(hud show the correct driver ZINK when gaming).

my factorio launch option:

SDL_VIDEODRIVER="wayland,x11" mangohud %command%

zink driver launch option:

MESA_LOADER_DRIVER_OVERRIDE=zink GALLIUM_DRIVER=zink SDL_VIDEODRIVER="wayland,x11" vk_radv mangohud %command%
obj-obj commented 4 months ago

I encountered the same problem, but if I use the zink driver, mangohud can display correctly(hud show the correct driver ZINK when gaming).

my factorio launch option:

SDL_VIDEODRIVER="wayland,x11" mangohud %command%

zink driver launch option:

MESA_LOADER_DRIVER_OVERRIDE=zink GALLIUM_DRIVER=zink SDL_VIDEODRIVER="wayland,x11" vk_radv mangohud %command%

Doesn't factorio already use opengl though? How does zink change anything?

obj-obj commented 4 months ago

It works, weird

Lassebq commented 4 months ago

Doesn't factorio already use opengl though? How does zink change anything?

@obj-obj Zink translates opengl to vulkan

obj-obj commented 4 months ago

Doesn't factorio already use opengl though? How does zink change anything?

@obj-obj Zink translates opengl to vulkan

I forgot, thought it was the other way around. My bad

Raikiri commented 1 month ago

SDL_VIDEODRIVER=wayland does make factorio run much better under wayland (there's terrible flickering every couple seconds otherwise), however, it still fails to launch with mangohud. Also tried MESA_LOADER_DRIVER_OVERRIDE=zink but with no success. The zink driver does work (I can see it in factorio logs) and the game launches but only there's no mangohud in its command line. As soon as I add mangohud to the command line, it stops launching.

flightlessmango commented 1 month ago

@Raikiri if the game doesn't start when you add mangohud to it, then mangohud is not properly installed. One common reason is if you installed steam using flatpak but using normal mangohud or vice versa

Raikiri commented 1 month ago

@Raikiri if the game doesn't start when you add mangohud to it, then mangohud is not properly installed. One common reason is if you installed steam using flatpak but using normal mangohud or vice versa

I should have mentioned that I'm on NixOS. Here's my steam installation:

  programs.steam = {
    enable = true;
  };

Here's mangohud:

  environment.systemPackages = with pkgs; [
    <...>
    mangohud
    <...>
  ];

I'm running a plasma6 wayland session, but running plasma6 x11 session seems to behave exactly the same way (fails to start).

mangohud glxgears (opengl overlay on integrated gpu) works, mangohud vkcube (vulkan overlay on nvidia) works too, MESA_LOADER_DRIVER_OVERRIDE=zink mangohud glxgears (opengl overlay on zinc) also works. I also tested Cyberpunk (runs on proton), Underrail, Valheim and a bunch of other d3d proton games, they all seem to run fine with mangohud. I think factorio specifically is failing because it's running natively on SDL.

I also have a dual boot PopOS that also has steam with mangohud and that's somehow running factorio with mangohud just fine, so it's not a hardware issue.

It has to be something specific to NixOS, but probably not related to my nvidia gpu setup, because the game runs with the integrated gpu by default anyway (and still fails to launch with mangohud).

Raikiri commented 1 month ago

If I run steam via the terminal and launch factorio (without mangohud), I get a bunch of logs from it:

/bin/sh\0-c\0SDL_VIDEODRIVER=wayland nvidia-offload /home/suslik/.local/share/Steam/ubuntu12_32/reaper SteamLaunch AppId=427520 -- /home/suslik/.local/share/Steam/ubuntu12_32/steam-launch-wrapper -- '/media/LinuxData/SteamLibrary/steamapps/common/Factorio/bin/x64/factorio'\0
chdir "/media/LinuxData/SteamLibrary/steamapps/common/Factorio"
ERROR: ld.so: object '/home/suslik/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
ERROR: ld.so: object '/home/suslik/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
ERROR: ld.so: object '/home/suslik/.local/share/Steam/ubuntu12_64/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
ERROR: ld.so: object '/home/suslik/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
ERROR: ld.so: object '/home/suslik/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
   0.000 Initializing Steam API.
[S_API] SteamAPI_Init(): Loaded '/home/suslik/.local/share/Steam/linux64/steamclient.so' OK.
Setting breakpad minidump AppID = 427520
SteamInternal_SetMinidumpSteamID:  Caching Steam ID:  <...> [API loaded no]
   0.000 2024-06-09 22:22:00; Factorio 1.1.107 (build 62234, linux64, steam)
ERROR: ld.so: object '/home/suslik/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
ERROR: ld.so: object '/home/suslik/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
ERROR: ld.so: object '/home/suslik/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
ERROR: ld.so: object '/home/suslik/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
   0.088 Operating system: Linux (NixOS 24.05)
  <...> proceeds with the log

There's a bunch of errors there and there's no steam overlay (it's enabled in the settings), but the game runs fine. I wonder if lack of the steam overlay is indicative of some failure though. Here's if I launch factorio with mangohud:

bin/sh\0-c\0SDL_VIDEODRIVER=wayland mangohud /home/suslik/.local/share/Steam/ubuntu12_32/reaper SteamLaunch AppId=427520 -- /home/suslik/.local/share/Steam/ubuntu12_32/steam-launch-wrapper -- '/media/LinuxData/SteamLibrary/steamapps/common/Factorio/bin/x64/factorio'\0
chdir "/media/LinuxData/SteamLibrary/steamapps/common/Factorio"
ERROR: ld.so: object '/home/suslik/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
ERROR: ld.so: object '/home/suslik/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
pid 40451 != 40450, skipping destruction (fork without exec?)
ERROR: ld.so: object '/home/suslik/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
pid 40453 != 40450, skipping destruction (fork without exec?)
ERROR: ld.so: object '/home/suslik/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
ERROR: ld.so: object '/home/suslik/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
ERROR: ld.so: object '/home/suslik/.local/share/Steam/ubuntu12_64/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
ERROR: ld.so: object '/home/suslik/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
ERROR: ld.so: object '/home/suslik/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
Uploaded AppInterfaceStats to Steam //<--- this is output when the program closes, log finishes here

That "fork without exec" thing seems to be only there with mangohud. Sorry man that's a lot of information, but I really have no idea what here is relevant.

PS thanks for the work you're doing, I think the linux ecosystem as a whole benefits greatly from mangohud. It played a significant role in making me want to switch from windows.

flightlessmango commented 1 month ago

To clarify, you can run other games in steam with mangohud? Because what it looks like is that steam can't find the mangohud script and so instantly crashes

Raikiri commented 1 month ago

To clarify, you can run other games in steam with mangohud? Because what it looks like is that steam can't find the mangohud script and so instantly crashes

Yes, I can run every other game I have under steam with mangohud using the same command line. It's something to do specifically with factorio and specifically with mangohud under nixos.

RichardFevrier commented 1 week ago

Couldn't make it run either with my game made with SDL3.