Explorar o código

mac-capture: Fix ScreenCaptureKit deadlock when using nil display ID

In some scenarios ScreenCaptureKit will not call our completion handler
when an internal ReplayKit error occurred. This seems to be more common
when a <nil> display id is provided as the content filter for
ScreenCaptureKit.

The issue was reported to Apple as FB13455947, but it is good practice
for us to check for an invalid display ID before even attempting to start
a capture stream.
PatTheMav %!s(int64=2) %!d(string=hai) anos
pai
achega
be7ac828de
Modificáronse 1 ficheiros con 7 adicións e 0 borrados
  1. 7 0
      plugins/mac-capture/mac-sck-video-capture.m

+ 7 - 0
plugins/mac-capture/mac-sck-video-capture.m

@@ -108,6 +108,13 @@ static bool init_screen_stream(struct screen_capture *sc)
         case ScreenCaptureDisplayStream: {
             SCDisplay *target_display = get_target_display();
 
+            if (!target_display) {
+                MACCAP_ERR("init_screen_stream: Invalid target display ID:  %u\n", sc->display);
+
+                os_sem_post(sc->shareable_content_available);
+                return false;
+            }
+
             if (sc->hide_obs) {
                 SCRunningApplication *obsApp = nil;
                 NSString *mainBundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];