csgo-osx-linux icon indicating copy to clipboard operation
csgo-osx-linux copied to clipboard

Wayland support (GNU/Linux)

Open DmitryHetman opened this issue 7 years ago • 33 comments

Your system information

Gentoo GNU/Linux nomultilib, Weston (uses Wayland Display Server Protocol), no xwayland.

  • System information from steam (Steam -> Help -> System Information) in a gist:
  • Have you checked for system updates?: [Yes/No] Yes

Please describe your issue in as much detail as possible:

Describe what you expected should happen and what did happen. Please link any large pastes as a Github Gist. Not able to launch cs:go or steam.

Steps for reproducing this issue:

  1. Install any distro and any Wayland compositor
  2. Install Steam
  3. Try to launch steam or any game with Source engine Wayland support is very important, wayland gives opportunity to not use user-space driver, improves performance significantly, saves energy.

DmitryHetman avatar Jul 08 '17 14:07 DmitryHetman

https://wayland.freedesktop.org/ https://en.wikipedia.org/wiki/Wayland_(display_server_protocol) https://jan.newmarch.name/Wayland/ProgrammingClient/

DmitryHetman avatar Jul 08 '17 14:07 DmitryHetman

Yea +1 for Wayland support pls add mr. lead csgo-linux-dev kisak-volvo.

I thought Steam OS is also using Gnome which is supporting Wayland, so give this high priority

mellowagain avatar Jul 09 '17 21:07 mellowagain

Doesn't CS:GO use SDL on Linux? SDL's support for Wayland is still in early experimental stages, it's probably best just to use XWayland for now.

roge avatar Jul 14 '17 01:07 roge

With XWayland I have poor result. High FPS (140+fps@1440p) but input have issue : huge lag input like 15-20 FPS. I read somewhere XWayland fullscreen in gnome is not unredirected.

I use fedora 26 and I relog on Xorg for CSGO.

ghost avatar Sep 02 '17 18:09 ghost

If CS:GO uses sdl2 then all valve has to do is update the sdl library that they provide with steam. However I think it's not easy for the steam client itself to support wayland unless they're fine with using native desktop notifications for their "is now playing" or "x sent you a message" notifications, and it probably won't support inhome streaming to another machine either

SethDusek avatar Oct 26 '17 17:10 SethDusek

Wayland support needed +1, XWayland hurts performent a lot, how long will it take for sdl support wayland?

AlynxZhou avatar Nov 22 '17 11:11 AlynxZhou

When launching CSGO with SDL_VIDEODRIVER=wayland, a popup gives me an SDL error message: SDL_Init(SDL_INIT_VIDEO) failed: wayland not available.

Given that SDL2 has support for Wayland, I assume the SDL version used for CSGO is outdated. Wouldn't updating it fix this issue? I understand this might not be as simple because it could introduce new bugs, but Wayland is becoming the default display system on Linux, and XWayland really isn't appropriate for fast-paced games.

tdaniel22 avatar Aug 29 '18 16:08 tdaniel22

You can get native-Wayland support by preloading CSGO with a newer version of SDL2 that was compiled with Wayland support, running Steam w/ native libraries, and using SDL_VIDEODRIVER=wayland.

However, even then, the performance isn't up to par with the Xorg version. Actually, based on my testing, it's even worse than running it with XWayland. There are some graphical bugs and a lot of FPS drops. I've tested this with sway 1.0.

bool3max avatar Mar 13 '19 21:03 bool3max

I can confirm LD_PRELOAD for libsdl2 and the SDL_VIDEODRIVER wayland method works for dota2.

I can't get it to work for CSGO.

I don't use arch - are there any other libraries that need to be preloaded for csgo to run under wayland?

SimplyCorbett avatar Nov 17 '20 15:11 SimplyCorbett

Xwayland introduces a noticable input lag on mutter (GNOMEs wm) which can be fixed when running the game with an SDL version that supports wayland. Is an SDL update planned/possible in the near future?

Mershl avatar Jan 01 '21 20:01 Mershl

