Skip to content

Commit 5ad284c

Browse files
committed
Dispatch AVCaptureDevice.requestAccess completion to the main queue
This fixes a bug where the "needs permission" message would not appear correctly on the camera view immediately after the user denied access to the camera. From the AVCaptureDevice.requestAccess documentation: "The completion handler is called on an arbitrary dispatch queue. It is the client's responsibility to ensure that any UIKit-related updates are called on the main queue or main thread as a result."
1 parent 8cc2dc7 commit 5ad284c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Authenticator/Source/QRScanner.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ class QRScanner: NSObject, AVCaptureMetadataOutputObjectsDelegate {
9999
guard !CommandLine.isDemo else {
100100
return
101101
}
102-
AVCaptureDevice.requestAccess(for: .video, completionHandler: completionHandler)
102+
AVCaptureDevice.requestAccess(for: .video) { accessGranted in
103+
DispatchQueue.main.async {
104+
completionHandler(accessGranted)
105+
}
106+
}
103107
}
104108

105109
// MARK: AVCaptureMetadataOutputObjectsDelegate

0 commit comments

Comments
 (0)