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 5361

Summary: RFC: Automatically fall back to non-udev joystick detection in Flatpak or pressure-vessel container
Product: SDL Reporter: Simon McVittie <smcv>
Component: joystickAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.1   
Hardware: x86_64   
OS: Linux   
Attachments: joystick: Don't use udev in Flatpak or pressure-vessel container

Description Simon McVittie 2020-11-19 17:42:55 UTC
Another follow-up for Bug #5337.

We can't expect udev change-notification to work reliably in containers, for the reasons discussed on Bug #5337.

Flatpak provides an official way to detect that you're inside a Flatpak container (test whether the file /.flatpak-info exists), so perhaps it would make sense for SDL to move to the inotify code path automatically in that case?

Similarly, Steam's pressure-vessel container tool, as used for the Steam Linux Runtime containers, can be detected by probing /run/pressure-vessel.
Comment 1 Simon McVittie 2020-11-19 17:43:39 UTC
Created attachment 4530 [details]
joystick: Don't use udev in Flatpak or pressure-vessel container


Flatpak[1] and pressure-vessel[2] are known to use user namespaces,
therefore udev event notification via netlink won't work reliably.
Both frameworks provide a filesystem API that libraries can use to
detect them. Do that, and automatically fall back from udev-based
device discovery to the inotify-based fallback introduced in Bug #5337.

[1] <https://flatpak.org/>
[2] <https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/tree/master/pressure-vessel>
Comment 2 Sam Lantinga 2020-11-24 05:11:10 UTC
Looks good, thanks!
https://hg.libsdl.org/SDL/rev/5a0fa9b6d4bf