Thank you very much for updating the SDL library with todays/yesterdays update. The updated library does unfortunatly not have Wayland support enabled. When trying to start using SDL_VIDEODRIVER=wayland the error SDL_Init(SDL_INIT_VIDEO) failed: wayland not available is shown on Fedora 33.

Mershl avatar Jan 21 '21 19:01 Mershl

Does "starting with SDL_VIDEODRIVER=wayland" mean in the launch options? ~~I tried that and got pretty good performance on Pop OS~~.

Edit: Nope, did it the right way: SDL_VIDEODRIVER=wayland %command%(and then -nojoy) and got the same error. Was I too using XWayland? Is there a way to check that in-game?

7RST1 avatar Jan 27 '21 13:01 7RST1

I don't think you can check from ingame, however if you run "~xinfo~ xprop" in the terminal, and hover over the CSGO window, if the cursor changes then it implies it's an Xwayland window. If it doesn't then it's Wayland.

SethDusek avatar Jan 28 '21 11:01 SethDusek

I don't think you can check from ingame, however if you run "~xinfo~ xprop" in the terminal, and hover over the CSGO window, if the cursor changes then it implies it's an Xwayland window. If it doesn't then it's Wayland.

A simple alternative: xlsclients

AlynxZhou avatar Jan 28 '21 15:01 AlynxZhou

If you're on GNOME 3 you can use looking glass to check if a window is using XWayland or Wayland.

Press ALT+F2 for the GNOME command prompt. Type "lg". Select "windows" on the top right. A list of your currently open windows is shown. Selecting a window will expose their parent object (first line of the display). "MetaWindowWayland" is a Wayland native window. "MetaWindowXwayland" is passed through Xwayland.

Mershl avatar Jan 28 '21 17:01 Mershl

I recently tried running CS-GO native with wayland too, but it isn't working currently. I'm using Archlinux with sway. There was a guide, but it's currently not working. There is a Segfault:

/mnt/ssdlinux/SteamLibrary/steamapps/common/Counter-Strike Global Offensive/csgo.sh: line 88: 67918 Segmentation fault      (core dumped) ${DEBUGGER} "${GAMEROOT}"/${GAMEEXE} "$@"

To get SDL using wayland, I added SDL_VIDEODRIVER=wayland", but since the bundled SDL-Lib doesn't support wayland and you get SDL_Init(SDL_INIT_VIDEO) failed: wayland not available (as @Mershl already mentioned). To circumvent using the old SDL-Lib you can add LD_PRELOAD="/usr/lib/libSDL2-2.0.so:/usr/lib32/libSDL2-2.0.so", but this results in a Segfault...

I would really appreciate it, if Valve would try to get the game working with current SDL-Librarys too.

Another tip for testing, if a window is in wayland: You can start xeyes and the eyes will only be able to follow your cursor in Xorg-windows.

UltimateNyn avatar Jun 08 '21 21:06 UltimateNyn

I would really appreciate it, if Valve would try to get the game working with current SDL-Librarys too.

Xwayland shows major regressions for CS:GO. As of today it is not possible to set the brightness of Xwayland windows (the gamma slider in CS:GO has no effect) and the game has a serious input bug where frames are dropped on mouse input (this is only shown on Xwayland and does not affect Xorg and we assume native Wayland). The later bug is crucial and renders the game on Xwayland unplayable. It has now been hunted for more than 7 months (https://gitlab.gnome.org/GNOME/mutter/-/issues/1455#note_1121504) and there's no solution from Xwayland side.

Considering that KDE and Nvidia have recently been pushing Wayland this will trigger more and more distros to enable Wayland by default. Steam users will then run into this issue and have to enable a Legacy Desktop Mode (if available) to play CS:GO.

I can only again ask Valve to update the SDL lib to support Wayland and especially the later mentioned issue would be solved in an instant.

EDIT: Can a KDE wayland user confirm the input issue also affects KWin's implementation?

Mershl avatar Jul 01 '21 15:07 Mershl

It would be nice to have updated SDL libraries so it can run on wayland.

I'm curious on how the big push into wayland is going to affect proton and native games. Will valve adopt the WIP wayland wine version over at https://github.com/varmd/wine-wayland for proton? But now I'm going off topic. :)

