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

CS2: Severe stutter with Wayland (vkWaitForFences VK_TIMEOUT)

Open an0nfunc opened this issue 2 years ago • 30 comments

Your system information

Please describe your issue in as much detail as possible:

Stutter under Wayland (sway) + AMDGPU. This does not happen with X11 (i3).

As soon as the game runs a few seconds, there are severe stutters down to 1 fps every few seconds. Seems to be getting more frequent if the game runs for a while.

Log messages that seem to relate to this issue:

CSwapChainBase::QueuePresentAndWait() looped for 21 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 1 ) after 0.255553 seconds, error = VK_TIMEOUT
CSwapChainBase::QueuePresentAndWait() looped for 22 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 2 ) after 0.252701 seconds, error = VK_TIMEOUT
CSwapChainBase::QueuePresentAndWait() looped for 21 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 1 ) after 0.252569 seconds, error = VK_TIMEOUT
CSwapChainBase::QueuePresentAndWait() looped for 22 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 2 ) after 0.252716 seconds, error = VK_TIMEOUT
CSwapChainBase::QueuePresentAndWait() looped for 21 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 1 ) after 0.255026 seconds, error = VK_TIMEOUT
CSwapChainBase::QueuePresentAndWait() looped for 22 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 2 ) after 0.257787 seconds, error = VK_TIMEOUT
CSwapChainBase::QueuePresentAndWait() looped for 21 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 1 ) after 0.256348 seconds, error = VK_TIMEOUT
CSwapChainBase::QueuePresentAndWait() looped for 22 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 2 ) after 0.251057 seconds, error = VK_TIMEOUT

Steps for reproducing this issue:

  1. Run CS2 under Wayland + AMD GPU

an0nfunc avatar Sep 27 '23 23:09 an0nfunc

Try the -nojoy launch parameter

alou-S avatar Sep 27 '23 23:09 alou-S

In CSGO, adding LD_PRELOAD="/usr/lib64/libSDL2-2.0.so.0" SDL_VIDEODRIVER=wayland as a launch option to force it to run as a wayland window fixed all stutters/jitters on my end (In the past for CSGO, not CS2). Could be a XWayland issue?

ErikReider avatar Sep 27 '23 23:09 ErikReider

Try the -nojoy launch parameter

I have that one already.

In CSGO, adding LD_PRELOAD="/usr/lib64/libSDL2-2.0.so.0" SDL_VIDEODRIVER=wayland as a launch option to force it to run as a wayland window fixed all stutters/jitters on my end. Could be a XWayland issue?

I'll try this, give me a second.

EDIT: As noted by @alou-S, this does not work.

an0nfunc avatar Sep 27 '23 23:09 an0nfunc

In CSGO, adding LD_PRELOAD="/usr/lib64/libSDL2-2.0.so.0" SDL_VIDEODRIVER=wayland as a launch option to force it to run as a wayland window fixed all stutters/jitters on my end. Could be a XWayland issue?

CS2 and Source 2 uses SDL3 this won't work.

@an0nfunc Could you give the replies for glxinfo -B

alou-S avatar Sep 27 '23 23:09 alou-S

@alou-S glxinfo -B: https://gist.github.com/an0nfunc/5d77bbb5b37d929b52855e45619282e0

an0nfunc avatar Sep 27 '23 23:09 an0nfunc

@an0nfunc Do you have a separate dedicated GPU or CS2 run on the iGPU?

alou-S avatar Sep 27 '23 23:09 alou-S

In CSGO, adding LD_PRELOAD="/usr/lib64/libSDL2-2.0.so.0" SDL_VIDEODRIVER=wayland as a launch option to force it to run as a wayland window fixed all stutters/jitters on my end. Could be a XWayland issue?

CS2 and Source 2 uses SDL3 this won't work.

@an0nfunc Could you give the replies for glxinfo -B

I wrote "in CSGO"... Anyways, maybe there's something similar for sdl3?

