moonlight-stream / moonlight-qt

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

Bad HiDPI scaling on macOS client #1185

Open hdonquichotte opened 6 months ago

hdonquichotte commented 6 months ago

Describe the bug Moonlight macOS client applies incorrect scaling to the stream window on any macOS scaled HiDPI resolution, resulting in blurry details

Steps to reproduce

Results: blurry text and details. Same results if the resolutions of both Moonlight and the host PC are set to the scaled resolution (1680x1050) instead of the native panel resolution

The only way to get an unaltered video stream is :

Results: everything looks nice and sharp

However nobody uses unscaled resolutions on Retina displays, thus, the macOS resolution must be changed each time Moonlight is used to preserve video quality, and then reverted back.

Idea: launching the Moonlight client in low resolution mode may fix this (NSHighResolutionCapable set to false in Info.plist). However, I could not test it because editing the Info.plist results in Sunshine error: "server certificate mismatch error 401"

Affected games Any video stream including Desktop

Other Moonlight clients Does not occur on Windows nor Android.

Moonlight settings (please complete the following information)

Client PC details (please complete the following information)

cgutman commented 6 months ago

Please test with the latest nightly: https://ci.appveyor.com/project/cgutman/moonlight-qt/builds/49211978/job/2exqqybbsko35tww/artifacts

The macOS renderer has been rewritten since v5.0.1.

hdonquichotte commented 6 months ago

Please test with the latest nightly: https://ci.appveyor.com/project/cgutman/moonlight-qt/builds/49211978/job/2exqqybbsko35tww/artifacts

The macOS renderer has been rewritten since v5.0.1.

Hi, thanks, I just tested your build. Results are the exact same.

Note : I was only able to get a video stream with software decoding. With hardware decoding, the video stream opens but I get a black screen. The stats overlay does not show either. Sound seems to get through though.

cgutman commented 6 months ago

Note : I was only able to get a video stream with software decoding. With hardware decoding, the video stream opens but I get a black screen. The stats overlay does not show either. Sound seems to get through though.

Ok, please post your Moonlight logs from the /tmp directory on your Mac with hardware decoding.

Please also post a screenshot of the improperly scaled output. FWIW, I'm seeing good scaling here when testing 1080p on host and Moonlight client on my M2 MacBook Pro. It looks pixel-perfect to my eye.

Are you seeing bad scaling with both windowed and borderless windowed modes?

hdonquichotte commented 6 months ago

Are you seeing bad scaling with both windowed and borderless windowed modes?

Yes it happens with both.

With further testing I think the problem happens only with non-integer scaling res on the client.

Here are the screenshots. Not sure it will be helpful because at scaled resolutions, macOS generates a screenshot that is 2x the size of the scaled res, so all the PNGs are not of the same size to compare. But I can confirm it is very noticeable. Notice that even the stats overlay seems to be of the same font size on native and 2x but of a different size at a the non-integer scaled res.

2880x1800native_non-scaled_borderless (pixel perfect) :

2880x1800native_non-scaled_borderless

1680x1050default_scaled_borderless (blurry) :

1680x1050default_scaled_borderless

1440x900_scaled_borderless (pixel perfect) :

1440x900_scaled_borderless

