Skip to content

Commit 7abab0f

Browse files
authored
chore: kickoff release
2 parents e6db58c + b28c192 commit 7abab0f

File tree

5 files changed

+21
-18
lines changed

5 files changed

+21
-18
lines changed

Sources/FaceLiveness/AV/LivenessCaptureSession.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import AVFoundation
1111
class LivenessCaptureSession {
1212
let captureDevice: LivenessCaptureDevice
1313
private let captureQueue = DispatchQueue(label: "com.amazonaws.faceliveness.cameracapturequeue")
14+
private let configurationQueue = DispatchQueue(label: "com.amazonaws.faceliveness.sessionconfiguration", qos: .userInitiated)
1415
let outputDelegate: AVCaptureVideoDataOutputSampleBufferDelegate
1516
var captureSession: AVCaptureSession?
1617

@@ -43,6 +44,7 @@ class LivenessCaptureSession {
4344
else { throw LivenessCaptureSessionError.cameraUnavailable }
4445

4546
let cameraInput = try AVCaptureDeviceInput(device: camera)
47+
let videoOutput = AVCaptureVideoDataOutput()
4648

4749
teardownExistingSession(input: cameraInput)
4850
captureSession = AVCaptureSession()
@@ -53,13 +55,10 @@ class LivenessCaptureSession {
5355

5456
try setupInput(cameraInput, for: captureSession)
5557
captureSession.sessionPreset = captureDevice.preset
56-
57-
let videoOutput = AVCaptureVideoDataOutput()
5858
try setupOutput(videoOutput, for: captureSession)
59-
6059
try captureDevice.configure()
6160

62-
DispatchQueue.global().async {
61+
configurationQueue.async {
6362
captureSession.startRunning()
6463
}
6564

Sources/FaceLiveness/Views/Liveness/FaceLivenessDetectionView.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ public struct FaceLivenessDetectorView: View {
172172
UIScreen.main.brightness = 1.0
173173
}
174174
}
175+
.onDisappear() {
176+
viewModel.stopRecording()
177+
}
175178
.onReceive(viewModel.$livenessState) { output in
176179
switch output.state {
177180
case .completed:

Sources/FaceLiveness/Views/Liveness/LivenessViewController.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ final class _LivenessViewController: UIViewController {
3737
}
3838
}
3939
}
40+
41+
deinit {
42+
self.previewLayer.removeFromSuperlayer()
43+
(self.previewLayer as? AVCaptureVideoPreviewLayer)?.session = nil
44+
self.previewLayer = nil
45+
}
4046

4147
override func viewDidLoad() {
4248
super.viewDidLoad()
@@ -110,6 +116,7 @@ extension _LivenessViewController: FaceLivenessViewControllerPresenter {
110116
imageView.frame = self.previewLayer.frame
111117
self.view.addSubview(imageView)
112118
self.previewLayer.removeFromSuperlayer()
119+
(self.previewLayer as? AVCaptureVideoPreviewLayer)?.session = nil
113120
self.viewModel.stopRecording()
114121
}
115122
}

Tests/IntegrationTestApp/IntegrationTestAppUITests/LivenessIntegrationUITests.swift

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@ class CreateLivenessSessionUITests: XCTestCase {
2626
Thread.sleep(forTimeInterval: 2)
2727
XCTAssert(app!.buttons[UIConstants.BeginCheck.primaryButton].exists)
2828
XCTAssertFalse(app!.buttons[UIConstants.primaryButton].exists)
29-
let scrollViewsQuery = app!.scrollViews
30-
let elementsQuery = scrollViewsQuery.otherElements
31-
XCTAssertEqual(elementsQuery.staticTexts.element(boundBy: 1).label, UIConstants.BeginCheck.description)
32-
XCTAssert(elementsQuery.buttons[UIConstants.BeginCheck.warning].exists)
33-
XCTAssert(elementsQuery.staticTexts[UIConstants.BeginCheck.instruction].exists)
29+
XCTAssert(app!.staticTexts[UIConstants.BeginCheck.warningTitle].exists)
30+
XCTAssert(app!.staticTexts[UIConstants.BeginCheck.warningDescription].exists)
31+
XCTAssert(app!.staticTexts[UIConstants.BeginCheck.instruction].exists)
3432
}
3533

3634
func testStartLivenessIntegration() throws {
@@ -40,14 +38,11 @@ class CreateLivenessSessionUITests: XCTestCase {
4038
app?.buttons[UIConstants.primaryButton].tap()
4139
Thread.sleep(forTimeInterval: 2)
4240
XCTAssert(app!.buttons[UIConstants.BeginCheck.primaryButton].exists)
43-
XCTAssertFalse(app!.buttons[UIConstants.primaryButton].exists)
4441
app!.buttons[UIConstants.BeginCheck.primaryButton].tap()
4542
Thread.sleep(forTimeInterval: 2)
46-
XCTAssert(app!.staticTexts[UIConstants.LivenessCheck.countdownInstruction].exists)
4743
XCTAssert(app!.buttons[UIConstants.LivenessCheck.closeButton].exists)
48-
Thread.sleep(forTimeInterval: 3)
4944
XCTAssert(app!.staticTexts[UIConstants.LivenessCheck.moveInstruction].exists)
50-
Thread.sleep(forTimeInterval: 3)
45+
Thread.sleep(forTimeInterval: 4)
5146
XCTAssert(app!.staticTexts[UIConstants.LivenessCheck.holdInstruction].exists)
5247
Thread.sleep(forTimeInterval: 8)
5348
XCTAssert(app!.buttons[UIConstants.LivenessResult.primaryButton].exists)

Tests/IntegrationTestApp/IntegrationTestAppUITests/UIConstants.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ struct UIConstants {
1010
static let primaryButton = "Create Liveness Session"
1111

1212
struct BeginCheck {
13-
static let primaryButton = "Begin Check"
14-
static let description = "You will go through a face verification process to prove that you are a real person. Your screen's brightness will temporarily be set to 100% for highest accuracy."
15-
static let warning = "Photosensitivity Warning, This check displays colored lights. Use caution if you are photosensitive."
16-
static let instruction = "Follow the instructions to complete the check:"
13+
static let primaryButton = "Start video check"
14+
static let warningTitle = "Photosensitivity Warning"
15+
static let warningDescription = "This check flashes different colors. Use caution if you are photosensitive."
16+
static let instruction = "Center your face"
1717
}
1818

1919
struct LivenessCheck {
20-
static let countdownInstruction = "Hold face position during countdown."
2120
static let moveInstruction = "Move closer"
2221
static let holdInstruction = "Hold still"
2322
static let closeButton = "Close"

0 commit comments

Comments
 (0)