moonlight-android icon indicating copy to clipboard operation
moonlight-android copied to clipboard

[Issue]: Inputs freeze intermittently with a Bluetooth controller connected to the phone while streaming (sunshine host)

Open RadarNyan opened this issue 1 year ago • 9 comments

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

  1. 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.
  2. Play a video on the PC as a reference for video/audio streaming status.
  3. 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.
  4. 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.
  5. However, during the streaming, input would freeze randomly and then recover after a few seconds, which is very annoying.
  6. 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.
  7. 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

Screenshot_2024-07-18-16-05-46-544-edit_com f0x1d logfox

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.

RadarNyan avatar Jul 18 '24 01:07 RadarNyan

image

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.

RadarNyan avatar Jul 18 '24 11:07 RadarNyan

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.

ClassicOldSong avatar Jul 18 '24 11:07 ClassicOldSong

Dupe https://github.com/moonlight-stream/moonlight-android/issues/1389

ClassicOldSong avatar Jul 18 '24 11:07 ClassicOldSong

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.

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.

RadarNyan avatar Jul 18 '24 11:07 RadarNyan

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.

RadarNyan avatar Jul 18 '24 12:07 RadarNyan

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...

ClassicOldSong avatar Jul 18 '24 12:07 ClassicOldSong

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.

RadarNyan avatar Jul 18 '24 12:07 RadarNyan

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.

pgomezi avatar Sep 09 '24 04:09 pgomezi

Exact same issue using the Nvidia Shield and after controlling the cursor using the Shield app on an android device.

JesterForPirate avatar Sep 12 '24 20:09 JesterForPirate