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

Games take forever to launch

Open octopoulpe opened this issue 2 years ago • 4 comments

Your system information

  • Steam client version (build number or date): 1696019606 (but I had the same problem for ages)
  • Distribution (e.g. Ubuntu): archlinux
  • Opted into Steam client beta?: No
  • Have you checked for system updates?: Yes
  • Steam Logs: https://share.unitel.one/#/rz08ur33
  • GPU: Nvidia

Please describe your issue in as much detail as possible:

When launching a game (any game, proton or linux native), it takes several minutes for the game to start. In the Steam UI, the game is in "Running" state but the game process is not started yet. During this time, my ~/.local/share/Steam/ubuntu12_32/steam process is at 100% of 1 CPU core (no cpu problems at any other times).

On the console I don't get anything suspicious :

Fossilize INFO: Setting autogroup scheduling.
/bin/sh\0-c\0/home/poulpe/.local/share/Steam/ubuntu12_32/reaper SteamLaunch AppId=200710 -- /home/poulpe/.local/share/Steam/ubuntu12_32/steam-launch-wrapper -- '/databig/games/SteamLibrary/steamapps/common/Torchlight II/ModLauncher.bin.x86_64'\0
chdir "/databig/games/SteamLibrary/steamapps/common/Torchlight II"

When I strace the ~/.local/share/Steam/ubuntu12_32/steam process, I can see it tries to open countless file descriptors.

fcntl64(657410824, F_GETFD)             = -1 EBADF (Bad file descriptor)
fcntl64(657410825, F_GETFD)             = -1 EBADF (Bad file descriptor)
fcntl64(657410826, F_GETFD)             = -1 EBADF (Bad file descriptor)
fcntl64(657410827, F_GETFD)             = -1 EBADF (Bad file descriptor)
fcntl64(657410828, F_GETFD)             = -1 EBADF (Bad file descriptor)
fcntl64(657410829, F_GETFD)             = -1 EBADF (Bad file descriptor)
fcntl64(657410830, F_GETFD)             = -1 EBADF (Bad file descriptor)
fcntl64(657410831, F_GETFD)             = -1 EBADF (Bad file descriptor)
fcntl64(657410832, F_GETFD)             = -1 EBADF (Bad file descriptor)
fcntl64(657410833, F_GETFD)             = -1 EBADF (Bad file descriptor)
fcntl64(657410834, F_GETFD)             = -1 EBADF (Bad file descriptor)

It increments up until 1073741815 every time (which is really close to 2^30 but not exactly, not sure if it's useful).

fcntl64(1073741813, F_GETFD)            = -1 EBADF (Bad file descriptor)
fcntl64(1073741814, F_GETFD)            = -1 EBADF (Bad file descriptor)
fcntl64(1073741815, F_GETFD)            = -1 EBADF (Bad file descriptor)
rt_sigprocmask(SIG_UNBLOCK, [CHLD], NULL, 8) = 0
execve("/bin/sh", ["/bin/sh", "-c", "/home/poulpe/.local/share/Steam/"...], 0x58afb900 /* 100 vars */) = 0

Here the real game process starts.

Steps for reproducing this issue:

  1. Launch any game
  2. Wait
  3. Wait
  4. Wait
  5. Wait
  6. The game starts

I tried tweaking almost every option available in steam for months without any success. Never heard of anyone having the same problem.

octopoulpe avatar Oct 15 '23 16:10 octopoulpe

Hello @octopoulpe, this issue report reminds me of #7970. Can you share the output of ulimit -Sn? (1024 is common and expected, but it's user configurable.)

kisak-valve avatar Oct 15 '23 17:10 kisak-valve

$ ulimit -Sn
1073741816

You got it @kisak-valve :clap:

octopoulpe avatar Oct 15 '23 19:10 octopoulpe

@octopoulpe did you ever find a solution/cause?

Adam-S-Gibson avatar Jul 01 '24 00:07 Adam-S-Gibson

Hello @Adam-S-Gibson, if your system is configured similarly to @octopoulpe's with a high soft file limit, the performance adjustment would be to change it to a value closer to the 1024 common default.

kisak-valve avatar Jul 01 '24 00:07 kisak-valve

Just chiming in with a +1, experiencing identical issue (but debian, and AMD GPU (mesa/RADV)), with a soft limit of 1024 fds - starting any game can take 3 to 4 minutes, and I can see similar behaviour from steam trying to open hundreds of thousands of files... before finally launching.

mwheeler avatar Jul 14 '24 10:07 mwheeler

I had this issue come up after downgrading my Nvidia drivers. I was able to fix it by deleting my ~/.cache directory

mgord9518 avatar Nov 18 '24 08:11 mgord9518

I'm running steam containerized inside podman, with a container image based on Ubuntu 24.04 (noble). When upgrading the host system from Ubuntu 24.10 (oracular) to 25.04 (plucky) (while still using the same container image) I hit the same issue as reported here. When trying to diagnose the problem I saw a couple of references to seemingly similar issues - sometimes in other containerized steam setups, e.g., flatpak - but no reported solutions. Only after tracking down the root cause using strace was I able to find this already reported issue.

In my case, upgrading the host system (including a newer version of podman) apparently vastly increased the limit on open files to 1073741816. The issue reported here -- steam somehow interacting with all "allowed" file descriptors -- meant that after the upgrade all attempts at launching any kind of game gets stuck, in a state that is not stopped by clicking "Stop" in the steam client.

Perhaps useful to mention for helping people find this issue: upon attempting to launch a game the last most prominent message I saw was: "WARNING: discarding _NET_WM_PID 118676 as invalid for X11 window - use specialized XCB_X11_TO_PID function!". However, it seems this does not have anything to do with this issue. The warning remains for me after the successful workaround below.

Since I don't see anyone above spelling out the workaround: just set a more strict limit on open files before starting steam, e.g.:

ulimit -n 65536
steam

I suggest as a short-term solution that the linux steam client simply adds the instructions to impose this limit in its own startup code. Longer-term, I suggest rethinking looping over all allowed file descriptors. (My guess is that we are hitting this in some kind of attempt to sanitize the environment by very heavy-handedly closing all file descriptors.)

rartino avatar Sep 30 '25 23:09 rartino