Skip to content

Failure on the first facial scan with FaceLivenessDetector. #250

@alvarorommel

Description

@alvarorommel

Before creating a new issue, please confirm:

On which framework/platform are you having an issue?

Android

Which UI component?

Liveness

How is your app built?

Android Kotlin

What browsers are you seeing the problem on?

No response

Which region are you seeing the problem in?

No response

Please describe your bug.

The tirst Attempt at Facial Scan (Liveness Check) Always Failed, Regardless of Device.

The following error appeared in the app logs:
“The camera failed to open within the allowed time limit.”

It seemed like the FaceLivenessDetector was trying to access the camera before it was fully ready, causing the device to be unable to activate or access the camera in time.

FaceLivenessDetector is triggered immediately after obtaining the sessionId, which leads to a backend error.

On the backend, the AWS Lambda function failed because the sessionId was sent too quickly. As a result, the issue shown in the image occurred, where the ReferenceImage object was not included. In order for the image to be present, the status had to be SUCCEEDED; in any other state, the object (the image) was not included.

Image

What's the expected behaviour?

We hope that the first facial scan attempt doesn't always fail and that it works as it did in previous versions.

Help us reproduce the bug!

The only change we made was updating the libraries involved in the facial scan.
We had:

implementation 'com.amplifyframework.ui:liveness:1.3.0'  
implementation 'com.amplifyframework:aws-auth-cognito:2.17.0'  
implementation 'com.amplifyframework:core:2.8.1'

We changed to:

implementation 'com.amplifyframework.ui:liveness:1.4.2'  
implementation 'com.amplifyframework:aws-auth-cognito:2.27.4'  
implementation 'com.amplifyframework:core:2.27.4'

Code Snippet

Here is a code example of how FaceLivenessDetector is used:

ResourceAWS.Status.SUCCESS -> {
    loading.dismiss()
    setContent {
        MaterialTheme(
            colorScheme = colores
        ) {
            FaceLivenessDetector(
                sessionId = resource.data.sessionId,
                region = "us-east-1",
                disableStartView = true,
                onComplete = {
                    viewModel.fetchSessionResult(
                        resource.data.sessionId
                    )
                    observeSessionResult()
                },
                onError = { error ->
                }
            )
        }
    }
}

ResourceAWS.Status.ERROR -> {
}

ResourceAWS.Status.LOADING -> {
    loading.show()
}

Console log output

"The camera failed to open within the allowed time limit."

Additional information and screenshots

Tested Solutions:

Introduce a delay before activating FaceLivenessDetector to allow time for the camera to become operational.

Attempt to check if the camera is ready to use: This solution was ineffective because Amplify manages the camera internally and does not provide any method or callback to determine whether the camera is ready.

Automatically retry the facial scan after the first failed attempt: If the error "camera failed to open" occurs, relaunch the scan. While this approach worked, it visibly showed the failure and then reloaded the view.

Introduce a delay within the Lambda function, though this is not recommended since it keeps the Lambda occupied.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglivenessThis issue relates to the Liveness componentpending-maintainer-responseIssue is pending response from an Amplify team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions