moonlight-stream / moonlight-qt

GameStream client for PCs (Windows, Mac, Linux, and Steam Link)
GNU General Public License v3.0
11k stars 640 forks source link

Client mouse cursor will occasionally appear above server cursor on remote desktop mode on macOS #897

Open gnattu opened 2 years ago

gnattu commented 2 years ago

Describe the bug When set the mouse cursor to remote desktop mouse mode, the client cursor will very occasionally appear above the server cursor, just like when you toggled ctrl+alt+shift+c, but when this is the case, you have to input ctrl+alt+shift+c twice to hide the cursor again.

Steps to reproduce It is very hard to reproduce this and I have not find any reliable way to reproduce this, sorry. I can only tell that randomly moving the cursor on the screen will trigger this bug by chance.

Screenshots It is hard to take screenshots for the double cursor, but it looks exactly the same when you toggled ctrl+alt+shift+c

Affected games Desktop

Other Moonlight clients Only tested macOS so far.

Moonlight settings (please complete the following information) Just check optimize mouse for remote desktop instead of games

Client PC details (please complete the following information)

Server PC details (please complete the following information)

Moonlight Logs (please attach)

Found "ModeSeven.ttf" at ":/data/ModeSeven.ttf"
Server GPU: "NVIDIA RTX A4000"
Server GFE version: "3.25.5.9"
2022-11-14 16:37:12.976 Moonlight[97059:2271579] INFO: Video bitrate: 45000 kbps
2022-11-14 16:37:13.121 Moonlight[97059:2271579] INFO: Desired audio buffer: 480 samples (1920 bytes)
2022-11-14 16:37:13.121 Moonlight[97059:2271579] INFO: Obtained audio buffer: 480 samples (1920 bytes)
2022-11-14 16:37:13.231 Moonlight[97059:2271579] INFO: Audio channel count: 2
2022-11-14 16:37:13.231 Moonlight[97059:2271579] INFO: Audio channel mask: 3
2022-11-14 16:37:13.231 Moonlight[97059:2271579] INFO: V-sync disabled
2022-11-14 16:37:13.231 Moonlight[97059:2271579] INFO: Using VideoToolbox accelerated renderer
[hevc @ 0x111f832d0] nal_unit_type: 32(VPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x111f832d0] nal_unit_type: 33(SPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x111f832d0] nal_unit_type: 34(PPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x111f832d0] nal_unit_type: 21(CRA_NUT), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x111f832d0] Decoding VPS
[hevc @ 0x111f832d0] Main profile bitstream
[hevc @ 0x111f832d0] Decoding SPS
[hevc @ 0x111f832d0] Main profile bitstream
[hevc @ 0x111f832d0] Decoding VUI
[hevc @ 0x111f832d0] Decoding PPS
[hevc @ 0x111f832d0] Format videotoolbox_vld chosen by get_format().
[hevc @ 0x111f832d0] Format videotoolbox_vld requires hwaccel initialisation.
[hevc @ 0x111f832d0] Output frame with POC 3.
2022-11-14 16:37:13.239 Moonlight[97059:2271579] INFO: FFmpeg-based video decoder chosen
2022-11-14 16:37:13.276 Moonlight[97059:2271579] INFO: Desired audio buffer: 480 samples (1920 bytes)
2022-11-14 16:37:13.276 Moonlight[97059:2271579] INFO: Obtained audio buffer: 480 samples (1920 bytes)
Found "gamecontrollerdb.txt" at "/Users/gnattu/Library/Caches/Moonlight Game Streaming Project/Moonlight/gamecontrollerdb.txt"
2022-11-14 16:37:13.397 Moonlight[97059:2271579] INFO: Loaded 108 new gamepad mappings
2022-11-14 16:37:13.397 Moonlight[97059:2271579] INFO: V-sync disabled
2022-11-14 16:37:13.398 Moonlight[97059:2271579] INFO: Using VideoToolbox accelerated renderer
[hevc @ 0x116ef8550] nal_unit_type: 32(VPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x116ef8550] nal_unit_type: 33(SPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x116ef8550] nal_unit_type: 34(PPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x116ef8550] nal_unit_type: 21(CRA_NUT), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x116ef8550] Decoding VPS
[hevc @ 0x116ef8550] Main profile bitstream
[hevc @ 0x116ef8550] Decoding SPS
[hevc @ 0x116ef8550] Main profile bitstream
[hevc @ 0x116ef8550] Decoding VUI
[hevc @ 0x116ef8550] Decoding PPS
[hevc @ 0x116ef8550] Format videotoolbox_vld chosen by get_format().
[hevc @ 0x116ef8550] Format videotoolbox_vld requires hwaccel initialisation.
[hevc @ 0x116ef8550] Output frame with POC 3.
2022-11-14 16:37:13.406 Moonlight[97059:2271579] INFO: FFmpeg-based video decoder chosen
Found "gamecontrollerdb.txt" at "/Users/gnattu/Library/Caches/Moonlight Game Streaming Project/Moonlight/gamecontrollerdb.txt"
2022-11-14 16:37:13.414 Moonlight[97059:2271579] INFO: Loaded 108 new gamepad mappings
Executing request: "https://192.168.123.122:47984/launch?uniqueid=0123456789ABCDEF&uuid=5f14ebae2be342e19fce06c6b2a3f5da&appid=16036336&mode=3024x1964x60&additionalStates=1&sops=0&rikey=0fc3fa364b90b30d5977240bbbf6fdc3&rikeyid=-1675932698&localAudioPlayMode=0&surroundAudioInfo=196610&remoteControllersBitmap=0&gcmap=0"
Launch response: "<?xml version=\"1.0\" encoding=\"UTF-16\"?><root protocol_version=\"0.1\" query=\"launch\" status_code=\"200\" status_message=\"OK\"><DisplayHeight>720</DisplayHeight><DisplayWidth>1280</DisplayWidth><EnhancedStreamMode>1</EnhancedStreamMode><HdrMode>0</HdrMode><RefreshRate>60</RefreshRate><avkey>ok</avkey><gamesession>4a7b2a346b8a2d3823452fd1baa88cc8</gamesession><rikey>ok</rikey><sessionUrl0>rtsp://192.168.123.122:48010</sessionUrl0><wssignaling>0</wssignaling></root>"
Found matching interface: "en10" "64:4B:F0:01:97:DD" QFlags<QNetworkInterface::InterfaceFlag>(IsUp|IsRunning|CanBroadcast|CanMulticast)
Interface Type: QNetworkInterface::Ethernet
Interface MTU: 1500
2022-11-14 16:37:18.223 Moonlight[97059:2271962] INFO: RTSP port: 48010
2022-11-14 16:37:18.223 Moonlight[97059:2271962] INFO: Initializing platform...
2022-11-14 16:37:18.223 Moonlight[97059:2271962] INFO: done
2022-11-14 16:37:18.223 Moonlight[97059:2271962] INFO: Resolving host name...
2022-11-14 16:37:18.224 Moonlight[97059:2271962] INFO: done
2022-11-14 16:37:18.224 Moonlight[97059:2271962] INFO: Initializing audio stream...
2022-11-14 16:37:18.224 Moonlight[97059:2271962] INFO: Selected receive buffer size: 65536
2022-11-14 16:37:18.224 Moonlight[97059:2271962] INFO: done
2022-11-14 16:37:18.224 Moonlight[97059:2271962] INFO: Starting RTSP handshake...
2022-11-14 16:37:18.334 Moonlight[97059:2271962] INFO: Audio port: 48000
2022-11-14 16:37:18.353 Moonlight[97059:2271962] INFO: Video port: 47998
2022-11-14 16:37:18.374 Moonlight[97059:2271962] INFO: Control port: 47999
2022-11-14 16:37:19.096 Moonlight[97059:2271962] INFO: done
2022-11-14 16:37:19.096 Moonlight[97059:2271962] INFO: Initializing control stream...
2022-11-14 16:37:19.096 Moonlight[97059:2271962] INFO: done
2022-11-14 16:37:19.096 Moonlight[97059:2271962] INFO: Initializing video stream...
2022-11-14 16:37:19.100 Moonlight[97059:2271962] INFO: done
2022-11-14 16:37:19.100 Moonlight[97059:2271962] INFO: Initializing input stream...
2022-11-14 16:37:19.100 Moonlight[97059:2271962] INFO: done
2022-11-14 16:37:19.100 Moonlight[97059:2271962] INFO: Starting control stream...
2022-11-14 16:37:19.107 Moonlight[97059:2271962] INFO: done
2022-11-14 16:37:19.107 Moonlight[97059:2271962] INFO: Starting video stream...
2022-11-14 16:37:19.107 Moonlight[97059:2271962] INFO: Video stream is 3024x1964x60 (format 0x100)
2022-11-14 16:37:19.108 Moonlight[97059:2271962] INFO: Selected receive buffer size: 524288
2022-11-14 16:37:19.108 Moonlight[97059:2271962] INFO: done
2022-11-14 16:37:19.108 Moonlight[97059:2271962] INFO: Starting audio stream...
2022-11-14 16:37:19.142 Moonlight[97059:2272007] INFO: Received first video packet after 0 ms
2022-11-14 16:37:19.170 Moonlight[97059:2271962] INFO: Desired audio buffer: 480 samples (1920 bytes)
2022-11-14 16:37:19.170 Moonlight[97059:2271962] INFO: Obtained audio buffer: 480 samples (1920 bytes)
2022-11-14 16:37:19.170 Moonlight[97059:2271962] INFO: Audio stream has 2 channels
2022-11-14 16:37:19.170 Moonlight[97059:2271962] INFO: done
2022-11-14 16:37:19.170 Moonlight[97059:2271962] INFO: Starting input stream...
2022-11-14 16:37:19.170 Moonlight[97059:2272050] INFO: Received first audio packet after 0 ms
2022-11-14 16:37:19.170 Moonlight[97059:2272050] INFO: Initial audio resync period: 800 milliseconds
2022-11-14 16:37:19.170 Moonlight[97059:2271962] INFO: done
2022-11-14 16:37:19.197 Moonlight[97059:2271579] INFO: Qt UI screen is at (1920,98)
2022-11-14 16:37:19.197 Moonlight[97059:2271579] INFO: SDL found matching display 1
2022-11-14 16:37:19.217 Moonlight[97059:2271579] INFO: Found display mode with desktop resolution: 3024x1964x120
2022-11-14 16:37:19.217 Moonlight[97059:2271579] INFO: Found display mode with desktop resolution: 3024x1964x60
2022-11-14 16:37:19.399 Moonlight[97059:2272007] INFO: Video decode unit queue overflow
2022-11-14 16:37:19.399 Moonlight[97059:2272005] INFO: IDR frame request sent
2022-11-14 16:37:19.417 Moonlight[97059:2272007] INFO: Waiting for IDR frame
2022-11-14 16:37:19.707 Moonlight[97059:2272007] INFO: Video decode unit queue overflow
2022-11-14 16:37:19.708 Moonlight[97059:2272005] INFO: IDR frame request sent
2022-11-14 16:37:19.724 Moonlight[97059:2272007] INFO: Waiting for IDR frame
2022-11-14 16:37:19.832 Moonlight[97059:2271579] INFO: Recreating renderer for window event: 1 (0 0)
2022-11-14 16:37:19.832 Moonlight[97059:2271579] INFO: V-sync enabled
2022-11-14 16:37:19.832 Moonlight[97059:2271579] INFO: NSWindow on display: 1
2022-11-14 16:37:19.832 Moonlight[97059:2271579] INFO: Using VideoToolbox accelerated renderer
[hevc @ 0x14b507760] nal_unit_type: 32(VPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x14b507760] nal_unit_type: 33(SPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x14b507760] nal_unit_type: 34(PPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x14b507760] nal_unit_type: 21(CRA_NUT), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x14b507760] Decoding VPS
[hevc @ 0x14b507760] Main profile bitstream
[hevc @ 0x14b507760] Decoding SPS
[hevc @ 0x14b507760] Main profile bitstream
[hevc @ 0x14b507760] Decoding VUI
[hevc @ 0x14b507760] Decoding PPS
[hevc @ 0x14b507760] Format videotoolbox_vld chosen by get_format().
[hevc @ 0x14b507760] Format videotoolbox_vld requires hwaccel initialisation.
[hevc @ 0x14b507760] Output frame with POC 3.
2022-11-14 16:37:19.842 Moonlight[97059:2271579] INFO: NSWindow on display: 1
2022-11-14 16:37:19.842 Moonlight[97059:2271579] INFO: Frame pacing active: target 120 Hz with 60 FPS stream
2022-11-14 16:37:19.842 Moonlight[97059:2271579] INFO: Using VideoToolbox accelerated renderer
2022-11-14 16:37:19.842 Moonlight[97059:2271579] INFO: FFmpeg-based video decoder chosen
2022-11-14 16:37:19.842 Moonlight[97059:2271579] INFO: Dropping window event during flush: 6 (1512 945)
[hevc @ 0x1330d2630] nal_unit_type: 32(VPS), nuh_layer_id: 0, temporal_id: 0
2022-11-14 16:37:19.843 Moonlight[97059:2272005] INFO: IDR frame request sent
[hevc @ 0x1330d2630] nal_unit_type: 33(SPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x1330d2630] nal_unit_type: 34(PPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x1330d2630] nal_unit_type: 19(IDR_W_RADL), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x1330d2630] Decoding VPS
[hevc @ 0x1330d2630] Main profile bitstream
[hevc @ 0x1330d2630] Decoding SPS
[hevc @ 0x1330d2630] Main profile bitstream
[hevc @ 0x1330d2630] Decoding VUI
[hevc @ 0x1330d2630] Decoding PPS
[hevc @ 0x1330d2630] Format videotoolbox_vld chosen by get_format().
[hevc @ 0x1330d2630] Format videotoolbox_vld requires hwaccel initialisation.
[hevc @ 0x1330d2630] Output frame with POC 0.
2022-11-14 16:37:20.297 Moonlight[97059:2272007] INFO: Leaving speculative RFI mode after OOS video data at frame 77
2022-11-14 16:37:37.254 Moonlight[97059:2272007] INFO: Recovered 1 video data shards from frame 1033
2022-11-14 16:38:31.638 Moonlight[97059:2271579] INFO: Detected type clipboard text combo
2022-11-14 16:38:31.638 Moonlight[97059:2271579] INFO: Raising 3 keys
2022-11-14 16:39:14.470 Moonlight[97059:2272007] INFO: Recovered 1 video data shards from frame 6629
2022-11-14 16:41:05.381 Moonlight[97059:2272007] INFO: Recovered 1 video data shards from frame 13090
2022-11-14 16:41:08.858 Moonlight[97059:2272007] INFO: Recovered 1 video data shards from frame 13293
2022-11-14 16:41:15.681 Moonlight[97059:2272007] INFO: Recovered 1 video data shards from frame 13684
2022-11-14 16:41:28.409 Moonlight[97059:2272007] INFO: Recovered 1 video data shards from frame 14405
2022-11-14 16:41:47.723 Moonlight[97059:2271579] INFO: Detected type clipboard text combo
2022-11-14 16:41:47.723 Moonlight[97059:2271579] INFO: Raising 3 keys
2022-11-14 16:42:08.359 Moonlight[97059:2272007] INFO: Recovered 1 video data shards from frame 16697
2022-11-14 16:43:00.812 Moonlight[97059:2272007] INFO: Recovered 1 video data shards from frame 19726
2022-11-14 16:43:26.485 Moonlight[97059:2272007] INFO: Recovered 1 video data shards from frame 21227
2022-11-14 16:43:41.681 Moonlight[97059:2272007] INFO: Recovered 1 video data shards from frame 22092
2022-11-14 16:44:10.799 Moonlight[97059:2272007] INFO: Recovered 1 video data shards from frame 23765
2022-11-14 16:44:16.547 Moonlight[97059:2272007] INFO: Recovered 1 video data shards from frame 24094
2022-11-14 16:44:22.383 Moonlight[97059:2272007] INFO: Recovered 1 video data shards from frame 24427
2022-11-14 16:45:18.125 Moonlight[97059:2272007] INFO: Recovered 1 video data shards from frame 27655
2022-11-14 16:45:57.897 Moonlight[97059:2272050] INFO: Recovered 1 audio data shards from block 38348
2022-11-14 16:45:57.897 Moonlight[97059:2272050] INFO: Leaving fast audio recovery mode after OOS audio data (38351 < 38352)
2022-11-14 16:46:05.292 Moonlight[97059:2272007] INFO: Recovered 1 video data shards from frame 30424
2022-11-14 16:46:06.707 Moonlight[97059:2272007] INFO: Recovered 1 video data shards from frame 30507
2022-11-14 16:48:13.642 Moonlight[97059:2272007] INFO: Recovered 1 video data shards from frame 37856
2022-11-14 16:48:41.749 Moonlight[97059:2272050] INFO: Entering fast audio recovery mode after sequenced audio data

