@DTS Engineer I spent sometime and enabled concurrency checks to complete in the compiler options. I was able to fix two main sources of warning (which are error in Swift 6) by changing the definition of two functions as follows:
func capturePhoto(with features: PhotoFeatures, isolation: isolated (any Actor)? = #isolation) async throws -> Photo
func stopRecording(_ isolation: isolated (any Actor)? = #isolation) async throws -> Movie
Effectively, I forced these functions to be called from the isolation domain of an Actor (which is actor CaptureService in the source code). I believe this should be okay as this is the only place where these functions are invoked.
However, there is one place in the code where I still need help:
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey: Any]?, context: UnsafeMutableRawPointer?) {
switch keyPath {
case systemPreferredKeyPath:
// Update the observer's system-preferred camera value.
let newDevice = change?[.newKey] as? AVCaptureDevice
continuation?.yield(newDevice)
default:
super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
}
}
The line continuation?.yield(newDevice) throws a warning that Task-isolated 'newDevice' is passed as a 'sending' parameter; Uses in callee may race with later task-isolated uses.
Is this because AVCaptureDevice is not Sendable?