From c16f4246845acc859f2f9f59846279c8f09859cc Mon Sep 17 00:00:00 2001 From: Tuan Pham Date: Fri, 20 Oct 2023 11:24:34 -0500 Subject: [PATCH] fix: update session timed out error to be non-blocking --- ...ionViewModel+FaceDetectionResultHandler.swift | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Sources/FaceLiveness/Views/Liveness/FaceLivenessDetectionViewModel+FaceDetectionResultHandler.swift b/Sources/FaceLiveness/Views/Liveness/FaceLivenessDetectionViewModel+FaceDetectionResultHandler.swift index a7458ed4..8a87ac03 100644 --- a/Sources/FaceLiveness/Views/Liveness/FaceLivenessDetectionViewModel+FaceDetectionResultHandler.swift +++ b/Sources/FaceLiveness/Views/Liveness/FaceLivenessDetectionViewModel+FaceDetectionResultHandler.swift @@ -89,9 +89,11 @@ extension FaceLivenessDetectionViewModel: FaceDetectionResultHandler { noFitStartTime = Date() } if let elapsedTime = noFitStartTime?.timeIntervalSinceNow, abs(elapsedTime) >= noFitTimeoutInterval { - self.livenessState - .unrecoverableStateEncountered(.timedOut) - self.captureSession.stopRunning() + DispatchQueue.main.async { + self.livenessState + .unrecoverableStateEncountered(.timedOut) + self.captureSession.stopRunning() + } } } @@ -100,9 +102,11 @@ extension FaceLivenessDetectionViewModel: FaceDetectionResultHandler { noFitStartTime = Date() } if let elapsedTime = noFitStartTime?.timeIntervalSinceNow, abs(elapsedTime) >= noFitTimeoutInterval { - self.livenessState - .unrecoverableStateEncountered(.timedOut) - self.captureSession.stopRunning() + DispatchQueue.main.async { + self.livenessState + .unrecoverableStateEncountered(.timedOut) + self.captureSession.stopRunning() + } } }