-
Notifications
You must be signed in to change notification settings - Fork 292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(liveness): allow selecting all cameras, allow camera selection … #5833
Conversation
|
@@ -115,6 +115,8 @@ export const LivenessCameraModule = ( | |||
|
|||
const isFaceMovementChallenge = | |||
useLivenessSelector(selectChallengeType) === FACE_MOVEMENT_CHALLENGE.type; | |||
const isMobileFaceMovementAndLightChallenge = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we flip this logic to be more readable, something like
const allowSelectableDevices = !isMobile || (isMobile && isFaceMovementChallenge)
then add a comment why we only support desktop or mobile and facemovement?
@@ -24,6 +24,3 @@ Feature: Disable Start Screen | |||
Then I click the "FaceMovementAndLightChallenge" selectfield and select the "FaceMovementChallenge" option | |||
Then I see "FaceMovementChallenge" | |||
Then I see "liveness-detector" element | |||
Then I see the "Face didn't fit inside oval in time limit." timeout error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do these need to be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rekognition updated the values for face distance which make it so these tests no longer work, only on the no light stuff, figure that's unrelated to this PR but just want to unblock this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh gotcha, what updates would we need to get them passing? But make sense as a follow up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would need to update the video we use in the e2e test haha
@@ -115,6 +115,8 @@ | |||
|
|||
const isFaceMovementChallenge = | |||
useLivenessSelector(selectChallengeType) === FACE_MOVEMENT_CHALLENGE.type; | |||
const allowSelectableDevicesMobile = | |||
!isMobileScreen || (isMobileScreen && isFaceMovementChallenge); |
Check warning
Code scanning / CodeQL
Useless conditional Warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this think isMobileScreen is always true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe because if isMobileScreen === false
then the left hand side will always short circuit the whole thing to be true. So you only evaluate the right side if isMobileScreen === true
so it's redundant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
boolean algebra 🙃
selectableDevices: MediaDeviceInfo[]; | ||
} | ||
|
||
export const CameraSelector = (props: CameraSelectorProps): JSX.Element => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
@@ -8,5 +8,4 @@ export const STATIC_VIDEO_CONSTRAINTS: MediaTrackConstraints = { | |||
ideal: 480, | |||
}, | |||
frameRate: { min: 15, ideal: 30, max: 30 }, | |||
facingMode: 'user', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to confirm, this is no longer needed because with the light challenge we only show the dropdown on desktop, and on desktop the facing mode is not relevant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, desktop cameras do not have a facingMode value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor feedback, lmk your thoughts!
value={selectedDeviceId} | ||
onChange={onCameraChange} | ||
> | ||
{selectableDevices?.map((device) => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are gating rendering of this component think we can remove the optional chaining here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, removed
...es/react-liveness/src/components/FaceLivenessDetector/LivenessCheck/LivenessCameraModule.tsx
Outdated
Show resolved
Hide resolved
{allowSelectableDevices && ( | ||
<CameraSelector | ||
onCameraChange={onCameraChange} | ||
selectableDevices={selectableDevices} | ||
selectedDeviceId={selectedDeviceId} | ||
/> | ||
)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer ternary returning null
as the second condition in place of returning false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -160,6 +153,15 @@ export const LivenessCameraModule = ( | |||
videoWidth && videoHeight ? videoWidth / videoHeight : 0 | |||
); | |||
|
|||
// Only allow on mobile screen if it is no light challenge | |||
const allowSelectableDevicesMobile = | |||
!isMobileScreen || isFaceMovementChallenge; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit hard to follow that allowSelectableDevicesMobile
is true
when isMobileScreen
is false
. Realize that it going to be hard for this not to be somewhat confusing but maybe we can update the approach to something like:
const hasMultipleDevices = !!selectableDevices?.length;
const allowDeviceSelection = (isStartView && hasMultipleDevices) && (!isMobileScreen || isFaceMovementChallenge)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think that makes sense, think this is much cleaner
selectedDeviceId?: string; | ||
onCameraChange: (e: React.ChangeEvent<HTMLSelectElement>) => void; | ||
selectableDevices: MediaDeviceInfo[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO we can simplify the naming of the props
a bit here since camera selection is implied by the component name, e.g.
deviceId?: string;
onSelect?: (e: React.ChangeEvent<HTMLSelectElement>) => void;
devices: MediaDeviceInfo[];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on board with this
…venessCheck/LivenessCameraModule.tsx Co-authored-by: Caleb Pollman <cpollman@amazon.com>
commit 984fa99 Author: thaddmt <68032955+thaddmt@users.noreply.github.com> Date: Thu Sep 26 11:10:45 2024 -0700 chore(liveness): allow selecting all cameras, allow camera selection … (aws-amplify#5833) * chore(liveness): allow selecting all cameras, allow camera selection on mobile * only show on mobile with facemovement challenge only * relax e2e tests on alpha * make more reaadable * fix * update names * refactor, add tests * Update packages/react-liveness/src/components/FaceLivenessDetector/LivenessCheck/LivenessCameraModule.tsx Co-authored-by: Caleb Pollman <cpollman@amazon.com> * refactor --------- Co-authored-by: Caleb Pollman <cpollman@amazon.com>
* Update publish workflow * disable e2e tests in workflow * Squashed commit of the following: commit 984fa99 Author: thaddmt <68032955+thaddmt@users.noreply.github.com> Date: Thu Sep 26 11:10:45 2024 -0700 chore(liveness): allow selecting all cameras, allow camera selection … (#5833) * chore(liveness): allow selecting all cameras, allow camera selection on mobile * only show on mobile with facemovement challenge only * relax e2e tests on alpha * make more reaadable * fix * update names * refactor, add tests * Update packages/react-liveness/src/components/FaceLivenessDetector/LivenessCheck/LivenessCameraModule.tsx Co-authored-by: Caleb Pollman <cpollman@amazon.com> * refactor --------- Co-authored-by: Caleb Pollman <cpollman@amazon.com>
* chore(liveness): allow selecting all cameras, allow camera selection … (#5833) * chore(liveness): allow selecting all cameras, allow camera selection on mobile * only show on mobile with facemovement challenge only * relax e2e tests on alpha * make more reaadable * fix * update names * refactor, add tests * Update packages/react-liveness/src/components/FaceLivenessDetector/LivenessCheck/LivenessCameraModule.tsx Co-authored-by: Caleb Pollman <cpollman@amazon.com> * refactor --------- Co-authored-by: Caleb Pollman <cpollman@amazon.com> * fix(liveness): fix camera select showing up with one camera, fix camera changing weirdness with hair check screen (#5845) --------- Co-authored-by: thaddmt <68032955+thaddmt@users.noreply.github.com> Co-authored-by: Caleb Pollman <cpollman@amazon.com>
* chore(liveness): allow selecting all cameras, allow camera selection … (#5833) * chore(liveness): allow selecting all cameras, allow camera selection on mobile * fix(liveness): fix camera select showing up with one camera, fix camera changing weirdness with hair check screen (#5845) * fix(liveness): Only apply transform style on user-facing video (#5953) * fix(liveness): Fix oval render when switching cameras (#5954) --------- Co-authored-by: thaddmt <68032955+thaddmt@users.noreply.github.com> Co-authored-by: Caleb Pollman <cpollman@amazon.com> Co-authored-by: Emma Sauerborn <70536670+esauerbo@users.noreply.github.com> Co-authored-by: Scott Rees <6165315+reesscot@users.noreply.github.com>
* chore(liveness): allow selecting all cameras, allow camera selection … (#5833) * chore(liveness): allow selecting all cameras, allow camera selection on mobile * only show on mobile with facemovement challenge only * relax e2e tests on alpha * make more reaadable * fix * update names * refactor, add tests * Update packages/react-liveness/src/components/FaceLivenessDetector/LivenessCheck/LivenessCameraModule.tsx Co-authored-by: Caleb Pollman <cpollman@amazon.com> * refactor --------- Co-authored-by: Caleb Pollman <cpollman@amazon.com> * fix(liveness): fix camera select showing up with one camera, fix camera changing weirdness with hair check screen (#5845) * fix(liveness): Only apply transform style on user-facing video (#5953) Co-authored-by: Scott Rees <6165315+reesscot@users.noreply.github.com> * fix(liveness): Fix oval render when switching cameras (#5954) * chore(liveness): update video constraints for selected camera (#6009) --------- Co-authored-by: thaddmt <68032955+thaddmt@users.noreply.github.com> Co-authored-by: Caleb Pollman <cpollman@amazon.com> Co-authored-by: Emma Sauerborn <70536670+esauerbo@users.noreply.github.com> Co-authored-by: Scott Rees <6165315+reesscot@users.noreply.github.com>
…on mobile
Description of changes
Issue #, if available
Description of how you validated changes
Checklist
yarn test
passes and tests are updated/addeddocs
,e2e
,examples
, or other private packages.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.