ValveSoftware / gamescope

SteamOS session compositing window manager
Other
3.13k stars 211 forks source link

After 25-30 minutes of gameplay, Battlefield 1 stutters like crazy #697

Open tralph3 opened 1 year ago

tralph3 commented 1 year ago

This is an odd one. For some reason, title happens. Up until that point, the game runs flawlessly, constant 60 FPS, no drops, no stutters, nothing. It's buttery smooth.

But CONSISTENTLY after about 25-30 minutes, it stutters, and it never goes away. This only happens when I'm using gamescope. If I don't use it, I can play multiple hours without a hitch.

I haven't encountered this issue on any other game, not even on its predecessor, Battlefield 4. It only happens in Battlefield 1 (I don't own the successors, I'm unaware if this is an issue in BF 5 or 2042).

This issue is not related to ping either. I don't have high ping, and it persists into the campaign and even menus.

System info:

Super detailed system info.

Here's a video showcasing the issue. I'm sorry for the compression, GitHub has a 10MB upload limit, but you can appreciate how choppy it is. That's not the framerate, that's this weird stuttering that makes the game unplayable. It's clearly noticeable when I stop and just move my mouse around.

https://user-images.githubusercontent.com/41462117/205507506-1af47898-d442-42c3-8e1f-687c5aee5cda.mp4

Sporknife commented 1 year ago

Same problem here with total war warhammer 2.

Operating System: Arch Linux KDE Plasma Version: 5.26.4 KDE Frameworks Version: 5.100.0 Qt Version: 5.15.7 Kernel Version: 6.0.11-zen1-1-zen (64-bit) Graphics Platform: Wayland Processors: 12 × Intel® Core™ i7-8700 CPU @ 3.20GHz Memory: 15,5 GiB of RAM Graphics Processor: AMD Radeon RX 480 Graphics

CartoonFan commented 1 year ago

Could this be related to #163? That issue's not Fedora or KDE-specific anymore.

cyberphantom52 commented 1 year ago

can you try doing sudo setcap 'cap_sys_nice=eip' /usr/bin/gamescope

Sporknife commented 1 year ago

Just tried running a game again, and now I get freeze every 1-3 seconds (this is without the command, unless it is persistent through a reboot).

Sporknife commented 1 year ago

For some reason, I can't reproduce this with a native game (in this case, Drag).

tralph3 commented 1 year ago

Oh, sorry. I forgot to update this. The command @cyberphantom52 provided actually worked wonders. I can play indefinitely now without issues.

Although, I'm hesitant to close the issue, since something is causing it in the first place, and I'd wager that should be fixed.

Sporknife commented 1 year ago

I now have a similar issue where the game starts to have fps drops every second. I noticed that with total war warhammer 2 it starts after a video thumbnail is loaded in the launcher and stops when I start a campaign (when I start playing the game).

Sporknife commented 1 year ago

Now I am having the same issue as @tralph3 encountered. The command did not help.

envyniv commented 1 year ago

Same thing happening here - Using Steam (and gamescope by extension) through flatpak; the games i've noticed this happening on are Team Fortress 2 (native) and City of Brass (proton). I have not tried out the command suggested in the previous posts yet.

I would like to add that input doesn't seem to be affected - seems to be only a video output issue. Both games run at lower resolution and then get upscaled to my desired window size (~1910x1044)

flasheeprom commented 5 months ago

I had exactly the same issue in War Thunder after some time of game play. Sudden massive stuttering after a few minutes.

The command sudo setcap 'cap_sys_nice=eip' /usr/bin/gamescope solved the issue. Packagers should be made aware of this so they can include this in their build/installation scripts. This information should be added to the front page of this repository.

ammgws commented 5 months ago

That seems to have issues as well: https://github.com/ValveSoftware/gamescope/issues/107

misyltoad commented 5 months ago

setcap solves the issue because it breaks LD_PRELOAD. Setting LD_PRELOAD="" %command% also fixes the problem.

