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 5010 - SDL_Init with SDL_INIT_JOYSTICK hangs for 10 seconds when playing audio from another application
Summary: SDL_Init with SDL_INIT_JOYSTICK hangs for 10 seconds when playing audio from ...
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: joystick (show other bugs)
Version: 2.0.10
Hardware: x86_64 Windows 10
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-01 06:59 UTC by Jake Breen
Modified: 2020-03-22 18:03 UTC (History)
0 users

See Also:


Attachments
Tested modified hid_blacklist function (734 bytes, text/plain)
2020-03-03 00:04 UTC, Jake Breen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jake Breen 2020-03-01 06:59:13 UTC
Howdy!

I first noticed this when creating an FNA project, however it's simple to recreate with a blank x86 or x64 C++ project using SDL 2.0.10 pre-built msvc binaries.

When I run SDL_INIT with SDL_INIT_JOYSTICK it stalls for about 10 seconds (last report was 10,615ms), but only if I'm currently playing audio. (Like in Spotify for example.) 

querying something related to device access (last dll loaded)
'BabbysFirst64.exe' (Win32): Loaded 'C:\Windows\SysWOW64\deviceaccess.dll'. 

I use a USB DAC because my mobo's audio out is pretty not great. And I've noticed unplugging it seems to solve the issue. I haven't noticed any other issues that are caused by my DAC.

My DAC is the Sound BlasterX G1 https://us.creative.com/p/gaming-headsets/sound-blasterx-g1

My system specs:
- Windows 10 Pro
- Ryzen 2700x
- 16GB Ram
- Nvidia 2070 RTX

Additional USB devices plugged in:
- Valve Index
- Xbox One Elite Controller

Now I'm not sure how much you can debug off of this, so let me know if there's anything you want me to try and reproduce! 

Cheers,
Jake
Comment 1 Sam Lantinga 2020-03-02 01:55:21 UTC
What is the USB VID/PID of the device? We can add it to the blacklist so we skip it during enumeration.
Comment 2 Jake Breen 2020-03-02 02:31:05 UTC
According to device manager it's:
Vid = 041E
PID = 3249

Cheers,
Jake
Comment 3 Sam Lantinga 2020-03-02 23:07:44 UTC
I may have fixed it in this commit:
https://hg.libsdl.org/SDL/rev/3e9f11265172

Can you try with the latest snapshot?
http://www.libsdl.org/tmp/SDL-2.0.zip
Comment 4 Jake Breen 2020-03-03 00:04:56 UTC
Created attachment 4232 [details]
Tested modified hid_blacklist function

Unfortunately it doesn't.

I have tracked it down to a call on
hid_device_info() -> HidD_GetManufacturerString (Line 499 in src\hidapi\windows\hid.c) 

I've added the vid/pid to hid_blacklist and it works great.

I'm a little clueless when it comes to patches, so I've cut out the function into a file and attached it. (Included the file, and line number in the comments)
Comment 5 Sam Lantinga 2020-03-03 01:32:20 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL/rev/88068887c25d
Comment 6 Sam Lantinga 2020-03-21 03:56:27 UTC
Can you double check that this hasn't regressed in the latest SDL snapshot?
http://www.libsdl.org/tmp/SDL-2.0.zip

Thanks!
Comment 7 Jake Breen 2020-03-21 04:19:41 UTC
Seems to work fine!

Thanks!
Comment 8 Sam Lantinga 2020-03-22 18:03:03 UTC
Great, thanks!