Here are the logs with hardware decoding (black video stream) : 00:00:00 - SDL Info (0): Compiled with SDL 2.31.0 00:00:00 - SDL Info (0): Running with SDL 2.31.0 00:00:00 - Qt Info: Successfully loaded translation for "fr_FR" 00:00:01 - Qt Warning: Populating font family aliases took 300 ms. Replace uses of missing font family "Roboto" with one that exists to avoid this cost. 00:00:01 - Qt Warning: qrc:/gui/main.qml:13:1: QML ApplicationWindow: ToolTip must be attached to an Item 00:00:01 - Qt Info: Found "gamecontrollerdb.txt" at "/Users/zt/Library/Caches/Moonlight Game Streaming Project/Moonlight/gamecontrollerdb.txt" 00:00:01 - SDL Info (0): Loaded 132 new gamepad mappings 00:00:01 - SDL Info (0): V-sync disabled 00:00:01 - Qt Info: Found "vt_renderer.metal" at ":/data/vt_renderer.metal" 00:00:01 - SDL Info (0): Using VideoToolbox Metal renderer 00:00:01 - FFmpeg: [hevc @ 0x7fa883fcd5c0] nal_unit_type: 32(VPS), nuh_layer_id: 0, temporal_id: 0 00:00:01 - FFmpeg: [hevc @ 0x7fa883fcd5c0] nal_unit_type: 33(SPS), nuh_layer_id: 0, temporal_id: 0 00:00:01 - FFmpeg: [hevc @ 0x7fa883fcd5c0] nal_unit_type: 34(PPS), nuh_layer_id: 0, temporal_id: 0 00:00:01 - FFmpeg: [hevc @ 0x7fa883fcd5c0] nal_unit_type: 21(CRA_NUT), nuh_layer_id: 0, temporal_id: 0 00:00:01 - FFmpeg: [hevc @ 0x7fa883fcd5c0] nal_unit_type: 21(CRA_NUT), nuh_layer_id: 0, temporal_id: 0 00:00:01 - FFmpeg: [hevc @ 0x7fa883fcd5c0] nal_unit_type: 21(CRA_NUT), nuh_layer_id: 0, temporal_id: 0 00:00:01 - FFmpeg: [hevc @ 0x7fa883fcd5c0] nal_unit_type: 21(CRA_NUT), nuh_layer_id: 0, temporal_id: 0 00:00:01 - FFmpeg: [hevc @ 0x7fa883fcd5c0] Decoding VPS 00:00:01 - FFmpeg: [hevc @ 0x7fa883fcd5c0] Main 10 profile bitstream 00:00:01 - FFmpeg: [hevc @ 0x7fa883fcd5c0] Decoding SPS 00:00:01 - FFmpeg: [hevc @ 0x7fa883fcd5c0] Main 10 profile bitstream 00:00:01 - FFmpeg: [hevc @ 0x7fa883fcd5c0] Decoding VUI 00:00:01 - FFmpeg: [hevc @ 0x7fa883fcd5c0] Decoding PPS 00:00:01 - FFmpeg: [hevc @ 0x7fa883fcd5c0] Format videotoolbox_vld chosen by get_format(). 00:00:01 - FFmpeg: [hevc @ 0x7fa883fcd5c0] Format videotoolbox_vld requires hwaccel initialisation. 00:00:01 - FFmpeg: [hevc @ 0x7fa883fcd5c0] Output frame with POC 3. 00:00:01 - SDL Info (0): FFmpeg-based video decoder chosen 00:00:01 - Qt Info: Found "gamecontrollerdb.txt" at "/Users/zt/Library/Caches/Moonlight Game Streaming Project/Moonlight/gamecontrollerdb.txt" 00:00:01 - SDL Info (0): Loaded 132 new gamepad mappings 00:00:01 - Qt Debug: Current Moonlight version: "5.0.1" 00:00:01 - Qt Info: "PC-zt" is now online at "192.168.1.10:47989" 00:00:02 - Qt Info: Discovered mDNS host: "PC-zt.local." 00:00:02 - Qt Info: Resolved "PC-zt.local." to QHostAddress("192.168.1.10") 00:00:02 - Qt Info: Resolved "PC-zt.local." to QHostAddress(« ab12::3ab3:ebaf:456a:2fd5) 00:00:04 - Qt Info: Processing new PC at "192.168.1.10:47989" from mDNS with IPv6 address "<NULL>" 00:00:04 - Qt Info: Executing request: "http://192.168.1.10:47989/serverinfo?uniqueid=0123456789ABCDEF&uuid=6178d351f24b5730850ef57e7034fca5" 00:00:04 - Qt Info: Executing request: "https://192.168.1.10:47984/serverinfo?uniqueid=0123456789ABCDEF&uuid=1ceb159669074b64a6bf34402f41d57b" 00:00:04 - Qt Info: Gamepad mappings are up to date 00:00:04 - Qt Debug: Found update manifest match for current platform 00:00:04 - Qt Debug: Latest version of Moonlight for this platform is: "5.0.1" 00:00:04 - Qt Debug: Update manifest version equal to current version 00:00:04 - Qt Info: Latest supported GFE server: "99.99.99.99"

Foul-Tarnished commented 5 months ago

seems normaly non-integer get blurry afaik ? then only bicubic/billinear filtering can somewhat help.

Thank god half res is pixel perfect (desktop windowed res) because macos fullscreen res it really high (2234p on m3 16")

with https://github.com/itsmikethetech/Virtual-Display-Driver it works well at least, as you can make the same res as your client

Foul-Tarnished commented 5 months ago

I wanted to try half res (LowDPI) but I couldn't because it's an odd number (half res is 1728x1117p, on 3456x2234p full res)

I was able to test LowDPI with a 16:9 aspect ratio (macbook are 16:10), so 1728x972p (full 16:9 res would be 3456x1944) But it's really blurry, and text looks really bad (worse than in any screenshot)

AFAIK, Moonlight should do some "integer scaling"/nearest neighbor upscaling for this scenario (upscale lower res stream to the max monitor res) like most emulators do

all this on latest nightly in fullscreen mode (notch visible)

Foul-Tarnished commented 5 months ago

https://github.com/moonlight-stream/moonlight-qt/issues/1242

Another issue for MacOS, wonder if it's fixed on the new UI...

TsaiTung-Chen commented 2 months ago

Same here. Image looks blurry if I'm using non-integer scaling on Mac. I've tried the latest v6.0.1 client and it's same.