ValveSoftware / gamescope

SteamOS session compositing window manager
Other
3.17k stars 213 forks source link

Stutters of 60 ms when a keyboard input is made after a prolonged game session #1292

Open troy0h opened 6 months ago

troy0h commented 6 months ago

image Any game I run with gamescope, after about an hour, the game will start to have large frametime spikes. These frametime spikes happen every time a keyboard input is made (both pressing and releasing a key), and are up to 60 ms. This makes games pretty much unplayable. I've had this in Team Fortress 2, Lethal Company and Helldivers 2.

kisak-valve commented 6 months ago

Hello @troy0h, this reads similarly to https://github.com/ValveSoftware/csgo-osx-linux/issues/2901 / https://github.com/ValveSoftware/Source-1-Games/issues/5767. Do you happen to have the Steam overlay disabled, and if that's true, does enabling it have an effect?

MGThePro commented 6 months ago

I've been experiencing the same issue in cs2. The issue happened only after switching to using gamescope, so I don't think it has anything to do with the game (but I can't 100% rule it out)

I have the steam overlay enabled, but I can't open it so not sure if that could affect it

troy0h commented 6 months ago

Hello @troy0h, this reads similarly to ValveSoftware/csgo-osx-linux#2901 / ValveSoftware/Source-1-Games#5767. Do you happen to have the Steam overlay disabled, and if that's true, does enabling it have an effect?

Hi, I can't even seem to get the steam overlay working in game, I add the -e flag, but it doesn't make shift - tab work in games My lethal company launch options are gamescope -f -w 2560 -h 1440 -- gamemoderun mangohud %command% My helldivers 2 launch options are gamescope -f -r 165 -w 2560 -h 1440 -e -- gamemoderun mangohud %command% --use-d3d11 both have the same issue, even though only Helldivers 2 actually has -e to enable Steam integration, while Lethal Company doesn't

sharkautarch commented 6 months ago

If you don’t have steam overlay disabled in steam’s options for that game, it could still have an effect on gamescope’s performance, even if you are unable to bring up the overlay w/ shift + tab. This is because steam overlay is a dynamic library loaded w/ LD_PRELOAD. Due to how LD_PRELOAD and environment variables work, this may mean that steam overlay may try to load itself into gamescope…

sharkautarch commented 6 months ago

Tho it is definitely possible there’s some weird issue happening in gamescope itself. I’m planning on hooking up Tracy profiler into gamescope, which would hopefully reveal the exact source of these sudden slowdowns. Especially since I’ve seen other unique & specific situations where gamescope will stutter for unclear reasons

troy0h commented 6 months ago

If you don’t have steam overlay disabled in steam’s options for that game, it could still have an effect on gamescope’s performance, even if you are unable to bring up the overlay w/ shift + tab. This is because steam overlay is a dynamic library loaded w/ LD_PRELOAD. Due to how LD_PRELOAD and environment variables work, this may mean that steam overlay may try to load itself into gamescope…

I've experienced it happening with or without the steam overlay, it doesnt make a difference (at least for me)

JimBimBum commented 6 months ago

this doesn't seem to be a gamescope or wayland issue, i use x11 and have this issue only with TF2 only with vulkan enabled. seems fine on opengl or i can't tell. only pattern i've found is around 2.5 GBs of ram used tf2 starts doing that. it is clearly has something to do with input but idk what or why.

first joined, no stutters image now stutters image image

JimBimBum commented 6 months ago

maybe an sdl3 issue?

BigBrotherLovesYou commented 6 months ago

Also suffering from this, both Wayland and X11 sessions. KDE 6.0.4.1 (so with the fix referenced in) kernel 6.9.1 Arch Linux, latest mesa-tkg-git

misyltoad commented 6 months ago

Please try adding LD_PRELOAD="" before launching Gamescope

JimBimBum commented 6 months ago

just turning on steam overlay fixes this for me but idk about you though.

lsr1006 commented 3 months ago

image I have also experienced this issue, happening on both steam and non-steam games (Arch, Hyprland, 7900XT). Screenshot above is from May (Black Ops 4 - battle.net on Bottles) but I didn't know gamescope was causing the issue until today when it happened again in "Chained Together" on Steam, only when using gamescope. Same scenario as OP - happens after 60-90 ish minutes of play and is for every keyboard input, otherwise is perfectly smooth. I can try using LD_PRELOAD with the launch option next time to see if it helps.

sharkautarch commented 3 months ago

@lsr1006 yeah try the LD_PRELOAD="" thing If it doesn’t fix the issue, I could give you some instructions for profiling gamescope to get insight into what’s causing the problem…

Tho it’d probably be a good idea to first try installing gamescope-git from the aur, to double check that the issue persists in the latest commit.

for profiling, gamescope has support for gpuvis, but there’s also another profiler that I’ve been working on hooking up: Tracy profiler. I’m thinking that Tracy profiler may work better for this case… I’ll give you more info later if you continue to have this issue and you’re up to chasing this weird performance bug…

lsr1006 commented 3 months ago

@sharkautarch LD_PRELOAD="" does seem to resolve the issue for me, at least in the one game I tried. Issue did not present after 2+ hrs of time in game.

JustPlainGarak commented 3 weeks ago

I put together a workaround that both prevents the frame time issue AND gets the Steam Overlay working.

LD_PRELOAD="" gamescope --steam -- env LD_PRELOAD="$HOME/.local/share/Steam/ubuntu12_64/gameoverlayrenderer.so" %command%

All this does is, as the original workaround does, cancel out LD_PRELOAD for gamescope, but then INSTEAD pass the overlay library via LD_PRELOAD to the command inside gamescope. So far, this has worked perfectly in my testing. No unplayable frame time glitches and the Steam Overlay injects and works normally.