Tobias K.
Tobias K.

Reputation: 306

await SCShareableContent never returns or throws error

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 🤔

Upvotes: 3

Views: 580

Answers (1)

Maxx
Maxx

Reputation: 1

Check if you are always closing SCStream properly using stopCapture.

Upvotes: 0

Related Questions