Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardware encoders do not work on macOS Ventura #2272

Closed
3 tasks done
VasylBaran opened this issue Mar 15, 2024 · 41 comments · Fixed by #2485
Closed
3 tasks done

Hardware encoders do not work on macOS Ventura #2272

VasylBaran opened this issue Mar 15, 2024 · 41 comments · Fixed by #2485
Labels
os:macOS OS is macOS

Comments

@VasylBaran
Copy link

VasylBaran commented Mar 15, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Is your issue described in the documentation?

  • I have read the documentation

Is your issue present in the nightly release?

  • This issue is present in the nightly release

Describe the Bug

Sunshine fails to use hardware encoders on macOS despite the fact that other applications (e.g. Hanbrake, videoproc) can.
It falls back to default software encoder but it's full of graphical glitches/atrifacts.

Expected Behavior

Hardware encoder should be found and used by Sunshine (on macOS)

Additional Context

I see the following message in logs:
Error: [h264_videotoolbox @ 0x7f9470706140] Error: cannot create compression session: -12902
[h264_videotoolbox @ 0x7f9470706140] Try -allow_sw 1. The hardware encoder may be busy, or not supported.
Error: Could not open codec [h264_videotoolbox]: Generic error in an external library
Info: Encoder [videotoolbox] failed

Host Operating System

macOS Ventura

Operating System Version

13.6.5

Architecture

64 bit

Sunshine commit or version

0.22.1

Package

macOS - brew

GPU Type

AMD

GPU Model

RX 6600

GPU Driver/Mesa Version

n/a

Config

vt_software = allowed

Apps

No response

Relevant log output

