moonlight-stream / moonlight-android

GameStream client for Android
GNU General Public License v3.0
3.94k stars 621 forks source link

[Issue]: Unable to start streaming on devices with multiple HAL resolution and unlocked config_maxUiWidth #1398

Open dantmnf opened 1 month ago

dantmnf commented 1 month ago

Describe the bug

By saying HAL resolution, I mean that can be found in dumpsys display:

    mSupportedModes=
      DisplayModeRecord{mMode={id=1, width=1096, height=2560, fps=60.000004, alternativeRefreshRates=[120.00001], supportedHdrTypes=[2, 3]}}
      DisplayModeRecord{mMode={id=2, width=1096, height=2560, fps=120.00001, alternativeRefreshRates=[60.000004], supportedHdrTypes=[2, 3]}}
      DisplayModeRecord{mMode={id=3, width=1644, height=3840, fps=60.000004, alternativeRefreshRates=[120.00001], supportedHdrTypes=[2, 3]}}
      DisplayModeRecord{mMode={id=4, width=1644, height=3840, fps=120.00001, alternativeRefreshRates=[60.000004], supportedHdrTypes=[2, 3]}}

The user can choose which resolution to use in Settings: https://pixel.gadgethacks.com/how-to/change-screen-resolution-your-google-pixel-pro-and-why-you-should-0385339/

With the lower resolution (1644x3840), Moonlight will not start streaming, it returns to the game list after a few display glitches (likely display mode change).

With the higher resolution, everything is OK.

Logcat supposes that the change of UI resolution invalidated the surface used for streaming. With config_maxUiWidth locked to 1096 (in stock ROM), changing the display mode won't change UI resolution.

Steps to reproduce

  1. Use a device with multiple HAL resolutions and unlocked config_maxUiWidth (in this case, a Sony Xperia 1 V with system mods. Maybe also Pixel?)
  2. Start Moonlight with the smaller display resolution
  3. Start streaming with a large enough streaming resolution (e.g. 3840x2160)

Affected games

Desktop

Other Moonlight clients

PC

Moonlight adjusted settings

Yes

Moonlight adjusted settings (please complete the following information)

Video resolution: 4K (not reproducible on 1080p) Allow refresh rate reduction: tried both on and off

Moonlight default settings

Yes

Gamepad-related connection issue

No

Gamepad-related input issue

No

Gamepad-related streaming issue

No

Android version

Android 14

Device model

Sony Xperia 1 V

Server PC OS version

Windows 11 23H2

Server PC GeForce Experience version

Sunshine 0.23.1

Server PC Nvidia GPU driver version

555.99

Server PC antivirus and firewall software

No

Screenshots

No response

Relevant log output

07-22 19:40:36.859  7824  7824 I com.limelight.LimeLog: Current display mode: 1096x2560x120.00001
07-22 19:40:36.859  7824  7824 I com.limelight.LimeLog: Examining display mode: 1096x2560x120.00001
07-22 19:40:36.859  7824  7824 I com.limelight.LimeLog: Examining display mode: 1096x2560x60.000004
07-22 19:40:36.859  7824  7824 I com.limelight.LimeLog: Examining display mode: 1644x3840x60.000004
07-22 19:40:36.859  7824  7824 I com.limelight.LimeLog: Examining display mode: 1644x3840x120.00001
07-22 19:40:36.859  7824  7824 I com.limelight.LimeLog: Best display mode: 1644x3840x120.00001
07-22 19:40:36.859  7824  7824 I com.limelight.LimeLog: Display refresh rate: 120.00001
...
07-22 19:40:37.458  2145  3633 D LocalDisplayAdapter: The active mode was changed from SurfaceFlinger or the display device to {id=4, width=1644, height=3840, fps=120.00001, alternativeRefreshRates=[60.000004], supportedHdrTypes=[2, 3]}
...
07-22 19:40:37.531  7824  7824 I com.limelight.LimeLog: Current display mode: 1644x3840x120.00001
07-22 19:40:37.531  7824  7824 I com.limelight.LimeLog: Examining display mode: 1644x3840x120.00001
07-22 19:40:37.531  7824  7824 I com.limelight.LimeLog: Examining display mode: 1644x3840x60.000004
07-22 19:40:37.531  7824  7824 I com.limelight.LimeLog: Examining display mode: 1096x2560x60.000004
07-22 19:40:37.531  7824  7824 I com.limelight.LimeLog: Examining display mode: 1096x2560x120.00001
07-22 19:40:37.531  7824  7824 I com.limelight.LimeLog: Best display mode: 1644x3840x120.00001
07-22 19:40:37.531  7824  7824 I com.limelight.LimeLog: Current display mode is already the best display mode
07-22 19:40:37.531  7824  7824 I com.limelight.LimeLog: Display refresh rate: 120.00001
...
07-22 19:40:38.222  7824 13056 I com.limelight.LimeLog: Configuring with format: {max-height=2160, max-width=3840, low-latency=1, mime=video/hevc, width=3840, color-range=1, frame-rate=60, height=2160}
07-22 19:40:38.222  7824 13127 I com.limelight.LimeLog: Art scaling divisor: 1.0
07-22 19:40:38.222  7824 13056 W System.err: java.lang.IllegalArgumentException: The surface has been released
07-22 19:40:38.222  7824 13056 W System.err:    at android.media.MediaCodec.native_configure(Native Method)
07-22 19:40:38.222  7824 13056 W System.err:    at android.media.MediaCodec.configure(MediaCodec.java:2332)
07-22 19:40:38.222  7824 13056 W System.err:    at android.media.MediaCodec.configure(MediaCodec.java:2248)
07-22 19:40:38.222  7824 13056 W System.err:    at com.limelight.binding.video.MediaCodecDecoderRenderer.configureAndStartDecoder(Unknown Source:165)
07-22 19:40:38.222  7824 13056 W System.err:    at com.limelight.binding.video.MediaCodecDecoderRenderer.tryConfigureDecoder(Unknown Source:11)
07-22 19:40:38.222  7824 13056 W System.err:    at com.limelight.binding.video.MediaCodecDecoderRenderer.initializeDecoder(Unknown Source:292)
07-22 19:40:38.222  7824 13056 W System.err:    at com.limelight.binding.video.MediaCodecDecoderRenderer.setup(Unknown Source:9)
07-22 19:40:38.222  7824 13056 W System.err:    at com.limelight.nvstream.jni.MoonBridge.bridgeDrSetup(Unknown Source:4)
07-22 19:40:38.222  7824 13056 W System.err:    at com.limelight.nvstream.jni.MoonBridge.startConnection(Native Method)
07-22 19:40:38.222  7824 13056 W System.err:    at com.limelight.nvstream.NvConnection$1.run(Unknown Source:318)
07-22 19:40:38.222  7824 13056 W System.err:    at java.lang.Thread.run(Thread.java:1012)

Additional context

System mods used:

ClassicOldSong commented 1 month ago

You can try my fork here, enable "Enforce refresh rate settings" and see if it helps:

https://github.com/ClassicOldSong/moonlight-android/releases

The fix introduced by this option might be related.