We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4868 - [PATCH] Optimization for non-libudev joystick detection
Summary: [PATCH] Optimization for non-libudev joystick detection
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: joystick (show other bugs)
Version: HG 2.0
Hardware: x86_64 Linux
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-11-21 04:31 UTC by Cameron Gutman
Modified: 2019-12-04 05:24 UTC (History)
1 user (show)

See Also:


Attachments
Patch (2.90 KB, patch)
2019-11-21 04:31 UTC, Cameron Gutman
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Cameron Gutman 2019-11-21 04:31:01 UTC
Currently, we attempt to open() everything in the /dev/input folder every 3 seconds looking for joystick (if we don't have udev, like with Flatpaks). This is problematic because opening an input device can result in I/O which may block the main thread for a short while, causing dropped frames. The delay (or lack thereof) depends on whether other processes on the system already have a fd open and what each input device driver actually does on open.

The attached patch implements a simple stat() mtime check to avoid opening devices if /dev/input hasn't changed since last time we checked. I could have gone with something more fancy like inotify, but it didn't seem worth the complexity for the (hopefully rare) non-udev codepath.
Comment 1 Cameron Gutman 2019-11-21 04:31:41 UTC
Created attachment 4064 [details]
Patch
Comment 2 Sam Lantinga 2019-12-04 05:24:18 UTC
Good change, thanks!
https://hg.libsdl.org/SDL/rev/f9a9707ff56d