The problem is some pipe getting filled up in the Steam overlay stuff. I will see if there is some workaround.

flasheeprom commented 5 months ago

Setting LD_PRELOAD="" %command% also fixes the problem.

I had to use env LD_PRELOAD="" %command% instead, as LD_PRELOAD isn't an executable binary and throws xwm: execvp failed: No such file or directory

EDIT: And the game started stuttering again, so this doesn't seem to work.

misyltoad commented 5 months ago

Then you set it wrong. Send your full commandline arg

flasheeprom commented 5 months ago

First it was this:

gamescope -W 2560 -H 1440 -f --expose-wayland --force-grab-cursor --display-index 1 -- LD_PRELOAD="" %command%

which gave the error, then this:

gamescope -W 2560 -H 1440 -f --expose-wayland --force-grab-cursor --display-index 1 -- env LD_PRELOAD="" %command%

which ran, but didn't solve the issue.

misyltoad commented 5 months ago

LD_PRELOAD="" gamescope -W 2560 -H 1440 -f --expose-wayland --force-grab-cursor --display-index 1 -- %command%

Use that ^, sorry I wasn't clear enough.

flasheeprom commented 5 months ago

Thanks, it's running now. Will test for a while and report back.

EDIT: OK, this way seems to be working, which is better, as I don't have to setcap every time gamescope is updated.

Stewmath commented 4 months ago

I've been encountering this issue on the Steam Deck with two specific games - PrimeHack, and DX-Ball 2. The only common thread between these games that I can think of is that I spent a lot of time tinkering with the mouse settings in steam input.

The lag occurs specifically when the virtual mouse is moved (as configured through steam input). When the mouse stops moving there is no lag.

More details in the issue I filed with PrimeHack here: https://github.com/shiiion/dolphin/issues/144

The LD_PRELOAD fix thankfully also works on the steam deck, in particular these were my arguments for DX-Ball 2:

LD_PRELOAD= %command%

This is slightly different from the above posted fix, I guess because gamescope is invoked at a different stage in the launch process when running in game mode.

It's concerning that this is happening on a fairly normal, not overly modded steam deck.

FaelLiberatori commented 2 months ago

I recently opened #1511 about this issue. I’d like to add that the stutters mentioned are caused by frametime becoming unstable. Using LD_PRELOAD="" solved the issue for me. In my case, it didn’t seem to be limited to specific games (tested with both Baldur's Gate III and Death Stranding Director's Cut).

LoipesMas commented 1 month ago

I've also ran into this issue (with Rain World and Nier: Automata, although I haven't tested other games). Setting LD_PRELOAD="" does fix that, but it broke the controller support (I guess it breaks Steam Input?), so I fixed that by re-setting the LD_PRELOAD for the game itself. Here's the command I used, for those having the same issue:

LD_PRELOAD=""  gamescope -- env LD_PRELOAD=:/home/user/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so:/home/user/.local/share/Steam/ubuntu12_64/gameoverlayrenderer.so %command%

(Obviously you would need to make those paths point to your home directory, but other than that I assume it should work)

gavtroy commented 1 month ago

I'm also seeing this in many Steam games for the last few months. For me it started only when the Wayland backend was added (and when I use it) so there could potentially be a big uptick in affected users. LD_PRELOAD= does seem to avoid it.

Arch / KDE Plasma / RX 6800 XT, also consistently about 30 minutes in. An example game is Half-Life 2.

X-m7 commented 2 weeks ago

I think I may have been affected by this issue as well, and setting CAP_SYS_NICE did make it go away, except in my case the affected game was Forza Horizon 5 and it takes something like 3 hours of gameplay for the stutters to appear.

I don't know yet if setting LD_PRELOAD="" without CAP_SYS_NICE will also make my issue go away (currently I'm trying out Flatpak for games so CAP_SYS_NICE is no longer an option), will give it a try and see if the stutters come back or not.