Live data from Hacker News

Fixing stutters in Papers Please on Linux

blog.jhm.dev

31–40 of 202 posts

Re: Fixing stutters in Papers Please on Linux

#31
post #23
post #8

Why 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.

Exactly. It should enumerate them when the player opens settings. Or at startup. But even if it wants to do this, why is it doing it on the main thread!? :(

If I start the game without a gamepad attached to the computer, and then attach the gamepad, I'd like to use the gamepad without restarting the game. And one would expect that polling the attached input devices should never take hundreds or thousands of milliseconds, there must be something seriously wrong in the Linux input device stack or maybe in one of the input device drivers.

Re: Fixing stutters in Papers Please on Linux

#32
post #5

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...

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...

The problem probably only shows up on some machines and hasn't been noticed during development and testing. And TBH, polling what input devices are connected should never take more than a few microseconds, no matter how much operating system code sits between the hardware and game code.

Re: Fixing stutters in Papers Please on Linux

#34

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...

Why is udev not used in this case?

Re: Fixing stutters in Papers Please on Linux

#37
post #23

Earlier quoted context omitted.

Exactly. It should enumerate them when the player opens settings. Or at startup. But even if it wants to do this, why is it doing it on the main thread!? :(

If I start the game without a gamepad attached to the computer, and then attach the gamepad, I'd like to use the gamepad without restarting the game. And one would expect that polling the attached input devices should never take hundreds or thousands of milliseconds, there must be something seriously wrong in the Linux input device stack or maybe in one of the input device drivers.

Or maybe just poll for new input devices when the game is paused, or before the game starts.

Re: Fixing stutters in Papers Please on Linux

#38
post #10

Earlier 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…

The actual SDL fix was even simpler, they now just check if the mtime of the /dev/input directory changed: https://github.com/spurious/SDL-mirror/commit/59728f9802c786...
Post reply on HN