SimplyCorbett avatar Jul 04 '21 00:07 SimplyCorbett

@Plagman confirmed that the Steam Deck will use Wayland for games (https://twitter.com/Plagman2/status/1418701862484594691) by utilizing gamescope ... so maybe there is a chance that CS:GO finally gets an updated SDL version.

tfaller avatar Jul 25 '21 14:07 tfaller

I hope so Manjaro recently switched to wayland as far as i can tell. Many major distributions have already switched and it is really a suboptimal experience for newcomers out of the box.

MordragT avatar Jul 30 '21 12:07 MordragT

csgo for wayland works pretty well, however the following are required.

  1. Prepare a strstr.so library - when using wayland at some point strstr() is called with one argument as type-casted -1 or so. This rightfully crashes the glibc's implementation, but we need to patch it
$ cat strstr.c 
#define _GNU_SOURCE
#include <string.h>
#include <dlfcn.h>
#include <stdint.h>
#include <inttypes.h>

char *strstr(const char *haystack, const char *needle) {
	if ((uintptr_t)haystack > (uintptr_t)0xFFFFFFFF00000000) {
		return NULL;
	}

	char* (*p)(const char *haystack, const char *needle) = dlsym(RTLD_NEXT, "strstr");
	return p(haystack, needle);
}
$ gcc -shared -o strstr.so strstr.c
  1. Run with your own libSDL
SDL_VIDEODRIVER=wayland LD_PRELOAD=<path_to>/strstr.so:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.14.0 steam

Voila!

robertswiecki avatar Aug 12 '21 21:08 robertswiecki

@robertswiecki ~~your workaround doesn't work for me. csgo just fails to start without error message.~~

nvm it's working :)

jakobkukla avatar Aug 18 '21 02:08 jakobkukla

I tried your solution, but the game won't start. It opens as a black window for ca. 10 seconds before closing.

I tried both with and without specifying a libsdl2 in lib32, didn't really make a difference. The log is with lib32/libSDL2 specified and using SDL_VIDEODRIVER=wayland LD_PRELOAD=/home/syvers/libstrstr/strstr.so:/usr/lib/libSDL2-2.0.so:/usr/lib32/libSDL2-2.0.so steam and SDL_VIDEODRIVER=wayland %command%

steamCSGO.log

EDIT: "Segmentation fault" in logs took me to #2651, but it has no concrete solution. Are anyone else having the same issue with this patch?

7RST1 avatar Oct 01 '21 19:10 7RST1

Yeah, it's crashing for me too now. It's crashing in some process exit procedure, so it's maybe not that relevant. What is problematic is that the new reason for the csgo_linux64 process exiting:

SDL_Init(SDL_INIT_VIDEO) failed: No available video device

So, maybe it's something with new SDL, or maybe csgo linux devs changed something. I'll give it a try, and do some shallow debugging, though I was hoping that with the Steam Deck coming, the devs would make it work better under wayland.

PS: It started working again after I installed supertux for SDL/wayland testing. Of course, supertux itself doesn't help here, but IIRC it also forced libSDL-image to be installed, so maybe that's it.

robertswiecki avatar Oct 04 '21 07:10 robertswiecki

I fixed it with this fix posted in another issue, so it seems that the fact it didn't start wasn't relevant to this issue.

None the less, seems like CS:GO works very well now, running on Wayland.

7RST1 avatar Oct 06 '21 18:10 7RST1

I'm using Manjaro Linux with KDE Plasma and Wayland - all packages updated My setup for reference:

System:    Host: crumbly-pc Kernel: 5.15.2-2-MANJARO x86_64 bits: 64 Desktop: KDE Plasma 5.23.3 Distro: Manjaro Linux
CPU:       Info: 6-Core model: AMD Ryzen 5 5600G with Radeon Graphics bits: 64 type: MT MCP cache: L2: 3 MiB
           Speed: 2729 MHz min/max: 1400/3900 MHz Core speeds (MHz): 1: 2729 2: 2501 3: 2404 4: 1978 5: 2686 6: 2449 7: 2147
           8: 1875 9: 2551 10: 2298 11: 2536 12: 2778
Graphics:  Device-1: Advanced Micro Devices [AMD/ATI] Cezanne driver: amdgpu v: kernel
           Display: wayland server: X.Org 1.21.1.3 driver: loaded: amdgpu,ati unloaded: modesetting resolution: 2560x1440~60Hz
           OpenGL: renderer: AMD RENOIR (DRM 3.42.0 5.15.2-2-MANJARO LLVM 13.0.0) v: 4.6 Mesa 21.2.5

I went through the following steps:

  1. Install the sdl2 package (sdl2 2.0.16-4)
  2. Compile the patch for strstr as shown here
  3. Rename the videos/ folder to videos.bak in /home/$HOME/.steam/steam/steamapps/common/Counter-Strike Global Offensive/csgo/panorama following this comment
  4. Run steam-native with env LD_PRELOAD="$HOME/Games/Steam/CounterStrike/strstr/strstr.so:/usr/lib/libSDL2-2.0.so.0.16.0:/usr/lib32/libSDL2-2.0.so.0.16.0" SDL_VIDEODRIVER=wayland steam-native
  5. Run CS:GO through Steam with these launch options: SDL_VIDEODRIVER=wayland %command% -novid -nojoy +exec autoexec.cfg

Now this get's the game running but it's not really playable. Even though net_graph 1 shows 80-100 FPS it looks more like 50, console is unusable (you can copy, paste and delete but you can't write into the console - when I'm in game it uses a different cursor so there might be a link here?), alt-tabbing works but is really funky (sometimes the window is partly out of my screen, sometimes it's really small, ...) and also colours look weird but I can tweak my monitor settings so that's not that big of a problem.

Do you guys have any ideas as to what I might be doing wrong?

CrumblyLiquid avatar Nov 23 '21 16:11 CrumblyLiquid

The Wayland fix used to work for a while, but now I get jagged* mouse movement with Raw Input activated micro-jolting my view back and fourth. Has anyone encountered this issue and know how to fix it?

Edit: Seems like the view fails to follow mouse sometimes. It's very apparent when moving the mouse slowly, as the view won't pan at all, as seen at the start of the video below.

https://user-images.githubusercontent.com/16783057/175095747-3668acf6-1441-41c8-ba1e-9cb13114420e.mp4

7RST1 avatar Jun 21 '22 19:06 7RST1

@7RST1 No issues for me on Plasma 5.25.1 (KWin) (latest packages, 5.18.5-arch1-1). What compositor are you running? Note: I'm running CS:GO with these launch options: %command% -vulkan -novid

CrumblyLiquid avatar Jun 22 '22 18:06 CrumblyLiquid

No issues for me on Plasma 5.25.1 (KWin) (latest packages, 5.18.5-arch1-1). What compositor are you running? Note: I'm running CS:GO with these launch options: %command% -vulkan -novid

@CrumblyLiquid Normally I use SDL_VIDEODRIVER=wayland gamemoderun %command% -vulkan -novid -nojoy +fps_max 0 -refresh 144, but it also happens after reducing it to SDL_VIDEODRIVER=wayland %command% -vulkan -novid. I'm using Gnome on Manjaro with mutter v42.2-1

EDIT: Just tried on another computer with Nvidia graphics instead of my previous AMD system. Seems like common denominator is only Manjaro Gnome (unstable). Is it anyone who specifically has Manjaro Gnome on any branch, who can confirm this issue?

7RST1 avatar Jun 22 '22 18:06 7RST1

The Wayland fix used to work for a while, but now I get jagged* mouse movement with Raw Input activated micro-jolting my view back and fourth. Has anyone encountered this issue and know how to fix it?

@7RST1 I have the same issue when using the Wayland fix on Plasma 5.25.2 (KWin). Seems that performance is better, but mouse jagging makes it unplayable. I'm using arch (5.18.9-arch1-1) with AMD Vega.

@CrumblyLiquid using %command% -vulkan -novid and not SDL_VIDEODRIVER=wayland %command% -vulkan -novid runs csgo on XWayland and not Wayland, so could you please try it on Wayland and repport if you face the same issue?

hasoart avatar Jul 11 '22 13:07 hasoart