fix(face-landmarks): check for track state only if image capture is not polyfill (#12711)

This commit is contained in:
Gabriel Borlea 2022-12-21 15:34:40 +02:00 committed by GitHub
parent 32dbdf2e5c
commit 291370a263
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -305,13 +305,20 @@ class FaceLandmarksDetector {
private async sendDataToWorker(faceCenteringThreshold = 10): Promise<boolean> {
if (!this.imageCapture
|| !this.worker
|| !this.imageCapture?.track
|| this.imageCapture?.track.readyState !== 'live') {
|| !this.imageCapture) {
logger.log('Environment not ready! Could not send data to worker');
return false;
}
// if ImageCapture is polyfilled then it would not have the track,
// so there would be no point in checking for its readyState
if (this.imageCapture.track && this.imageCapture.track.readyState !== 'live') {
logger.log('Track not ready! Could not send data to worker');
return false;
}
let imageBitmap;
let image;