Description
Before creating a new issue, please confirm:
- I have searched for duplicate or closed issues and discussions.
- I have tried disabling all browser extensions or using a different browser
- I have tried deleting the node_modules folder and reinstalling my dependencies
- I have read the guide for submitting bug reports.
On which framework/platform are you having an issue?
React
Which UI component?
Liveness
How is your app built?
Create React App
What browsers are you seeing the problem on?
Android (React Native)
Which region are you seeing the problem in?
No response
Please describe your bug.
The FaceLivenessDetector component incorrectly selects the infrared camera (used for face unlock) instead of the regular selfie camera when performing liveness validation on Pixel 4 devices. This causes the liveness detection to fail as it attempts to use the infrared camera feed instead of the normal camera feed.
Environment:
- Device: Pixel 4
- Packages:
@aws-amplify/ui-react: 6.1.10
@aws-amplify/ui-react-liveness: 3.0.23
What's the expected behaviour?
The regular front-facing (selfie) camera should be activated for liveness detection.
Help us reproduce the bug!
Steps to Reproduce
- Initialize FaceLivenessDetector component
- Attempt to perform liveness validation
- Observe that the infrared camera is activated instead of the normal selfie camera
Code Snippet
return (
<ThemeProvider>
<div className="App">
{!sessionId ? (
<Loader />
) : (
<FaceLivenessDetector
sessionId={sessionId}
region="eu-west-1"
disableStartScreen={true}
onAnalysisComplete={handleAnalysisComplete}
onError={(error) => {
console.error(error);
}}
displayText={displayText}
onUserCancel={() => sendMessageToNative({ status: "CLOSED" })}
/>
)}
</div>
</ThemeProvider>
);
Console log output
No response
Additional information and screenshots
The infrared camera (used for face unlock) is being detected as the first available camera on getUserMedia call, causing the liveness detection to fail.
The issue occurs in:
packages/react-liveness/src/components/FaceLivenessDetector/service/machine/machine.ts
in the checkVirtualCameraAndGetStream function.
Here is my suggestion:
Filter out infrared cameras from the device selection process by:
- Adding infrared camera detection
- Filtering out infrared cameras from real video devices
- Validating existing devices against infrared camera check
Here are some references that made me think this can be solved like above: