steam-for-linux icon indicating copy to clipboard operation
steam-for-linux copied to clipboard

Add Wayland support to the Steam overlay

Open flibitijibibo opened this issue 4 years ago • 50 comments

Your system information

  • Steam client version (build number or date): Jul 20 2021, at 22:25:57
  • Distribution (e.g. Ubuntu): Fedora 34
  • Opted into Steam client beta?: No
  • Have you checked for system updates?: Yes

Please describe your issue in as much detail as possible:

The Steam overlay currently depends on GLX and X WSI for OpenGL and Vulkan respectively. As a result, when running a Wayland-native application the overlay will not appear.

For OpenGL, gameoverlayrenderer.so overrides glX* but not egl*. For Vulkan, steamoverlayvulkanlayer.so only overrides the functions for VK_KHR_xcb_surface and VK_KHR_xlib_surface, not VK_KHR_wayland_surface.

This will take time to write (mostly for input handling I imagine) so a workaround would be for Steam to set SDL_VIDEODRIVER to x11 if it's unset, being sure to only do this for native applications.

Steps for reproducing this issue:

  1. Take any game with a recent SDL version (my go-to is the public Steam beta for FEZ)
  2. Set SDL_VIDEODRIVER=wayland %command% /gldevice:XXX as a launch option, where XXX can be OpenGL or Vulkan
  3. Observe no overlay

flibitijibibo avatar Aug 27 '21 04:08 flibitijibibo

Related to this, https://github.com/ValveSoftware/steam-runtime/issues/473#issuecomment-953932369 mentions that in at least some configurations, the overlay is loaded into a native Wayland app, but causes the app to crash when it is opened.

smcv avatar Jan 04 '22 18:01 smcv

It's starting to look very much like 2.0.22 will be the SDL release that defaults to Wayland... our only blockers are this and NVIDIA finishing their driver support, the latter being actively worked on as we speak.

As a stepping stone to native support, it might be a good idea for the Steam client to check SDL_VIDEODRIVER and set it to x11 if it's unset? That way we can have Wayland be the default in SDL without having to wait for the Steam team to catch up.

flibitijibibo avatar Jan 25 '22 22:01 flibitijibibo

I've been playing Axiom Verge recently (native, FNA game) and Steam overlay shows up but nothing is rendered. For example, achievement popups has nothing on them, just a flat background. Is it due to this issue? I'll launch the game with SDL_VIDEODRIVER=wayland and see if it works better.

murlakatamenka avatar Feb 08 '22 06:02 murlakatamenka

I've been playing Axiom Verge recently (native, FNA game) and Steam overlay shows up but nothing is rendered. For example, achievement popups has nothing on them, just a flat background. Is it due to this issue? I'll launch the game with SDL_VIDEODRIVER=wayland and see if it works better.

#7889

flibitijibibo avatar Feb 08 '22 07:02 flibitijibibo

@flibitijibibo thanks, Ethan, that's exactly the issue. You can add the list of games you have there.

murlakatamenka avatar Feb 09 '22 02:02 murlakatamenka

I see Fedora has patched their SDL to make SDL default to native Wayland (which I think is premature, but I'm not a Fedora developer, so it's not up to me)...

As a stepping stone to native support, it might be a good idea for the Steam client to check SDL_VIDEODRIVER and set it to x11 if it's unset?

... so I think it would be a good idea for Steam to do this, as a stopgap until the gameoverlayrenderer has Wayland support.

smcv avatar Jun 09 '22 10:06 smcv

I see Fedora has patched their SDL to make SDL default to native Wayland (which I think is premature, but I'm not a Fedora developer, so it's not up to me)...

From my point of view, it's important so that the Wayland backend is actively used and developers wind up encountering it. Otherwise people will continue to develop their applications in a way where the backend won't work.

Conan-Kudo avatar Jun 09 '22 10:06 Conan-Kudo

Here we are again

revival

Going to try this one more time for SDL 2.28: https://github.com/libsdl-org/SDL/pull/6362

flibitijibibo avatar Oct 11 '22 22:10 flibitijibibo

Has Valve done any work towards this? Wayland seems to be the default for SDL2 now, and since Wayland is especially being preferred by more users this would probably be desired (fractional scaling).

If something is needed to base support for Wayland off of, wouldn't using MangoHUD as an example work? It seems to support native Wayland just fine, more or less. Permissive licensing too (MIT) if that's a concern.

orowith2os avatar Jan 07 '23 20:01 orowith2os

Doesn't seem like MangoHud has Wayland input written either: https://github.com/flightlessmango/MangoHud/blob/11142b5b2cdeb1b83a52d14c1adb567ff2513c31/src/keybinds.h#L58

Presentation works but that's arguably the easy part, since Vulkan layers are a thing and EGL is something that's been overridden before in lots of other places.

flibitijibibo avatar Jan 08 '23 02:01 flibitijibibo

Interesting, I thought it was global keybindings that didn't work. IG I'll have to do a bit more testing with native Wayland applications.

If presentation works, could the keybinds be done via the global shortcuts portal? That seems like the best way to go about it, especially since by design Wayland doesn't like to allow keylogging without permission.

orowith2os avatar Jan 08 '23 17:01 orowith2os

The latest Steam client overhauls the rendered contents of the overlay, but not the overlay itself - still no luck with EGL or Wayland WSI yet!

flibitijibibo avatar Apr 28 '23 15:04 flibitijibibo

The latest Steam client overhauls the rendered contents of the overlay, but not the overlay itself - still no luck with EGL or Wayland WSI yet!

They're using portals for the filechooser on the Beta client, at the very least, so I've got hope. Good to see Valve working towards improving the client.

orowith2os avatar Apr 28 '23 16:04 orowith2os

@kisak-valve @Plagman Any update? Will be support of Steam, Dota 2 of native Wayland? Is there work going on in this direction?

alexeysvrv avatar Oct 04 '23 05:10 alexeysvrv

Any movement on this?

PacketAuditor avatar May 29 '24 22:05 PacketAuditor

... our only blockers are this and NVIDIA finishing their driver support

It's 2024 and Nvidia on Wayland is looking better than ever. Many distros are now beginning to default to Wayland on their chosen DEs / compositors. It's time for Steam to do their end and implement Wayland support for their client and overlay.

I've been testing out and running Counter-Strike 2 with native wayland for quite a while now. This was achieved by editing the game/cs2.sh file in the CS2 game file directory, and changing the SDL_VIDEO_DRIVER line to use Wayland instead. This has worked almost flawlessly for a while now, and other than a few hiccups like crashing on loading screens if you move your mouse, it has worked perfectly. To be honest with you, it's better than running through XWayland. I noticed immediately that frametimes were improved, and even though I was seeing the same / similar FPS, the game just felt so much smoother.

With many native games supporting Wayland, and now Wine (and then proton soon), everything is now moving over to a Native wayland backend. When will we see these roadblocks for the steam client and overlay solved?

fxzzi avatar Jul 11 '24 16:07 fxzzi

You can add Left 4 Dead 2 to this also. I am on CachyOS.

Launch commands

STEAM_COMPAT_RUNTIME_SDL2=1 SDL_VIDEODRIVER=wayland %command% -vulkan

tda0626 avatar Jul 01 '25 01:07 tda0626

Also when you select ' Wayland' as the graphics driver in Factorio in the Graphics settings menu. The Steam in-game overlay is not working. When you switch back to ' x11' it does work again. I assume it is related to this issue.

MaartenBW avatar Jul 04 '25 20:07 MaartenBW

I think it's related to shortcuts on wayland. If you try to use any shortcuts, to display steamoverlay, or other apps like MangoHUD, it does not work. But with X11, all work.

MangoHUD shortcuts work fine for me in CS2 Wayland mode. Steam Overlay does not however.

PacketAuditor avatar Jul 27 '25 21:07 PacketAuditor

I think it's related to shortcuts on wayland. If you try to use any shortcuts, to display steamoverlay, or other apps like MangoHUD, it does not work. But with X11, all work.

If that were the case, the FPS overlay would work anyway, but it doesn't.

Play-InTheWay avatar Jul 28 '25 05:07 Play-InTheWay

Mangohud may not work with OpenGL Wayland games on Steam, for them, at least right now, it additionally requires LD_PRELOAD=""

Damglador avatar Jul 28 '25 09:07 Damglador

You are right, with latest MangoHUD build, it work fine in wayland.

But Steamoverlay not....

joan31 avatar Jul 30 '25 22:07 joan31

Confirming that after the latest CS2 updates, it seems to have broken support for the steam overlay on native wayland for that game specifically, as running the game under the gamescope microcompositor returns the steam overlay functionality. Seems specific to CS2 as other native games like TF2 still work fine.

Tested with KDE Plasma 6.4.3 and gamescope 3.16.2

TheOdd avatar Jul 30 '25 22:07 TheOdd

Confirming that after the latest CS2 updates, it seems to have broken support for the steam overlay on native wayland for that game specifically, as running the game under the gamescope microcompositor returns the steam overlay functionality. Seems specific to CS2 as other native games like TF2 still work fine.

Tested with KDE Plasma 6.4.3 and gamescope 3.16.2

Can you share your launch command with gamescope ?

I tried with gamescope but in my case it launch cs2 with xwayland, so overlay work. But with the expand wayland option, overlay does not work too, like cs2 wayland without gamescope.

joan31 avatar Jul 31 '25 09:07 joan31

I fixed the steam overlay issue temporarily by setting these startup flags for cs2:

SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS=0 SDL_VIDEO_WAYLAND_SCALE_TO_DISPLAY=1 SDL_VIDEO_DRIVER=x11 gamemoderun %command%

Running KDE Plasma 6.4.3 and gamemode 1.8.2-1.1 on CachyOS Linux :) 👍🏼

That's because you set it to XWayland with "SDL_VIDEO_DRIVER=x11"

PacketAuditor avatar Jul 31 '25 12:07 PacketAuditor

I fixed the steam overlay issue temporarily by setting these startup flags for cs2:

SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS=0 SDL_VIDEO_WAYLAND_SCALE_TO_DISPLAY=1 SDL_VIDEO_DRIVER=x11 gamemoderun %command%

Running KDE Plasma 6.4.3 and gamemode 1.8.2-1.1 on CachyOS Linux :) 👍🏼

This might get the overlay running; however, that is beside the point of this issue. The issue is, that the overlay doesn't work on wayland, where as your method forces the use of x11/xwayland.

As I understand it, the overlay (just like the Steam client itself) is based on fundamentally incompatible software and will have to be manually ported to wayland or maybe even entirely rewritten.

QuantenToast avatar Jul 31 '25 12:07 QuantenToast

Did this get fixed in latest cs2 update? Overlay seems to work again, and I'm using wayland.

nicxz avatar Jul 31 '25 18:07 nicxz

from cs2.sh:

# There is Wayland support in SDL but a recent (7/30/2025) attempt at
# allowing SDL to default to Wayland caused a number of customer issues so
# keep the default at X11 for now. Don't override any user setting so
# people can easily use Wayland if they want.
if [ "$UNAME" == "Linux" ]; then
    if [ -z "$SDL_VIDEO_DRIVER" ]; then
        export SDL_VIDEO_DRIVER=x11
    fi
fi

The game defaults to x11/Xwayland again. You can run it with SDL_VIDEO_DRIVER=wayland %command% to use wayland.

NyCodeGHG avatar Jul 31 '25 19:07 NyCodeGHG

@NyCodeGHG

Replying to https://github.com/ValveSoftware/steam-for-linux/issues/8020#issuecomment-3141060558

As an aside, this explains the behavior of Gamescope.

In my case, I initialize the SDL_VIDEO_DRIVER=wayland environment variable via the Hyprland configuration file :

env = SDL_VIDEO_DRIVER,wayland

The bahavior, is the same as an export SDL_VIDEO_DRIVER=wayland for all system.

So, the game launches in its Wayland version every time with the overlay problem mentioned here.

However, in Gamescope, it does not inherit the environment variable. Therefore, according to the cs2.sh script, it will be defined in X11 and thus systematically start on xwayland (unless this same script is modified).

This confirms the observation made in this comment :

@TheOdd

Confirming that after the latest CS2 updates, it seems to have broken support for the steam overlay on native wayland for that game specifically, as running the game under the gamescope microcompositor returns the steam overlay functionality. Seems specific to CS2 as other native games like TF2 still work fine.

Tested with KDE Plasma 6.4.3 and gamescope 3.16.2

joan31 avatar Aug 01 '25 09:08 joan31

Did this get fixed in latest cs2 update? Overlay seems to work again, and I'm using wayland.

It is not fixed and will not work until Valve fixes it. You cannot fix this on your own because it is a problem with the Steam Overlay program itself so no amount of modifying files or adding launch parameters will work.

tda0626 avatar Aug 01 '25 12:08 tda0626