-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for complete strict concurrency and Swift 6 migration #456
base: develop
Are you sure you want to change the base?
Changes from 7 commits
ea93b87
d7dc395
5863a99
8367da6
fb4f338
b807384
776ed9d
bd7393b
98f5941
11d4888
14cd09b
ad54f07
6934f20
84c548a
edf9fb9
e193941
c06c002
ea9e454
02dd40b
35809ba
2ae5031
da5fd90
abf3932
3f1bc36
0be8e17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,8 +112,7 @@ struct CodeScannerView_Previews: PreviewProvider { | |
} | ||
} | ||
|
||
final class ScannerViewController: UIViewController, UINavigationControllerDelegate, AVCaptureMetadataOutputObjectsDelegate, | ||
UIAdaptivePresentationControllerDelegate { | ||
final class ScannerViewController: UIViewController, UINavigationControllerDelegate, UIAdaptivePresentationControllerDelegate { | ||
private let photoOutput = AVCapturePhotoOutput() | ||
private var isCapturing = false | ||
private var handler: ((UIImage) -> Void)? | ||
|
@@ -214,9 +213,7 @@ final class ScannerViewController: UIViewController, UINavigationControllerDeleg | |
reset() | ||
|
||
if (captureSession.isRunning == false) { | ||
DispatchQueue.global(qos: .userInteractive).async { | ||
self.captureSession?.startRunning() | ||
} | ||
self.captureSession?.startRunning() | ||
} | ||
} | ||
|
||
|
@@ -322,9 +319,7 @@ final class ScannerViewController: UIViewController, UINavigationControllerDeleg | |
super.viewDidDisappear(animated) | ||
|
||
if (captureSession?.isRunning == true) { | ||
DispatchQueue.global(qos: .userInteractive).async { | ||
self.captureSession?.stopRunning() | ||
} | ||
captureSession?.stopRunning() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did we remove the background async? Can we replace it instead with a simple task to the GlobalActor? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
} | ||
|
||
NotificationCenter.default.removeObserver(self) | ||
|
@@ -491,7 +486,14 @@ final class ScannerViewController: UIViewController, UINavigationControllerDeleg | |
} | ||
} | ||
|
||
extension ScannerViewController: AVCapturePhotoCaptureDelegate { | ||
#if swift(>=6.0) | ||
extension ScannerViewController: @preconcurrency AVCapturePhotoCaptureDelegate, | ||
@preconcurrency AVCaptureMetadataOutputObjectsDelegate {} | ||
#else | ||
extension ScannerViewController: AVCapturePhotoCaptureDelegate, AVCaptureMetadataOutputObjectsDelegate {} | ||
#endif | ||
|
||
extension ScannerViewController { | ||
|
||
func photoOutput( | ||
_ output: AVCapturePhotoOutput, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ import StreamVideo | |
import UIKit | ||
|
||
final class LocalParticipantSnapshotViewModel: NSObject, AVCapturePhotoCaptureDelegate, | ||
AVCaptureVideoDataOutputSampleBufferDelegate { | ||
martinmitrevski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
AVCaptureVideoDataOutputSampleBufferDelegate, @unchecked Sendable { | ||
|
||
private actor State { | ||
private(set) var isCapturingVideoFrame = false | ||
|
@@ -173,10 +173,15 @@ final class LocalParticipantSnapshotViewModel: NSObject, AVCapturePhotoCaptureDe | |
} | ||
|
||
/// Provides the default value of the `LocalParticipantSnapshotViewModel` class. | ||
#if swift(>=6.0) | ||
struct LocalParticipantSnapshotViewModelKey: @preconcurrency InjectionKey { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering how the environmenrkey on SwiftUI handles that? Is it assigned on MainActor? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, this part is ugly, we have to find a better way There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's meet and dicsuccs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe we can create a small package with the DI capabilities. Reuse it in both SwiftUI and Video, with the |
||
@MainActor static var currentValue: LocalParticipantSnapshotViewModel = .init() | ||
} | ||
#else | ||
struct LocalParticipantSnapshotViewModelKey: InjectionKey { | ||
@MainActor | ||
static var currentValue: LocalParticipantSnapshotViewModel = .init() | ||
@MainActor static var currentValue: LocalParticipantSnapshotViewModel = .init() | ||
} | ||
#endif | ||
|
||
extension InjectedValues { | ||
/// Provides access to the `LocalParticipantSnapshotViewModel` class to the views and view models. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did we remove the background async?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch