Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Stop retrying unsupported face thumbnail formats

laurenspriembc27f14c7773
diff --git a/mobile/apps/photos/changes/unsupported-face-preview-retries.md b/mobile/apps/photos/changes/unsupported-face-preview-retries.md
new file mode 100644
index 0000000000..75efd3615d
--- /dev/null
+++ b/mobile/apps/photos/changes/unsupported-face-preview-retries.md
@@ -0,0 +1 @@
+- Reduced repeated attempts to generate face previews from unsupported image formats, allowing thumbnail fallback to load sooner.
diff --git a/mobile/apps/photos/lib/services/machine_learning/face_thumbnail_generator.dart b/mobile/apps/photos/lib/services/machine_learning/face_thumbnail_generator.dart
index 4efc36d49c..2aead4df8b 100644
--- a/mobile/apps/photos/lib/services/machine_learning/face_thumbnail_generator.dart
+++ b/mobile/apps/photos/lib/services/machine_learning/face_thumbnail_generator.dart
@@ -5,6 +5,19 @@ import "package:photos/models/ml/face/box.dart";
import "package:photos/utils/isolate/isolate_operations.dart";
import "package:photos/utils/isolate/super_isolate.dart";
+final _unsupportedImageFormatError = RegExp(
+ r'^Exception: decode error: (The file extension .+ was not recognized as an image format|The image format .+ is not supported)$',
+);
+
+class UnsupportedFaceThumbnailException implements Exception {
+ final Object cause;
+
+ const UnsupportedFaceThumbnailException(this.cause);
+
+ @override
+ String toString() => "UnsupportedFaceThumbnailException: $cause";
+}
+
@pragma('vm:entry-point')
class FaceThumbnailGenerator extends SuperIsolate {
@override
@@ -42,6 +55,9 @@ class FaceThumbnailGenerator extends SuperIsolate {
} catch (e, s) {
_logger.severe("Failed to generate face thumbnails", e, s);
+ if (_unsupportedImageFormatError.hasMatch(e.toString())) {
+ Error.throwWithStackTrace(UnsupportedFaceThumbnailException(e), s);
+ }
rethrow;
}
}
diff --git a/mobile/apps/photos/lib/utils/face/face_thumbnail_cache.dart b/mobile/apps/photos/lib/utils/face/face_thumbnail_cache.dart
index 6b64f3f786..a4bcc8c9cc 100644
--- a/mobile/apps/photos/lib/utils/face/face_thumbnail_cache.dart
+++ b/mobile/apps/photos/lib/utils/face/face_thumbnail_cache.dart
@@ -240,7 +240,8 @@ Future<Map<String, Uint8List>?> getCachedFaceCrops(
}
return faceIdToCrop.isEmpty ? null : faceIdToCrop;
} catch (e, s) {
- if (e is! TaskQueueTimeoutException &&
+ if (e is! UnsupportedFaceThumbnailException &&
+ e is! TaskQueueTimeoutException &&
e is! TaskQueueOverflowException &&
e is! TaskQueueCancelledException) {
if (fetchAttempt <= _retryLimit) {