1

I built a Swift CLI application that records screen audio & video using ScreenCaptureKit. It worked before, but now it's starting to behave strangely without any changes to my app (nor to my system...afaik)

I created a small sample project only checking for Screen Capture rights, which also produces the same result:

import ScreenCaptureKit

print("CHECKING PERMISSIONS")

do {
    
    let _ = try await SCShareableContent.current

    print("PERMISSIONS GRANTED")
} catch _ as NSError {
    print("NO PERMISSIONS")
}

At the first run, it states "NO PERMISSIONS" and opens a dialog to grant permissions. After granting permissions and rerunning the app, the app "freezes" while awaiting the result of SCShareableContent.current. Like I said, it worked before and printed "PERMISSIONS GRANTED" after granting permissions, but not it simply freezes and I don't really know how to debug a non-returning await

Tobias K.
  • 286
  • 1
  • 3
  • 11
  • What is `current`? I don't think that is included in `ScreenCaptureKit`? – lorem ipsum Mar 23 '23 at 19:16
  • You can also try the following with the same result: ```try await SCShareableContent.excludingDesktopWindows(false, onScreenWindowsOnly: true)``` Also when adding a stream and starting an SCStream, everything seems fine, but the added stream never gets called. – Tobias K. Mar 23 '23 at 20:32
  • I'm hitting this too, did you ever figure it out? It feels like a bug in the framework. – idevelop May 23 '23 at 22:46
  • I am also getting this. It happens when I open the app in both Xcode and AppCode at same time and try to run the application again. Restarting does solve this problem but after restart it only records once for me – Jonathan Ma Jun 25 '23 at 10:55

1 Answers1

0

Check if you are always closing SCStream properly using stopCapture.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Maxx
  • 1