From ca92aa8c625ad9e6dbb3db4f8dbf3ac1a37c96ea Mon Sep 17 00:00:00 2001 From: laurenspriem Date: Mon, 5 May 2025 14:59:53 +0530 Subject: [PATCH] Include delay --- mobile/lib/utils/face/face_box_crop.dart | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/mobile/lib/utils/face/face_box_crop.dart b/mobile/lib/utils/face/face_box_crop.dart index 12046b4b57..ced0c84d08 100644 --- a/mobile/lib/utils/face/face_box_crop.dart +++ b/mobile/lib/utils/face/face_box_crop.dart @@ -1,5 +1,6 @@ import "dart:async"; import "dart:io" show File; +import "dart:math" show pow; import "package:flutter/foundation.dart"; import "package:logging/logging.dart"; @@ -114,12 +115,16 @@ Future?> getCachedFaceCrops( if (e is! TaskQueueTimeoutException && e is! TaskQueueOverflowException && e is! TaskQueueCancelledException) { - _logger.severe( - "Error getting face crops for faceIDs: ${faces.map((face) => face.faceID).toList()}", - e, - s, - ); if (fetchAttempt <= _retryLimit) { + final backoff = Duration( + milliseconds: 100 * pow(2, fetchAttempt + 1).toInt(), + ); + await Future.delayed(backoff); + _logger.warning( + "Error getting face crops for faceIDs: ${faces.map((face) => face.faceID).toList()}, retrying (attempt ${fetchAttempt + 1}) in ${backoff.inMilliseconds} ms", + e, + s, + ); return getCachedFaceCrops( enteFile, faces, @@ -127,6 +132,11 @@ Future?> getCachedFaceCrops( useFullFile: useFullFile, ); } + _logger.severe( + "Error getting face crops for faceIDs: ${faces.map((face) => face.faceID).toList()}", + e, + s, + ); } else { _logger.info( "Stopped getting face crops for faceIDs: ${faces.map((face) => face.faceID).toList()} due to $e",