[1.3.3287] 100% single core CPU utilization when in background on Linux

Started by nipsy, March 23, 2022, 03:45:41 AM

Previous topic - Next topic

nipsy

I think this is a variation of the previously reported bug described in this now locked post at: https://ludeon.com/forums/index.php?topic=38076.msg390196

Anytime the game is put into the background, either while on the main menu or during game play, whether in a paused state or while game time is running, the game process goes into a tight loop presumably because it's aware it has lost focus.  Instead of idling properly, I hear my CPU cooler spin up mightily as that one core goes to 100% utilization in aforementioned loop.  The loop looks like this:


$ strace -s 4096 -fp 3316563
strace: Process 3316563 attached with 52 threads
[pid 3317190] restart_syscall(<... resuming interrupted read ...> <unfinished ...>
[pid 3316916] restart_syscall(<... resuming interrupted read ...> <unfinished ...>
<snipped a bunch of duplicate lines with different PID's>
[pid 3316610] pselect6(64, [63], NULL, NULL, {tv_sec=260, tv_nsec=853852181}, NULL <unfinished ...>
[pid 3316609] restart_syscall(<... resuming interrupted read ...> <unfinished ...>
[pid 3316608] futex(0x1591da8, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, NULL, FUTEX_BITSET_MATCH_ANY <unfinished ...>
[pid 3316607] restart_syscall(<... resuming interrupted read ...> <unfinished ...>
[pid 3316605] restart_syscall(<... resuming interrupted read ...> <unfinished ...>
[pid 3316597] restart_syscall(<... resuming interrupted read ...> <unfinished ...>
[pid 3316596] futex(0x7f67d01a8a80, FUTEX_WAIT_PRIVATE, 0, NULL <unfinished ...>
[pid 3316595] futex(0x7f67d01a8a80, FUTEX_WAIT_PRIVATE, 0, NULL <unfinished ...>
[pid 3316594] futex(0x7f67d01a8a80, FUTEX_WAIT_PRIVATE, 0, NULL <unfinished ...>
<snipped even more duplicate lines with different PID's>
[pid 3316580] futex(0x7f67d01a8880, FUTEX_WAIT_PRIVATE, 26910, NULL <unfinished ...>
[pid 3316579] futex(0x7f67d01a8880, FUTEX_WAIT_PRIVATE, 26915, NULL <unfinished ...>
[pid 3316578] futex(0x7f67d01a8880, FUTEX_WAIT_PRIVATE, 26904, NULL <unfinished ...>
<snipped more duplicates here with different PID's and futex values>
[pid 3316565] futex(0x7f679c2e37f0, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, NULL, FUTEX_BITSET_MATCH_ANY <unfinished ...>
[pid 3316564] futex(0xe731b0, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, NULL, FUTEX_BITSET_MATCH_ANY <unfinished ...>
[pid 3316563] pselect6(7, [6], NULL, NULL, {tv_sec=0, tv_nsec=0}, NULL <unfinished ...>
[pid 3316580] <... futex resumed>)      = -1 EAGAIN (Resource temporarily unavailable)
[pid 3316579] <... futex resumed>)      = -1 EAGAIN (Resource temporarily unavailable)
[pid 3316578] <... futex resumed>)      = -1 EAGAIN (Resource temporarily unavailable)
<snipped more duplicates here with different PID's>
[pid 3316563] <... pselect6 resumed>)   = 0 (Timeout)
[pid 3316580] futex(0x7f67d01a8880, FUTEX_WAIT_PRIVATE, 26916, NULL <unfinished ...>
[pid 3316579] futex(0x7f67d01a8880, FUTEX_WAIT_PRIVATE, 26916, NULL <unfinished ...>
[pid 3316578] futex(0x7f67d01a8880, FUTEX_WAIT_PRIVATE, 26916, NULL <unfinished ...>
<snipped more duplicates here with different PID's but all waiting on the same futex>
[pid 3316563] pselect6(32, [31], NULL, NULL, {tv_sec=0, tv_nsec=0}, NULL) = 0 (Timeout)
[pid 3316563] recvmsg(6, {msg_namelen=0}, 0) = -1 EAGAIN (Resource temporarily unavailable)
[pid 3316563] recvmsg(6, {msg_namelen=0}, 0) = -1 EAGAIN (Resource temporarily unavailable)
[pid 3316563] pselect6(7, [6], NULL, NULL, {tv_sec=0, tv_nsec=0}, NULL) = 0 (Timeout)
[pid 3316563] pselect6(32, [31], NULL, NULL, {tv_sec=0, tv_nsec=0}, NULL) = 0 (Timeout)
[pid 3316563] recvmsg(6, {msg_namelen=0}, 0) = -1 EAGAIN (Resource temporarily unavailable)
[pid 3316563] recvmsg(6, {msg_namelen=0}, 0) = -1 EAGAIN (Resource temporarily unavailable)


And you end up at the bottom there of what looks to be the hard loop between pselect and recvmsg.

This is trivial to reproduce.  I'm using i3 as my window manager.  The game is running full screen launched from Steam.  Simply switching to another i3 workspace (virtual desktop) triggers the behavior.  The sound also stops playing, hence why I think it's simply wanting to idle in a paused state during the loss of focus, but programmed very badly, quite possibly within Unity itself.  Here are all of my version details for anything I think is relevant:


Debian bookworm (testing, with unstable pinned to a lower priority) with main, contrib and non-free repos all enabled; multiarch enabled for amd64 and i386
Actual Steam client version: 1647446817 (Built: Mar 14 2022)
Rimworld Steam Linux install 1.3.3287 (64-bit)

$ dpkg -l | grep -E '^ii  (i3 |linux-image-5.16.0-5|nvidia-kernel-dkms|steam:|xserver-xorg-core|zfs-dkms)'
ii  i3                                                          4.20.1-1                              amd64        metapackage (i3 window manager, screen locker, menu, statusbar)
ii  linux-image-5.16.0-5-amd64                                  5.16.14-1                             amd64        Linux 5.16 for 64-bit PCs (signed)
ii  nvidia-kernel-dkms                                          510.54-1                              amd64        NVIDIA binary kernel module DKMS source
ii  steam:i386                                                  1:1.0.0.74-1                          i386         Valve's Steam digital software delivery system
ii  xserver-xorg-core                                           2:21.1.3-2+b1                         amd64        Xorg X server - core server
ii  zfs-dkms                                                    2.1.2-1                               all          OpenZFS filesystem kernel modules for Linux


This is an entirely vanilla installation with neither expansion nor any mods.  The only slightly "abnormal" things about my system might be the proprietary GPU drivers (obviously required) and the fact that all my underlying file systems are ZFS (I can't possibly imagine this having anything to do with the problem based on the exhibited behavior; I'm just including it for completeness).

Feel free to let me know if any other information would be helpful in reproducing this.

Canute

Hi,
at last the windows version got at the option "Run at background".
When the flag is on, the game keep running even when it isn't focused.
When you turn on/off that flag does it made any different for you ?