The rest just spamming with data shards recovery

Additional context

I suspect this is an upstream SDL bug because I tried to force an SDL_Event to be pushed on each cursor position change and SDL_ShowCursor(SDL_DISABLE); triggered by those events will not hide the cursor again, but if I do

SDL_ShowCursor(SDL_ENABLE);
SDL_ShowCursor(SDL_DISABLE);

In a sequence in the event handler, I have not see such weird behaviors for hours of use now.

So for now my workaround to this tricky bug:

case SDL_CODE_HIDE_CURSOR:
    if (SDL_ShowCursor(SDL_QUERY) == SDL_ENABLE) {
      SDL_ShowCursor(SDL_DISABLE);
    } else {
      SDL_ShowCursor(SDL_ENABLE);
      SDL_ShowCursor(SDL_DISABLE);
    }
    break;

The workaround above is dirty and breaks persistent client cursor mode, so may I ask is there any cleaner workarounds we can use ? I don't really want to compile from source for each release but current workaround is clearly not mergeable.

cgutman commented 2 years ago

This should probably be reported upstream to SDL. Are you able to reproduce the issue with any of the SDL test apps?

HenryLoenwind commented 2 years ago

Does this happen when a macOS toast is displayed? Those force-show the mouse cursor in plenty of apps for me.

oxkenshin commented 1 year ago

Reproduce steps:

  1. Set display mode to "borderless windowed (Recommended)"
  2. Toggle on "Optimize mouse for remote desktop instead of games"
  3. Connect to remote, and move mouse to the top menu, then move back.