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 4564

Summary: Not initializing Joystick subsystem causes SDL_PollEvents to block with some hardware devices connected
Product: SDL Reporter: Matheus Valadares <matheusavs3>
Component: joystickAssignee: Sam Lantinga <slouken>
Status: RESOLVED DUPLICATE QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: metalcaedes
Version: 2.0.9   
Hardware: x86_64   
OS: Windows 10   
Attachments: Repro code, not very useful without the hardware

Description Matheus Valadares 2019-03-24 02:17:52 UTC
Created attachment 3711 [details]
Repro code, not very useful without the hardware

This is a very weird bug I found that is a bit hard to reproduce. Here are all the details I could collect:

It happens only when the joystick subsystem is *disabled*.

On Windows 10, with a specific USB hardware device plugged in (it's an USB microphone), every exactly 3 seconds, a call to SDL_PollEvents blocks for ~80 ms.

Initializing the joystick subsystem makes the problem go away, not initializing it causes the problem to appear. Other systems being initialized (other than the gamecontroller one which initializes joystick) does not affect anything. Unplugging the device while the program is running makes the problem go away, replugging brings it back.

The blocking code is in the function hid_enumerate (in hidapi\windows\hid.c). Most of the time is spent in SetupDiGetDeviceRegistryProperty, but some non-insignificant amount of time is spent in other functions too (SetupDiGetClassDevsA, CreateFileA and HidD_GetManufacturerString).

The 3 seconds timer seems to come from HIDAPI_UpdateDiscovery.

This is the microphone: https://smile.amazon.com/gp/product/B001R76D42
Comment 1 Daniel Gibson 2019-04-05 17:23:20 UTC
This sounds like a duplicate of #4391
The bug has been introduced in 2.0.9, the code is fixed in hg and will be part of 2.0.10 (whenever it's released)

*** This bug has been marked as a duplicate of bug 4391 ***