[2024:03:15:16:07:26]: Info: Sunshine version: 0.22.1
[2024:03:15:16:07:26]: Info: // Testing for available encoders, this may generate errors. You can safely ignore those errors. //
[2024:03:15:16:07:26]: Info: Trying encoder [videotoolbox]
[2024:03:15:16:07:26]: Info: SDR color coding [Rec. 601]
[2024:03:15:16:07:26]: Info: Color depth: 8-bit
[2024:03:15:16:07:26]: Info: Color range: [JPEG]
[2024:03:15:16:07:27]: Error: [h264_videotoolbox @ 0x7f9471d05480] Error: cannot create compression session: -12902
[2024:03:15:16:07:27]: Error: [h264_videotoolbox @ 0x7f9471d05480] Try -allow_sw 1. The hardware encoder may be busy, or not supported.
[2024:03:15:16:07:27]: Error: Could not open codec [h264_videotoolbox]: Generic error in an external library
[2024:03:15:16:07:27]: Info: SDR color coding [Rec. 601]
[2024:03:15:16:07:27]: Info: Color depth: 8-bit
[2024:03:15:16:07:27]: Info: Color range: [JPEG]
[2024:03:15:16:07:27]: Error: [h264_videotoolbox @ 0x7f9470707900] Error: cannot create compression session: -12902
[2024:03:15:16:07:27]: Error: [h264_videotoolbox @ 0x7f9470707900] Try -allow_sw 1. The hardware encoder may be busy, or not supported.
[2024:03:15:16:07:27]: Error: Could not open codec [h264_videotoolbox]: Generic error in an external library
[2024:03:15:16:07:27]: Info: Encoder [videotoolbox] failed
[2024:03:15:16:07:27]: Info: Trying encoder [software]
[2024:03:15:16:07:27]: Info: SDR color coding [Rec. 601]
[2024:03:15:16:07:27]: Info: Color depth: 8-bit
[2024:03:15:16:07:27]: Info: Color range: [JPEG]
[2024:03:15:16:07:27]: Info: [libx264 @ 0x7f9471f05540] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[2024:03:15:16:07:27]: Info: [libx264 @ 0x7f9471f05540] profile High, level 4.2, 4:2:0, 8-bit
[2024:03:15:16:07:28]: Info: [libx264 @ 0x7f9471f05540] frame I:1     Avg QP:49.35  size:  2486
[2024:03:15:16:07:28]: Info: [libx264 @ 0x7f9471f05540] mb I  I16..4: 98.7%  1.3%  0.0%
[2024:03:15:16:07:28]: Info: [libx264 @ 0x7f9471f05540] 8x8 transform intra:1.3%
[2024:03:15:16:07:28]: Info: [libx264 @ 0x7f9471f05540] coded y,uvDC,uvAC intra: 0.2% 5.1% 0.0%
[2024:03:15:16:07:28]: Info: [libx264 @ 0x7f9471f05540] i16 v,h,dc,p: 79% 17%  4%  0%
[2024:03:15:16:07:28]: Info: [libx264 @ 0x7f9471f05540] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu:  3%  4% 40% 33%  3%  1%  4%  4%  9%
[2024:03:15:16:07:28]: Info: [libx264 @ 0x7f9471f05540] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu:  0%  0% 100%  0%  0%  0%  0%  0%  0%
[2024:03:15:16:07:28]: Info: [libx264 @ 0x7f9471f05540] i8c dc,h,v,p: 94%  5%  0%  0%
[2024:03:15:16:07:28]: Info: [libx264 @ 0x7f9471f05540] kb/s:1193.28
[2024:03:15:16:07:28]: Info: 
[2024:03:15:16:07:28]: Info: // Ignore any errors mentioned above, they are not relevant. //
[2024:03:15:16:07:28]: Info: 
[2024:03:15:16:07:28]: Info: Found H.264 encoder: libx264 [software]
[2024:03:15:16:07:28]: Error: Couldn't find any of the following libraries: [libavahi-common.3.dylib, libavahi-common.dylib]
[2024:03:15:16:07:28]: Info: Configuration UI available at [https://localhost:47990]
[2024:03:15:16:10:26]: Info: // Testing for available encoders, this may generate errors. You can safely ignore those errors. //
[2024:03:15:16:10:26]: Info: Trying encoder [videotoolbox]
[2024:03:15:16:10:26]: Info: SDR color coding [Rec. 601]
[2024:03:15:16:10:26]: Info: Color depth: 8-bit
[2024:03:15:16:10:26]: Info: Color range: [JPEG]
[2024:03:15:16:10:26]: Error: [h264_videotoolbox @ 0x7f9470706140] Error: cannot create compression session: -12902
[2024:03:15:16:10:26]: Error: [h264_videotoolbox @ 0x7f9470706140] Try -allow_sw 1. The hardware encoder may be busy, or not supported.
[2024:03:15:16:10:26]: Error: Could not open codec [h264_videotoolbox]: Generic error in an external library
[2024:03:15:16:10:26]: Info: Encoder [videotoolbox] failed
[2024:03:15:16:10:26]: Info: Trying encoder [software]
[2024:03:15:16:10:26]: Info: SDR color coding [Rec. 601]
[2024:03:15:16:10:26]: Info: Color depth: 8-bit
[2024:03:15:16:10:26]: Info: Color range: [JPEG]
[2024:03:15:16:10:26]: Info: [libx264 @ 0x7f9471b0ea00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[2024:03:15:16:10:26]: Info: [libx264 @ 0x7f9471b0ea00] profile High, level 4.2, 4:2:0, 8-bit
[2024:03:15:16:10:26]: Info: [libx264 @ 0x7f9471b0ea00] frame I:1     Avg QP:49.82  size:  2414
[2024:03:15:16:10:26]: Info: [libx264 @ 0x7f9471b0ea00] mb I  I16..4: 98.7%  1.2%  0.0%
[2024:03:15:16:10:26]: Info: [libx264 @ 0x7f9471b0ea00] 8x8 transform intra:1.2%
[2024:03:15:16:10:26]: Info: [libx264 @ 0x7f9471b0ea00] coded y,uvDC,uvAC intra: 0.2% 4.7% 0.0%
[2024:03:15:16:10:26]: Info: [libx264 @ 0x7f9471b0ea00] i16 v,h,dc,p: 83% 13%  3%  0%
[2024:03:15:16:10:26]: Info: [libx264 @ 0x7f9471b0ea00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu:  8% 14% 31% 27%  2%  1%  2%  3% 11%
[2024:03:15:16:10:26]: Info: [libx264 @ 0x7f9471b0ea00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu:  0%  0% 100%  0%  0%  0%  0%  0%  0%
[2024:03:15:16:10:26]: Info: [libx264 @ 0x7f9471b0ea00] i8c dc,h,v,p: 97%  2%  1%  0%
[2024:03:15:16:10:26]: Info: [libx264 @ 0x7f9471b0ea00] kb/s:1158.72
[2024:03:15:16:10:26]: Info: 
[2024:03:15:16:10:26]: Info: // Ignore any errors mentioned above, they are not relevant. //
[2024:03:15:16:10:26]: Info: 
[2024:03:15:16:10:26]: Info: Found H.264 encoder: libx264 [software]
[2024:03:15:16:10:26]: Info: Executing [Desktop]
[2024:03:15:16:10:26]: Info: CLIENT CONNECTED
[2024:03:15:16:10:26]: Info: SDR color coding [Rec. 601]
[2024:03:15:16:10:26]: Info: Color depth: 8-bit
[2024:03:15:16:10:26]: Info: Color range: [MPEG]
[2024:03:15:16:10:26]: Info: [libx264 @ 0x7f947191b680] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[2024:03:15:16:10:26]: Info: [libx264 @ 0x7f947191b680] profile High, level 4.2, 4:2:0, 8-bit
[2024:03:15:16:10:26]: Error: opening microphone '' failed. Please set a valid input source in the Sunshine config.
[2024:03:15:16:10:26]: Error: Available inputs:
[2024:03:15:16:10:26]: Error: 	PRO X Wireless Gaming Headset
[2024:03:15:16:10:26]: Error: 	HD Pro Webcam C920
[2024:03:15:16:10:26]: Error: Unable to initialize audio capture. The stream will not have audio.
[2024:03:15:16:10:44]: Info: CLIENT DISCONNECTED
[2024:03:15:16:10:44]: Info: [libx264 @ 0x7f947191b680] frame I:3     Avg QP:10.93  size:127457
[2024:03:15:16:10:44]: Info: [libx264 @ 0x7f947191b680] frame P:1022  Avg QP: 2.25  size: 13227
[2024:03:15:16:10:44]: Info: [libx264 @ 0x7f947191b680] mb I  I16..4: 74.8%  8.4% 16.8%
[2024:03:15:16:10:44]: Info: [libx264 @ 0x7f947191b680] mb P  I16..4:  0.5%  0.0%  0.0%  P16..4: 16.8%  0.0%  0.0%  0.0%  0.0%    skip:82.6%
[2024:03:15:16:10:44]: Info: [libx264 @ 0x7f947191b680] 8x8 transform intra:4.0% inter:6.7%
[2024:03:15:16:10:44]: Info: [libx264 @ 0x7f947191b680] coded y,uvDC,uvAC intra: 27.9% 21.7% 19.1% inter: 6.6% 2.1% 2.0%
[2024:03:15:16:10:44]: Info: [libx264 @ 0x7f947191b680] i16 v,h,dc,p: 49% 49%  1%  1%
[2024:03:15:16:10:44]: Info: [libx264 @ 0x7f947191b680] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 10% 35% 20% 11%  2%  3%  2%  8%  9%
[2024:03:15:16:10:44]: Info: [libx264 @ 0x7f947191b680] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 50% 10%  3%  2%  3%  5%  2%  8%
[2024:03:15:16:10:44]: Info: [libx264 @ 0x7f947191b680] i8c dc,h,v,p: 49% 39% 11%  2%
[2024:03:15:16:10:44]: Info: [libx264 @ 0x7f947191b680] Weighted P-Frames: Y:0.0% UV:0.0%
[2024:03:15:16:10:44]: Info: [libx264 @ 0x7f947191b680] kb/s:6509.43
@VasylBaran
Copy link
Author

Screenshot 2024-03-15 at 16 26 10
Screenshot 2024-03-15 at 16 25 49

@VasylBaran
Copy link
Author

VasylBaran commented Mar 15, 2024

Would it be possible to add more encoders supported by Sunshine or to add the ability to explicitly specify what device should be used for encoding. Or do you think it's not really a solution?

@VasylBaran
Copy link
Author

I went with Apple's own "Screen Sharing" for the time being but it would be lovely to have it all in my place (Moonlight) =)

@ReenigneArcher
Copy link
Member

I might be hitting this in #1603 as well. I'm not sure if what I'm seeing is exactly the same though.

https://github.com/LizardByte/Sunshine/actions/runs/8313001334/job/22748528257#step:12:5742

@ReenigneArcher
Copy link
Member

Did you grant screen sharing permission?

@ReenigneArcher ReenigneArcher added the os:macOS OS is macOS label Mar 27, 2024
@VasylBaran
Copy link
Author

screen sharing permission

I did grant screen sharing permission.

And here's a video of the problem I'm having: even with software encoder it fails to properly capture the screen (it looks like the mouse cursor and some other UI elements are "shaking") but in reality (on the actual screen) mouse cursor moves properly. It's just that Sunshine/Moonlight fails to capture/reproduce the image properly

IMG_3580.mp4

@ReenigneArcher ReenigneArcher changed the title Encoders do not work on macOS Ventura Hardware encoders do not work on macOS Ventura Mar 30, 2024
@lulzsun
Copy link

lulzsun commented Apr 26, 2024

I'm getting the exact same issue on macOS Monterey, using Sunshine installed with brew. However, I'll mention that my setup is a little unusual because I am running all this on a virtual machine with GPU (AMD Radeon Pro WX4100) passthrough using QEMU. Games are able to utilize the GPU just fine.

Same log output and same "shaking" or "stuttering" effect when connecting through Moonlight on Linux.

@VasylBaran
Copy link
Author

@lulzsun that's actually my setup here 😁
macOS VM running under QEMU with GPU passthrough (RX 6600)

@lulzsun
Copy link

lulzsun commented Apr 26, 2024

Did a little digging around, appears that #2347 might be the exact same issue described here. A user says an older build of sunshine worked, will try later when I get the chance.

@lulzsun
Copy link

lulzsun commented Apr 27, 2024

Tried version 0.14.1 of sunshine and surprisingly software encoding works and that shaking/freezing issue is resolved. Hardware encoding still doesn't work and the error logs still output the same thing as the latest version.

[2024:04:26:20:52:57]: Info: Trying encoder [videotoolbox]
[2024:04:26:20:52:57]: Info: Color coding [Rec. 601]
[2024:04:26:20:52:57]: Info: Color range: [JPEG]
[2024:04:26:20:52:58]: Error: Could not open codec [h264_videotoolbox]: Generic error in an external library
[2024:04:26:20:52:58]: Info: Color coding [Rec. 601]
[2024:04:26:20:52:58]: Info: Color range: [JPEG]
[2024:04:26:20:52:58]: Error: Could not open codec [h264_videotoolbox]: Generic error in an external library
[2024:04:26:20:52:58]: Info: Encoder [videotoolbox] failed

@VasylBaran
Copy link
Author

@lulzsun did you install sunshine using brew or something else?

@VasylBaran
Copy link
Author

version 0.14.1 of sunshine doesn't seem to be available in brew and I'm having trouble building it myself

@ReenigneArcher
Copy link
Member

You shouldn't even attempt to use a version that old... that are several security issues we have fixed in the past 2 years.

@VasylBaran
Copy link
Author

@ReenigneArcher I see.. any idea as to why there might be a regression on macOS between those versions?

@ReenigneArcher
Copy link
Member

Sorry, I don't know... we would need to know the first version that doesn't work, then try to narrow it down to a specific commit between the last working version and the first broken one.

@VasylBaran
Copy link
Author

VasylBaran commented Apr 27, 2024

@ReenigneArcher @lulzsun I did a short test of different versions of Sunshine on macOS and here's what I got:

v0.21.0 - doesn't work properly (see my video above)
v0.20.0 - crashes during start (zsh: segmentation fault ./sunshine)
v0.19.1 - works properly (including HEVC encoding)
v0.19.0 - works properly (including HEVC encoding)
v0.18.4 - work properly (including HEVC encoding)

I'm happy to find a version of Sunshine that works propertly (v0.19.1) for me and now I'm happy ♥️

@lulzsun
Copy link

lulzsun commented Apr 27, 2024

Tried v0.19.1 and unfortunately hardware encoding still doesn't work for me, but at least software encoding is still usable.

@VasylBaran
Copy link
Author

@lulzsun and does your hardware encoder gets detected and working properly with other applications? (e.g. Hanbrake, videoproc)

You should see something like this: #2272 (comment)

@lulzsun
Copy link

lulzsun commented Apr 27, 2024

@VasylBaran Apparently it doesn't... I just assumed it was working. I installed VideoProc to check and it says HEVC and H264 were both unavailable/disabled.

Not sure why that is the case. I think my GPU should be able to support it, but I'll have to look into it further myself as it seems like it is unrelated to Sunshine now.

@rahulc07
Copy link

+1 Encountering this issue on an RX 550 Lexa card spoofed to 67FF in Mac OS Ventura OSX-KVM under Proxmox (Ryzen 7 1700)

@VasylBaran
Copy link
Author

VasylBaran commented Apr 27, 2024

@lulzsun @xXTeraXx I did a small “research” on this topic in the past. Here’s a list of articles and guides that I found useful enough to save them:

  • GUIDE How to Enable H.264 and HEVC/H.265 encoding on macOS - [link]
  • Hackintosh on ASRock B550M Steel Legend with AMD RX 6800 XT via OpenCore - [link]
  • Googel query on the topic: [link]
  • iMac19,1(Headless) vs iMacPro1,1 Video Encoding Performance Test. - [link]
  • INTEL/AMD GPU SUPPORT FÜR H265/HEVC MAIN10 (10 BIT) UHD ENCODING AM MAC - [link]
  • Hacking in 2022, the criticality of the GPU [link]

@ReenigneArcher
Copy link
Member

@VasylBaran thank you for testing the different versions!

I'm not sure the cause of the issue at this point, but here is all the changes from v0.19.1 to v0.20.0. https://github.com/LizardByte/Sunshine/pull/1115/files

@Hazer
Copy link
Member

Hazer commented Apr 28, 2024

Can confirm, version 0.19.1 works for me too. Newer versions don't.

macOS 14.4.1
AMD Radeon RX 570
Not Virtualizing

@lulzsun
Copy link

lulzsun commented Apr 28, 2024

I did a small “research” on this topic in the past. Here’s a list of articles and guides that I found useful enough to save them

@VasylBaran Thanks, this was helpful in figuring out that I was using the wrong SMBIOS required for enabling hardware acceleration. It seems like it "works" now (using version 0.19.1), but this time I ran into another problem.

Not sure if it is related to Moonlight/Sunshine, but I get this weird color artifact in addition to higher latency compared to using the software encoder.

Screenshot: With hardware encoder

Screenshot_20240427_210229

Screenshot: With software encoder

Screenshot_20240427_210334

Sorry if my issue is now off topic since it might no longer be related to the original issue.

@ReenigneArcher
Copy link
Member

@lulzsun how about the current version when using the correct SMBIOS?

@lulzsun
Copy link

lulzsun commented Apr 28, 2024

@lulzsun how about the current version when using the correct SMBIOS?

Unfortunately still getting the same initial issue on version 0.23.1 installed using brew (no hardware encoder detected and shaking/freezing issue with software encoder).

Will be sticking to 0.19.1 and forcing software encoder for the time being until the issue is figured out in latest version.

Hazer added a commit to Hazer/Sunshine that referenced this issue Apr 30, 2024
@Hazer
Copy link
Member

Hazer commented Apr 30, 2024

@ReenigneArcher found the issue.

First it was in commit 036aa2e470cf72e63f036b6b4ec23446a4fdf140, it freed the frame too soon in video.cpp:1735, so the encoder failed, then eed27d3 broken macOS for a while. It then was fixed in a29d2e11ea4b46590dab0ea97586bbc5152a8c7a, which worked if I reverted 036aa2e changes after line 1735, but got broken again in the next commit... After poking around a bit, found out that now the culprit was mostly e535706a09f1849d2799fd72e889e4d7182f7fe5, this commit changes av_img_t and how it retains/release the frame buffers, which again, breaks something with how the frame is available to the encoder when needed.

So after trying to fix the retain/release cycle of this change without success, I decided to just revert the necessary changes, taking care to not remove newer unrelated changes, and it's now working for me even with the nightly branch.

If you have any improvement suggestion, for example how to fix without fully reverting av_img_t like I did, but only fixing the retain/release issues, I can run it here to try out.

PR: #2485

@VasylBaran
Copy link
Author

@Hazer just wanted to say 'thank you!' for taking the time and looking into it. Kudos! ♥️

Hazer added a commit to Hazer/Sunshine that referenced this issue May 9, 2024
@Hazer
Copy link
Member

Hazer commented May 9, 2024

If anyone using homebrew wants to try out my branch (@VasylBaran I'm looking at you), you can download the file here:
https://github.com/Hazer/Sunshine/actions/runs/9024651951/artifacts/1489439570

unzip the file downloaded, then run in the same folder:
brew install --build-from-source sunshine.rb

This should install the version with my most recent changes. While reverting those changes helped, I think now I got a proper implementation of the fix, testers welcome.

Hazer added a commit to Hazer/Sunshine that referenced this issue May 13, 2024
@ArtanisKrall
Copy link

Hi, I've been trying to install this version or the last one that worked (v19 apparently) without succes. I'm using macports, not homebrew. Do you know when will it be merged with 'nightly' so I can try that branch?

Thanks for all the work!

@VasylBaran
Copy link
Author

VasylBaran commented May 14, 2024

If anyone using homebrew wants to try out my branch (@VasylBaran I'm looking at you), you can download the file here: https://github.com/Hazer/Sunshine/actions/runs/9024651951/artifacts/1489439570

unzip the file downloaded, then run in the same folder: brew install --build-from-source sunshine.rb

This should install the version with my most recent changes. While reverting those changes helped, I think now I got a proper implementation of the fix, testers welcome.

I can confirm that this build works well on an M1 Macbook Air, although I do see an interesting "Error: Encoder did not produce IDR frame when requested!`" error in the logs. Can't test it on AMD-based system at the moment, but I don't think this issue was linked to a any particular system. Looks like the problem I logged is fixed in this build, encoders are being correctly identified and used ;-)

[2024:05:14:13:28:07]: Info: Found H.264 encoder: h264_videotoolbox [videotoolbox] [2024:05:14:13:28:07]: Info: Found HEVC encoder: hevc_videotoolbox [videotoolbox] [2024:05:14:13:28:07]: Info: Executing [Desktop] [2024:05:14:13:28:07]: Info: CLIENT CONNECTED [2024:05:14:13:28:07]: Info: Detecting displays [2024:05:14:13:28:07]: Info: Detected display: Built-in Retina Display (id: 1) connected: true [2024:05:14:13:28:07]: Info: Configuring selected display (1) to stream [2024:05:14:13:28:07]: Info: SDR color coding [Rec. 601] [2024:05:14:13:28:07]: Info: Color depth: 8-bit [2024:05:14:13:28:07]: Info: Color range: [MPEG] [2024:05:14:13:28:32]: Error: Encoder did not produce IDR frame when requested!

@Hazer
Copy link
Member

Hazer commented May 14, 2024

@VasylBaran Thanks for the test!

Yeah, this missing IDR frame message is happening with me too, on my RX 570, but I think it's another issue for a new PR, and don't seem to break the stream. I guess some GPUs need some tweaks to the GOP/Keyint settings for optimal usage, but that's another round of experimentation.

Having it at least working again makes things easier!

Hazer added a commit to Hazer/Sunshine that referenced this issue May 14, 2024
@VasylBaran
Copy link
Author

@VasylBaran Thanks for the test!

Yeah, this missing IDR frame message is happening with me too, on my RX 570, but I think it's another issue for a new PR, and don't seem to break the stream. I guess some GPUs need some tweaks to the GOP/Keyint settings for optimal usage, but that's another round of experimentation.

Having it at least working again makes things easier!

yes, thanks again for doing this!

@ArtanisKrall
Copy link

It's working for me now with the last nigthly. I think is not using hardware encoder correctly, but I didn't try before the patch so I have to do more testing. But now the mouse works and the screen doesn't get stuck.
Thanks for the fix!

@Hazer
Copy link
Member

Hazer commented May 16, 2024

@ArtanisKrall if hardware encoding still don't work for you after your tests, please open another issue with your details, gpu, logs, etc, and a print of your VideoProc converter status, so I can give it proper attention.

@ArtanisKrall
Copy link

Thanks! Don't worry I have to do more testing first. It's my first time using MacOs, its a virtual machine with GPU-Passthrough and I'm not familiar with this card capabilities (its a RX 460 4GB). I have to figure out what I am doing first...
But at least now I'm able to remote desktop the machine :)

@lprhodes
Copy link

@Hazer I could be wrong but I don't believe that streaming on macOS Sonoma is working correctly. I'm using the code from master and seeing significant CPU load while streaming, to the point where it's a laggy mess.

This is on an M2 Mac but I was seeing the same issue with an Intel Mac with 5700 XT (confirmed using Video Proc that the encoder was working).

Interestingly, less CPU cores light up with software encoding forced.

Screenshot 2024-05-31 at 8 40 54 PM

[2024:05:31:20:39:49]: Info: // Testing for available encoders, this may generate errors. You can safely ignore those errors. //
[2024:05:31:20:39:49]: Info: Trying encoder [videotoolbox]
[2024:05:31:20:39:49]: Info: Detecting displays
[2024:05:31:20:39:49]: Info: Detected display: Built-in Retina Display (id: 1) connected: true
[2024:05:31:20:39:49]: Info: Configuring selected display (1) to stream
[2024:05:31:20:39:49]: Info: SDR color coding [Rec. 601]
[2024:05:31:20:39:49]: Info: Color depth: 8-bit
[2024:05:31:20:39:49]: Info: Color range: [JPEG]
[2024:05:31:20:39:50]: Warning: [h264_videotoolbox @ 0x128f0e4b0] PrioritizeEncodingSpeedOverQuality property is not supported on this device. Ignoring.
[2024:05:31:20:39:50]: Info: [h264_videotoolbox @ 0x128f0e4b0] This device does not support the AllowOpenGop option. Value ignored.
[2024:05:31:20:39:50]: Info: SDR color coding [Rec. 601]
[2024:05:31:20:39:50]: Info: Color depth: 8-bit
[2024:05:31:20:39:50]: Info: Color range: [JPEG]
[2024:05:31:20:39:50]: Info: Detecting displays
[2024:05:31:20:39:50]: Info: Detected display: Built-in Retina Display (id: 1) connected: true
[2024:05:31:20:39:50]: Info: Configuring selected display (1) to stream
[2024:05:31:20:39:50]: Info: SDR color coding [Rec. 709]
[2024:05:31:20:39:50]: Info: Color depth: 10-bit
[2024:05:31:20:39:50]: Info: Color range: [JPEG]
[2024:05:31:20:39:50]: Info:
[2024:05:31:20:39:50]: Info: // Ignore any errors mentioned above, they are not relevant. //
[2024:05:31:20:39:50]: Info:
[2024:05:31:20:39:50]: Info: Found H.264 encoder: h264_videotoolbox [videotoolbox]
[2024:05:31:20:39:50]: Info: Found HEVC encoder: hevc_videotoolbox [videotoolbox]
[2024:05:31:20:39:50]: Error: Couldn't find any of the following libraries: [libavahi-common.3.dylib, libavahi-common.dylib]
[2024:05:31:20:39:50]: Info: Configuration UI available at [https://localhost:47990]
[2024:05:31:20:40:23]: Info: // Testing for available encoders, this may generate errors. You can safely ignore those errors. //
[2024:05:31:20:40:23]: Info: Trying encoder [videotoolbox]
[2024:05:31:20:40:23]: Info: Detecting displays
[2024:05:31:20:40:23]: Info: Detected display: Built-in Retina Display (id: 1) connected: true
[2024:05:31:20:40:23]: Info: Configuring selected display (1) to stream
[2024:05:31:20:40:23]: Info: SDR color coding [Rec. 601]
[2024:05:31:20:40:23]: Info: Color depth: 8-bit
[2024:05:31:20:40:23]: Info: Color range: [JPEG]
[2024:05:31:20:40:23]: Warning: [h264_videotoolbox @ 0x12a5069e0] PrioritizeEncodingSpeedOverQuality property is not supported on this device. Ignoring.
[2024:05:31:20:40:23]: Info: [h264_videotoolbox @ 0x12a5069e0] This device does not support the AllowOpenGop option. Value ignored.
[2024:05:31:20:40:23]: Info: SDR color coding [Rec. 601]
[2024:05:31:20:40:23]: Info: Color depth: 8-bit
[2024:05:31:20:40:23]: Info: Color range: [JPEG]
[2024:05:31:20:40:23]: Info: Detecting displays
[2024:05:31:20:40:23]: Info: Detected display: Built-in Retina Display (id: 1) connected: true
[2024:05:31:20:40:23]: Info: Configuring selected display (1) to stream
[2024:05:31:20:40:23]: Info: SDR color coding [Rec. 709]
[2024:05:31:20:40:23]: Info: Color depth: 10-bit
[2024:05:31:20:40:23]: Info: Color range: [JPEG]
[2024:05:31:20:40:24]: Info:
[2024:05:31:20:40:24]: Info: // Ignore any errors mentioned above, they are not relevant. //
[2024:05:31:20:40:24]: Info:
[2024:05:31:20:40:24]: Info: Found H.264 encoder: h264_videotoolbox [videotoolbox]
[2024:05:31:20:40:24]: Info: Found HEVC encoder: hevc_videotoolbox [videotoolbox]
[2024:05:31:20:40:24]: Info: Executing [Desktop]
[2024:05:31:20:40:24]: Info: CLIENT CONNECTED
[2024:05:31:20:40:24]: Info: Detecting displays
[2024:05:31:20:40:24]: Info: Detected display: Built-in Retina Display (id: 1) connected: true
[2024:05:31:20:40:24]: Info: Configuring selected display (1) to stream
[2024:05:31:20:40:24]: Info: SDR color coding [Rec. 601]
[2024:05:31:20:40:24]: Info: Color depth: 10-bit
[2024:05:31:20:40:24]: Info: Color range: [MPEG]
[2024:05:31:20:40:24]: Warning: audio_control_t::set_sink() unimplemented: BlackHole 2ch
[2024:05:31:20:40:26]: Error: Encoder did not produce IDR frame when requested!

@lprhodes
Copy link

lprhodes commented May 31, 2024

I've determined that the high CPU usage occurs when you allow HEVEC to report HDR as being available or leaving it set to automatic. CPU usage returns to normal when the available HEVC options are explicitly set.

Even with normal usage, Sunshine on macOS still feels around 400ms laggier than Windows (using the same client) so I think I'll need to stick with VNC for now.

@VasylBaran
Copy link
Author

@lprhodes did you get high CPU usage after you changed sunshine's default settings or do you get high CPU usage with default settings?

@Hazer
Copy link
Member

Hazer commented May 31, 2024

@lprhodes can you please open a new issue for this? I don't have a client with HEVC decoding support, nor HDR, to test it right now, but maybe someone has.

@lprhodes
Copy link

lprhodes commented Jun 1, 2024

@VasylBaran @Hazer default settings. I certainly can open a new issue. Aside from the excessive CPU bug, what work (if any) do you think can be done to improve the overall performance of Sunshine on macOS so that it sits closers to that of Windows? I have some free time coming up that I'd like to dedicate to this.

Is ffmpeg the primary bottleneck?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
os:macOS OS is macOS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants