Invalid Enum KeyCode Error due to :GetSupportedGamepadKeyCodes() on Mobile

Background:

Recently Sonic Speed Simulator released a gamepad support update to improve overall experience for players on console and for those who prefer to use gamepads even on other platforms.
However, a very strange bug was reported by mobile players using gamepads.

The Bug:

We use UIS:GetSupportedGamepadKeyCodes() to confirm whether the player can actually use the keycodes (and we dynamically show or hide keycode hints) but on mobile, the method errors:

Reproduction Steps:

  1. Open the reproduction file OR make your own place and use UserInputService:GetSupportedGamepadKeyCodes() when a gamepad is connected
  2. Publish the place
  3. Connect a gamepad to a mobile device
  4. Open the place on the Roblox app on your mobile device
  5. Try to move using the gamepad
  6. Open Dev console and see the error

NOTE 1: Interchanging steps 3 and 4 does not seem to affect the outcome.
NOTE 2: The bug seems to occur very frequently but not at all times.
NOTE 3: UserInputService.GamepadEnabled is true

Reproduction File:

InvalidEnumError.rbxl (54.1 KB)

Hardware used:

  1. I used an XBox Controller for testing.
  2. The issue occurs on both. Android and iOS mobile devices.

Expected behavior

The method should return an array of supported gamepad keycodes OR an empty array if the gamepad is not connected.