Skip to content

Commit

Permalink
use weak reference in legacy selfie view model to prevent retain cycle.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobitech committed Dec 2, 2024
1 parent 1c1007a commit 887d627
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Sources/SmileID/Classes/SelfieCapture/SelfieViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ public class SelfieViewModel: ObservableObject, ARKitSmileDelegate {
}

do {
try faceDetector.detect(imageBuffer: image) { [self] request, error in
try faceDetector.detect(imageBuffer: image) { [weak self] request, error in
guard let self else { return }
if let error {
print("Error analyzing image: \(error.localizedDescription)")
self.error = error
Expand Down Expand Up @@ -192,8 +193,8 @@ public class SelfieViewModel: ObservableObject, ARKitSmileDelegate {

let userNeedsToSmile = livenessImages.count > numLivenessImages / 2

DispatchQueue.main.async { [self] in
directive = userNeedsToSmile ? "Instructions.Smile" : "Instructions.Capturing"
DispatchQueue.main.async {
self.directive = userNeedsToSmile ? "Instructions.Smile" : "Instructions.Capturing"
}

// TODO: Use mouth deformation as an alternate signal for non-ARKit capture
Expand Down

0 comments on commit 887d627

Please sign in to comment.