ErikReider avatar Sep 27 '23 23:09 ErikReider

@an0nfunc Do you have a separate dedicated GPU or CS2 run on the iGPU?

As you can see in my sys info, the 3800X does not posses an igp.

an0nfunc avatar Sep 27 '23 23:09 an0nfunc

Erm my bad so you use a Vega 10 GPU ehehe. Pardon my ignorance. I'll try debugging directly on sway, I don't seem to have any issues on Kwin Wayland (KDE) with the latest mesa-git drivers.

alou-S avatar Sep 27 '23 23:09 alou-S

Erm my bad so you use a Vega 10 GPU ehehe. Pardon my ignorance. I'll try debugging directly on sway, I don't seem to have any issues on Kwin Wayland (KDE) with the latest mesa-git drivers.

Should I try mesa-git?

edit: Give me a sec, compiling...

an0nfunc avatar Sep 27 '23 23:09 an0nfunc

You could attempt, If you are using Arch derivative distros you can get mesa-tkg-git straight from Chaotic AUR. Its pre-compiled.

alou-S avatar Sep 27 '23 23:09 alou-S

Mesa is compiled quickly enough, just takes a few minutes. I'll report back.

EDIT: Still happens on mesa 23.3.0_devel.178293.65afc8bebf4.d41d8cd-1.

an0nfunc avatar Sep 27 '23 23:09 an0nfunc

Try disable Steam Overlay. Used to fix a similar issue when using dxvk on CS:GO

alou-S avatar Sep 28 '23 00:09 alou-S

Also happens with Steam Overlay disabled. I noticed it's much more intense after visiting advanced video options once. (unrelated to the overlay, just an observation)

an0nfunc avatar Sep 28 '23 00:09 an0nfunc

Try FSR Ultra Quality, it fixed stuttering for me and others.

Cruleo avatar Sep 28 '23 00:09 Cruleo

I'm on Debian SId + mesa experimental + KDE + Wayland, game is running smooth as butter. All stock settings. 5600X + 6900 XT.

bunkbail avatar Sep 28 '23 02:09 bunkbail

Just noticed that these stutters correspond with log messages in the ingame-console. Must have been tired yesterday to not notice.

CSwapChainBase::QueuePresentAndWait() looped for 21 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 1 ) after 0.255553 seconds, error = VK_TIMEOUT
CSwapChainBase::QueuePresentAndWait() looped for 22 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 2 ) after 0.252701 seconds, error = VK_TIMEOUT
CSwapChainBase::QueuePresentAndWait() looped for 21 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 1 ) after 0.252569 seconds, error = VK_TIMEOUT
CSwapChainBase::QueuePresentAndWait() looped for 22 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 2 ) after 0.252716 seconds, error = VK_TIMEOUT
CSwapChainBase::QueuePresentAndWait() looped for 21 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 1 ) after 0.255026 seconds, error = VK_TIMEOUT
CSwapChainBase::QueuePresentAndWait() looped for 22 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 2 ) after 0.257787 seconds, error = VK_TIMEOUT
CSwapChainBase::QueuePresentAndWait() looped for 21 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 1 ) after 0.256348 seconds, error = VK_TIMEOUT
CSwapChainBase::QueuePresentAndWait() looped for 22 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 2 ) after 0.251057 seconds, error = VK_TIMEOUT

an0nfunc avatar Sep 28 '23 11:09 an0nfunc

I cannot reproduce this under sway with a 5700xt. no stutter or vulkan related error messages.

sand-r avatar Sep 28 '23 17:09 sand-r

As I commented here: https://github.com/ValveSoftware/csgo-osx-linux/issues/3307#issuecomment-1739680927

For me lowering the graphics and disabling MSAA and FSR worked. Especially MSAA. I'm using Fedora Linux with AMD Mesa drivers.

Reduced stutter so much.

leotada avatar Sep 28 '23 18:09 leotada

Downgrading to mesa 23.0.3 seems to fix this. Not sure if the problem is on mesa or CS2's side.

