NativeInputSystem.IOCTL taking 250ms

Hi,

We’ve occasionally been seeing a strange performance hit in our game and we’ve been trying to pinpoint it for a while. Today I noticed the following entries in the log at the same time as this performance drop:

 [16:27:19.340] Joystick reconnected ("Xbox Bluetooth Gamepad").
[16:27:19.698] Joystick disconnected ("Xbox Bluetooth Gamepad").

So I made a dev build and ran the profiling whilst disconnecting and reconnecting my USB bluetooth receiver (which my gamepad is connected to). Whilst disconnecting the receiver causes InputManager.Update a spike at 46ms, the worst offender is the reconnection which causes around 20 frames in a row where a call to NativeInputSystem.IOCTL takes 250ms.

This call to NativeInputSystem.IOCTL originates from our controller rumble system which is calling Gamepad.SetMotorSpeeds every frame in order to set the controller rumble amount.

Has anyone experienced this before, or have any idea of what is causing it and how to avoid it?

*Edit
We’re using version 1.4.1, in Unity 2021.3.15f1
Noticing this in PC standalone builds

Cheers,
Andy

Update, this still happens with 1.5.1

I have submitted a bug report of this