You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On a macOS host, if I start Sunshine with only 1 display connected, and later connect another physical or virtual display, and only then connect with a Client, the host will crash.
This happens because we call video::probe_encoders() on the nvhttp connection threads, which then calls [NSScreen screens] inside av_video. NSScreen has issues with being called on background threads, and while it may correctly work on a conventional NSApplication on some macOS background threads, we are not one. So when we try to get all display names, we get a new display count with all displays, but we still get the old cached NSScreen.screens with less screens, and we index bounds crash.
Expected Behavior
NSScreen.screens should be called on main thread;
Should always return the updated list of screens;
Sunshine should not crash
Additional Context
I'm developing a fix, already have a working prototype, but running things on the main thread, outside of the startup actions, it's currently trick on Sunshine, and my current fix may impact other platforms and current stable behaviors, so while we discuss and evaluate a proper fix and refactor, there's this open issue.
Fixing this issue will predate #2490, and I will use some of the things learned/done there, which will eventually lead to that PR and libdisplay.
Is there an existing issue for this?
Is your issue described in the documentation?
Is your issue present in the nightly release?
Describe the Bug
On a macOS host, if I start Sunshine with only 1 display connected, and later connect another physical or virtual display, and only then connect with a Client, the host will crash.
This happens because we call
video::probe_encoders()
on thenvhttp
connection threads, which then calls[NSScreen screens]
insideav_video
. NSScreen has issues with being called on background threads, and while it may correctly work on a conventional NSApplication on some macOS background threads, we are not one. So when we try to get all display names, we get a new display count with all displays, but we still get the old cachedNSScreen.screens
with less screens, and we index bounds crash.Expected Behavior
Additional Context
I'm developing a fix, already have a working prototype, but running things on the main thread, outside of the startup actions, it's currently trick on Sunshine, and my current fix may impact other platforms and current stable behaviors, so while we discuss and evaluate a proper fix and refactor, there's this open issue.
Fixing this issue will predate #2490, and I will use some of the things learned/done there, which will eventually lead to that PR and
libdisplay
.Host Operating System
macOS
Operating System Version
Sonoma 14.4.1
Architecture
64 bit
Sunshine commit or version
nightly: b4c12cb
Package
macOS - dmg
GPU Type
n/a
GPU Model
unrelated
GPU Driver/Mesa Version
unrelated
Capture Method (Linux Only)
No response
Config
Apps
No response
Relevant log output
The text was updated successfully, but these errors were encountered: