From the description of the problem (a freeze every 3 seconds) I knew exactly what it was. You can fix it by simply upgrading SDL as they fixed this bug 2 years ago. https://github.com/spurious/SDL-mirror/commit/59728f9802c786...
From one of the printouts in the post, it seems that Papers Please is using a bundled and statically linked SDL. So it would be the game developer that would have to update the version of the SDL library. The binary patching done seems like a good-enough alternative in the meantime. I have the feeling such bundling of dependencies is fairly common when porting games for Linux.
Fixing stutters in Papers Please on Linux
21–30 of 202 posts
Re: Fixing stutters in Papers Please on Linux
#22Earlier quoted context omitted.
Yes, and even if it checks for new devices, it should only need to check devices it hasn't already checked.
Ah, but are /dev/input entries reusable? Let's say you have /dev/input/event{0,10}, event5 is a USB keyboard, you unplug it, I assume event5 goes away. But then you plug in a controller, does this get mapped to event11, or does event5 get reused? Is the behaviour reliable in all versions of linux? You might argue that metadata should do the trick, but in my experience, on device files, anything beyond read/write is a…
Re: Fixing stutters in Papers Please on Linux
#23Why is the engine even checking input devices so often? Shouldn't the input device be registered via settings and then assumed to exist when the game runs? It seems wasteful to check all input devices every few seconds.
But even if it wants to do this, why is it doing it on the main thread!? :(
Re: Fixing stutters in Papers Please on Linux
#24Why is the engine even checking input devices so often? Shouldn't the input device be registered via settings and then assumed to exist when the game runs? It seems wasteful to check all input devices every few seconds.
A lot of games will automatically switch between keyboard and gamepad when a gamepad is connected. Perhaps this is some automatic background function that SDL handles.
But you can also manually enumerate devices as in the example here: http://wiki.libsdl.org/SDL_GameControllerOpen
Re: Fixing stutters in Papers Please on Linux
#25Earlier quoted context omitted.
From one of the printouts in the post, it seems that Papers Please is using a bundled and statically linked SDL. So it would be the game developer that would have to update the version of the SDL library. The binary patching done seems like a good-enough alternative in the meantime. I have the feeling such bundling of dependencies is fairly common when porting games for Linux.
SDL has its own "dynapi" layer, where you can override it with your own copy of SDL even if it was statically linked: https://github.com/libsdl-org/SDL/blob/main/docs/README-dyna...
Re: Fixing stutters in Papers Please on Linux
#26Earlier quoted context omitted.
Why is it even doing this on the main thread at all? The obvious thing would be to have a background thread polling for changes and then sending messages asynchronously to the main thread if a change actually occurred...
It is appropriate to use your main thread for your OS interaction - polling fds, talking to display server, whatever I/O you need, etc. An open/close call should never take this long, and you should never need to make a large amount of them in sequence after startup. What should not be on your main thread is any long blocking compute, which is why rendering/game logic often goes to another thread - although simple ga…
> What should not be on your main thread is any long blocking compute
Isn't that contradicting yourself? I'm pretty sure open() can block.
Re: Fixing stutters in Papers Please on Linux
#27Earlier quoted context omitted.
SDL has its own "dynapi" layer, where you can override it with your own copy of SDL even if it was statically linked: https://github.com/libsdl-org/SDL/blob/main/docs/README-dyna...
Is the version statically linked recent enough to support it? Also, can’t decide if it’s genius or insane, that extra layer of dynamic linking…
[1] https://old.reddit.com/r/linux_gaming/comments/1upn39/sdl2_a...
Edit: (what I believe to be) This freezing bug was only added 3 years ago, so it might actually have it.
Re: Fixing stutters in Papers Please on Linux
#28Earlier quoted context omitted.
Ah, but are /dev/input entries reusable? Let's say you have /dev/input/event{0,10}, event5 is a USB keyboard, you unplug it, I assume event5 goes away. But then you plug in a controller, does this get mapped to event11, or does event5 get reused? Is the behaviour reliable in all versions of linux? You might argue that metadata should do the trick, but in my experience, on device files, anything beyond read/write is a…
Isn’t this the whole point of using file descriptors? As long as you have an open file descriptor, the kernel resource it references should remain stable. And if the resource is unexpectedly destroyed from under the process’s nose, the file descriptor should report an I/O error the next time you try to read or write from it.
Opening the same file multiple times will yield different fds, and the paths can be modified independently of the fd.
The goal here is to find if:
1. there are new input devices
2. which are joysticks (a category which, for SDL, includes gamepads, so basically "has the user plugged in a new gamepad they might want to use for the game")
How would keeping a bunch of fds around help?
Re: Fixing stutters in Papers Please on Linux
#29Why is the engine even checking input devices so often? Shouldn't the input device be registered via settings and then assumed to exist when the game runs? It seems wasteful to check all input devices every few seconds.
A lot of games will automatically switch between keyboard and gamepad when a gamepad is connected. Perhaps this is some automatic background function that SDL handles.
https://docs.microsoft.com/en-us/windows/win32/xinput/gettin...
In general, "notifying the program when a new device has become available" seems to be a surprisingly difficult problem. I've encountered trouble with multiple device types across multiple platforms.
Re: Fixing stutters in Papers Please on Linux
#30Will have to fire up my copy again. A good excuse to play this marvelous game again.