[Issue]: Inputs freeze intermittently with a Bluetooth controller connected to the phone while streaming (sunshine host)
Describe the bug
Input (phone touchscreen & Xbox controller connected to the phone via Bluetooth) would freeze randomly during streaming, but video/audio are not affected.
Steps to reproduce
- Start streaming with a Bluetooth controller connected to my phone, this would NOT create a virtual controller until I any button on the controller is pressed.
- Play a video on the PC as a reference for video/audio streaming status.
- Move the cursor by using the touch screen constantly, then press any button on the controller. As soon as I press the button, a "device connect" sound can be heard, as now the virtual game pad is connected and all inputs are frozen. Not even the touch screen would move the cursor anymore, while video/audio are not affected at all. I can move the mouse on the PC, so it's not Windows being frozen.
- Wait for a few seconds until the cursor can be moved again by the touchscreen, and then the controller will work with no issue as well.
- However, during the streaming, input would freeze randomly and then recover after a few seconds, which is very annoying.
- I have tried to repeat the above procedure on another laptop (running moonlight-qt) but can't reproduce the issue, which makes me think this might be an Android-specific issue.
- I do not have this "game controller freezes touchscreen" issue with any controller test app I can find, so it's unlikely to be a hardware problem of the phone.
Affected games
All.
Other Moonlight clients
PC
Moonlight adjusted settings
No
Moonlight adjusted settings (please complete the following information)
N/A
Moonlight default settings
Yes
Gamepad-related connection issue
No
Gamepad-related input issue
No
Gamepad-related streaming issue
Yes
Android version
Android 12
Device model
POCO X4 GT (Dimensity 8100)
Server PC OS version
Windows 10 21H2
Server PC GeForce Experience version
N/A
Server PC Nvidia GPU driver version
N/A
Server PC antivirus and firewall software
Windows defaults
Screenshots
No response
Relevant log output
Inputs freeze at the first log (about audio) and resumes at the last (so about 10 seconds.)
Additional context
I managed to find an OTG connector and connected the Xbox controller to the phone via USB, but I failed to reproduce the issue, so it's Bluetooth-specific.
I've tried to play the same games with the Steam Link app, and despite the horrible performance and messy steam input mapping system, I haven't experienced any freezing, so this can't be caused by "hardware limitation due to the antenna wiring" as mentioned in the moonlight-streaming troubleshooting page.
I've been trying to track this down but do not have enough knowledge of Android development to make anything out of it. All I've found is that this problem is caused by some slow binder calls which block the ControllerHandler thread.
You can try my fork that may have solved the issue: ClassicOldSong/moonlight-android/releases
Uncheck Enable battery status report for gamepad in the settings.
Dupe https://github.com/moonlight-stream/moonlight-android/issues/1389
You can try my fork that may have solved the issue: ClassicOldSong/moonlight-android/releases
Uncheck
Enable battery status report for gamepadin the settings.
I just installed your fork and unchecked the option, but the problem persists. All inputs still hang for 10 seconds with the same slow binder log.
Thanks, @ClassicOldSong ! I managed to produce a duct tape fix by commenting out
private final HandlerThread backgroundHandlerThread;
private final Handler backgroundThreadHandler;
And every error lines caused by commenting out the above two lines in ControllerHandler.java, now the problem is gone.
There was a typo in my commit, that option was not actually set... Just pushed a new release, you can try again...
The AI generated string didn't match the actual key of the checkbox...
There was a typo in my commit, that option was not actually set... Just pushed a new release, you can try again...
The AI generated string didn't match the actual key of the checkbox...
Yup, the new upload works.
Thanks so much, @ClassicOldSong! I had been having the exact same issue for a month. Only with bluetooth controller, only on Android client, and server wasn't even Sunshine, just nvidia driver. Input freeze every few minutes for about 15 seconds, with the last inputs remaining stuck. I searched a lot and thought the github would have a newer Android client version than the play store but no, still 12.1, the same as over six months ago. But today thanks to your fork I never had that problem again, and found some nice advanced features as well. Awesome. Glad I found this page.
Exact same issue using the Nvidia Shield and after controlling the cursor using the Shield app on an android device.