EDIT: I'm currently bisecting mesa to find out what commit we are dealing with.

an0nfunc avatar Sep 28 '23 20:09 an0nfunc

Upstream mesa issue: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9902

an0nfunc avatar Sep 28 '23 23:09 an0nfunc

I am consistently having 60 fps in cs2, but not on Xorg. Is it related?

EysseW avatar Oct 11 '23 17:10 EysseW

For a simpler solution than switching to Xorg, running steam and CS2 in fullscreen gamescope gives a much higher consistent framerate (on KDE Wayland).

melvyn2 avatar Oct 17 '23 06:10 melvyn2

For a simpler solution than switching to Xorg, running steam and CS2 in fullscreen gamescope gives a much higher consistent framerate (on KDE Wayland).

Swag thanks for sharing

HurricanePootis avatar Oct 19 '23 02:10 HurricanePootis

This seems to be gone for me on linux lts (6.1.61).

ico277 avatar Nov 06 '23 01:11 ico277

This seems to be gone for me on linux lts (6.1.61).

I just tried this on 6.1 because Xorg was crashing and the stutter is still there and my GPU is maxed out. No clue what's going on there.


CS2 Choppy on Wayland / Stutters

Issue transferred from https://github.com/ValveSoftware/csgo-osx-linux/issues/3542. @sparkie3 posted on 2023-11-07T15:51:58:

Your system information

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

Please describe your issue in as much detail as possible:

CS2 is very choppy on Wayland. It is similar to have the GPU on low power settings when playing, however I have manually set the power profile to the highest and verified via nvtop that the GPU power settings are at the highest level while playing. The game will smooth out if vsync is disabled, but the filtering also makes the game unplayable. I've tried multiple kernels, and tried 6.1 as another bug report suggested. The game is unplayable as it sits due to the choppy rendering.

Here is the console output: https://gist.github.com/sparkie3/99d49fb4ec49d4cfe53d10dd3b42f914

sparkie3 avatar Nov 07 '23 15:11 sparkie3

Gamescope helps a bit, until it enters a state that is even worse and unplayable. X11 is perfectly smooth.

For me it correlates with package loss / choke. It starts smoothish and stutters once there are network imperfections. After some time it recovers a little, but it keeps being stuttery. I don't know if it's caused by it, or vice verse.. or at all connected.

Root-Core avatar Nov 08 '23 00:11 Root-Core

Using a higher refresh rate monitor and freesync helps with this. There are still stutters but not quite as bad. I'm using the 6.7 dev kernels.

sparkie3 avatar Nov 29 '23 16:11 sparkie3

For me personally it worked fine during October/November and then at some point in December it started stuttering and was unable to keep up stable FPS. GPU usage was ~70% and CPU usage much lower than that.

Today Steam downloaded shader cache and then did some shader compilation, and now again it works fine without any stuttering and having stable FPS.

FPS on Linux seems lower than on Windows 10 but then again I have to play with variable refresh rate to not have forced v-sync, so I am limiting to 140fps anyway, which also allows to set everything on recommended high settings (1440p, 4x MSAA, high, high, 4x anisotropic filtering, FSR off). Without limiting FPS I get 200+ FPS on de_dust2. I also tried it on xorg and I get similar FPS there.

So having tried out different mesa and xwayland versions I concluded that it probably had something to do with shader cache and not mesa/xwayland itself.

Running CS2 on: Arch Linux, currently kernel v6.6.9, Ryzen 7 5800X, Radeon RX 6800 XT, Gnome Wayland with mutter VRR patches.

Playing with VRR at 140FPS feels good on Linux, was able to rank up and play at purple ranks without issues. I hope the performance doesn't degrade again any time soon. And looking forward to getting native wayland support for CS2 without xwayland.

Janhouse avatar Jan 05 '24 22:01 Janhouse

The upstream mesa issue was resolved, so I think this can be closed?

an0nfunc avatar May 09 '24 19:05 an0nfunc