You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Calls to DirectInput EnumDevices sometimes very slow! #1
Typically calls to EnumerateDevices which calls _DirectInput->EnumDevices take about 85ms on average on my system.
Sometimes, this is orders of magnitude larger taking in the range of minutes instead of milliseconds.
This is due to device drivers on the system, in my case a Corsair K70 Keyboard, hanging and not replying to Window's request to query attached devices.
Perhaps the DLL should start a watchdog and timeout the EnumerateDevices function if it takes more than ~300ms?
Hopefully, as each enumerated device adds to _DeviceInstances in its own callback instance, if we cancel EnumDevices early _DeviceInstances will still be populated with the correct information. 🤞 other devices are processed before we hang. Otherwise, the timeout will need to be in the callback, which will be more difficult to implement.
This is a very difficult issue to debug as it only happens occasionally.
Luckily, when it does happen and EnumerateDevices hangs, I can slide the Hz slider on my K70 and EnumerateDevices immediately returns.
min = 4900ns
max = 417400ns
Range R = 412500ns
Count n = 54
sum = 2455500ns
Mean x̄ = 45472.222ns
Median x˜ = 44050ns
mode = 5300, 45200
Standard Deviation = 75339.76ns
Variance s2 = 5676079400
Activity
MrTimcakes commentedon Aug 26, 2021
Perhaps the DLL should start a watchdog and timeout the
EnumerateDevicesfunction if it takes more than ~300ms?Hopefully, as each enumerated device adds to
_DeviceInstancesin its own callback instance, if we cancelEnumDevicesearly_DeviceInstanceswill still be populated with the correct information. 🤞 other devices are processed before we hang. Otherwise, the timeout will need to be in the callback, which will be more difficult to implement.This is a very difficult issue to debug as it only happens occasionally.
Luckily, when it does happen and
EnumerateDeviceshangs, I can slide the Hz slider on my K70 andEnumerateDevicesimmediately returns.MrTimcakes commentedon Aug 26, 2021
_EnumDevicesCallbackStatistics from 54 samples:min = 4900ns
max = 417400ns
Range R = 412500ns
Count n = 54
sum = 2455500ns
Mean x̄ = 45472.222ns
Median x˜ = 44050ns
mode = 5300, 45200
Standard Deviation = 75339.76ns
Variance s2 = 5676079400
MrTimcakes commentedon Aug 26, 2021
Upon further inspection, the delay doesn't occur within
_EnumDevicesCallbackTested when issue is occurring
_EnumDevicesCallback MrT USB Handbreak: 16000ns
_EnumDevicesCallback FANATEC CSL Elite Wheel Base PlayStation: 45300ns
_EnumDevicesCallback FANATEC CSL Elite Wheel Base PlayStation: 43400ns
EnumDevices: 40192473100ns
MrTimcakes commentedon Aug 26, 2021
Made an attempt to exit
EnumDevicesearly but_DeviceInstancesisn't populated 😭