-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Insufficient delay in UInput._find_device_fallback() #214
Comments
what's your kernel version? And please also post |
And |
|
Also:
|
Interesting, so it takes some time even though devtmpfs is being used. If I remember correctly, this contradicts our previous discussion @KarsMulder |
On general principles, I also think it's not ideal to rely on the delay, as it can result in code breaking on a heavily loaded system, or when running under emulation, or when the system is severely underclocked, etc. I think the ideal would be a caller-specifiable timeout, with a generous default. |
I might of course have been wrong and devtmpfs might after all not actually be in charge of managing event device nodes, just some other kind of device nodes. Another possibility to consider is that the event nodes do actually show up immediately through devtmpfs, but are only accessible to root, because devtmpfs always creates nodes with a fixed set of default permissions and it is the task of udev to change those permissions to whatever the OS wants them to be (source.) So maybe the device shows up immediately owned by This could be an explanation for why it immediately shows up when running as root, but not when running as non-root. Though if that was the case, I would expect the |
Good guess about permissions. I included os.system("ls -l /dev/input") during each iteration of the retry loop in my modified version. First time through it showed
Note the lack of group permissions for event2. Second time around it showed:
Now event2 is accessible. So this does indeed explain why it works as root but not as an ordinary user. |
A workaround is for the module caller to loop until the device becomes available. But it would be neater if the fix was in the evdev module. |
I have created pull request #215 to fix this issue. |
It works for me! Thank you. |
On my Raspberry PI 3B+, when I create a uinput device using a non-root user, the device does not show up quickly enough for UInput._find_device_fallback() to find it. (It works fine with root, oddly.) Currently there is a sleep(0.1) delay in the method. If I raise the delay to sleep(0.5), it works fine.
But one doesn't want to add latency to everybody's code. So what I did on my local installation was to add a timeout of 10 seconds, and loop until the time runs out if nothing is found, with a 0.1 second delay after each try. This also removes the 0.1 second delay on systems where the device shows up quickly.
The text was updated successfully, but these errors were encountered: