WIP: hidapi/linux: retry hid_send_feature_report() if the ioctl() fails with EPIPE (e.g. the device stalled) #579
No reviewers
Labels
No labels
3rdparty
Android
API
Author does not respond
bsd
bug
build system/CI
ci-virtual-device
CMake
Contributions Welcome
Core
dependencies
device-specific
documentation
don't_merge
duplicate
enhancement
Example
Haiku
hidraw
hotplug
info required
invalid
libusb
macOS
Misc
Not an issue
question
Release
Test
Test GUI
Windows
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-libusb/hidapi!579
Loading…
Reference in a new issue
No description provided.
Delete branch "slouken/0001-hidapi-linux-retry-hid_send_feature_report-if-the-io.patch"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Just wondering what is the device which has this issue. Thanks. Retry count of 50 seems to be quite high.
I don't remember offhand, this fix is several years old, but it's 50 retries without any delay, so I believe this was a very fast loop.
50 is definitely too much (that is a lot of flood on the driver/bus in some cases when
EPIPEis even expected.I cannot imagine a case, where the
ioctlfails for 47 times and then suddenly succeeds for the 48-th time.By my experience - if it fails for 2-3 times in a row - it will not recover on its own.
And this workaround is too specific - why only
send_feature_report? What about input/output reports, etc.?And if we're to handle the return codes of
ioctl- we better handle not onlyEPIPE, but at leastEINTR(often a debugger attachement) as well.In one of my projects I use:
I suggest we adapt it (make a C macro instead of C++ template) for our case, and use in all report related functions.
And 5 attempts should be enough, unless you have specific measurements where 50 is justified.
5 was definitely not enough. I ran into this on the Steam Link hardware, which is fairly slow, and I think the actual number in that case was the low 20s and I doubled it for safety. My goal was to provide the lowest latency possible while still handling EPIPE conditions. This happens only rarely, so my assumption was that leaving the number high was fine.
In any case, I just wanted to share in case this was helpful. If you go with a different approach, no worries.
In that case maybe make the number of retries configurable. Make it small (5?) by default and give some means to configure it for projects like SDL.
The thing is that I encounter
EPIPEquite often and consistently with some devices in some scenarios and in all of those - it is not recoverable (due to HW/FW bug/inconsistency, driver error, etc.). And too many retries would just flood the logs with no real improvement(s).Making a draft for now, until we have a better implementation.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.