libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
9.87k stars 1.83k forks source link

SDL2 Performance regression since 2.0.18.0 when used with Joycons in various apps using SDL library. #9106

Open bad-netcode opened 8 months ago

bad-netcode commented 8 months ago

Im not sure whats changed with the library but just spent a day trouble shooting some controll issues in various emulators. Input lag issues I had not experienced with some decent BT adapters, two machines and two sets of Joycons.

I could easily rule out hardware issues and after initially discovering that disabling vibration drastically improved things across various apps using the SDL library I decided to take a look at when these apps updated there SDL libraries and if different releases changed things.

I knew the motion controls of the Joy Cons had worked flawlessly in the past and sure enough, older versions of the SDL library do not so produce this regression.

I can pin point the last version that didnt show this regression was 2.0.18.0.

The issue is easily reproduced. Load up an application of choice that makes use of newer SDL2 builds (Yuzu, Ryu) and connect Joycons, having motion and vibration enabled. You will see some degree of input lag. If you wish to stay on your current SDL version youll need to disable vibration. Otherwise downgrading to the aforementioned version will allow you to use Joycons, with vibration enabled, without the 800ms input delay.

To further confirm the SDL library is at fault, updating the SDL library within Dolphins mainline to a more recent release will produce similar issues.

TAGS for those seeking a workaround; Joycon input lag motion control yuzu ryu dolphin delay laggy vibration multiple controllers pro controller delayed

slouken commented 8 months ago

Can you reproduce this with SDL's testgamecontroller, or is there something specific about the way Yuzu, Ryu, etc. interact with the controller that demonstrates this?

ViRb3 commented 7 months ago

Can confirm a similar issue with my 8BitDo Lite Bluetooth Controller on Ryujinx 3924bd1 (SDL 2.30.0, I think) on macOS 14.4. The controller can toggle between Switch and Xbox controller emulation. I recorded a 240fps slow motion video on my phone, pressing the same button in the same menu, and counting the frames until anything happens. Consistently, I get 19 frames for Xbox mode and 34 frames for Switch mode. This is almost a 2x difference. I'm not well versed in SDL, so please let me know how to test further and I'm happy to do so. Thanks!

ViRb3 commented 7 months ago

Seeing a similar issue with Dolphin 5.0-21088 which is at SDL 2.26.5. Strangely, the latency seems to be cut in half, but still seeing 2x difference: around 10 frames for Xbox mode and around 20 frames for Switch mode.