aws-amplify / amplify-ui-swift-liveness

This repository offers a UI component for Amazon Rekognition Face Liveness, enabling developers to ensure that only authentic users, and not bad actors using spoofs, can access their services.
https://ui.docs.amplify.aws/swift/connected-components/liveness
Apache License 2.0
8 stars 18 forks source link

UI is blocking when getting the "session timed out" error #61

Closed wind15973 closed 8 months ago

wind15973 commented 9 months ago

Hello We built an app with Amplify 2.18.0 and AmplifyUILiveness 1.1.1. It worked well if we followed the hints to finish the flow.

When we simulated some failure cases like time-out, we started the face check flow and didn't finish it. The UI was blocking for about 5 - 10 seconds when getting the first error. The console log showed the error but there was no "TTT test" string in the first time. After that, we got the next error. The console log showed the "TTT test" string and the error. It is weird that the UI is blocking when getting the "session timed out" error.

Please help with this case. Thank you!

Sample code we used:

FaceLivenessDetectorView(sessionID: viewModel.sessionID, region: "us-east-1", disableStartView: true, isPresented: $isPresentingLiveness) { result in
                switch result {
                case .success:
                    let _ = debugPrint("TTT success")
                case .failure(let error):
                    DispatchQueue.main.async {
                        let _ = debugPrint("TTT test")
                    }
                    let detectError = error as FaceLivenessDetectionError
                    let _ = debugPrint("TTT \(String(describing: detectError))")
                }
            }

Console logs:

截圖 2023-10-12 下午5 18 09
phantumcode commented 9 months ago

@wind15973 Thanks for submitting the issue, we'll try to reproduce the issue and investigate further.

phantumcode commented 8 months ago

@wind15973 Can you try out the latest release v1.1.3

If you're still seeing the issue, can you provide logs that includes the thread details and timestamps? For example

print("Received error - \(error) - \(Thread.current) - \(Date().timeIntervalSince1970)")
wind15973 commented 8 months ago

Hi @phantumcode, I saw the update of the latest release. Thanks for your help.

phantumcode commented 8 months ago

@wind15973 Can you provide confirmation that the latest release fixes your issue?

wind15973 commented 8 months ago

I will test it in these two days. Will back to you soon. Thank you

wind15973 commented 8 months ago

Hi @phantumcode, sorry for the late reply. The latest release v1.1.3 still cannot fix this issue. Every time this session timed out error occurred, and SDK would throw the error twice. These are the logs:

Received error - FaceLivenessDetectionError(code: 2, message: "Session timed out. Did not receive final response from server within time limit.", recoverySuggestion: "Try again.") - <_NSMainThread: 0x283864880>{number = 1, name = main} - 1698657869.402375
Received error - FaceLivenessDetectionError(code: 2, message: "Session timed out. Did not receive final response from server within time limit.", recoverySuggestion: "Try again.") - <_NSMainThread: 0x283864880>{number = 1, name = main} - 1698657878.415007

I tried to fix it with #64. And it worked for me. Does that not make sense to you? Thank you!

phantumcode commented 8 months ago

@wind15973 Fix should be in the latest release 1.1.4 Your fix in #64 does not resolve the root cause. In the original issue submitted, the error message was delayed 5-10 seconds because the error was being set on a background thread (this was fixed in the previous release). The error messages are getting set twice because the timeout handler was getting call even after the timeout error was already set as the current state, this should be fixed in the latest release 1.1.4.

wind15973 commented 6 months ago

Hi @phantumcode, this issue still has not been fixed in the latest release 1.2.1.