π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Reduce noise for expected ML skips
laurenspriembee99f48c28c
diff --git a/mobile/apps/photos/lib/services/machine_learning/ml_indexing_isolate.dart b/mobile/apps/photos/lib/services/machine_learning/ml_indexing_isolate.dartindex 8ee9630856..3f6c142d81 100644--- a/mobile/apps/photos/lib/services/machine_learning/ml_indexing_isolate.dart+++ b/mobile/apps/photos/lib/services/machine_learning/ml_indexing_isolate.dart@@ -104,6 +104,9 @@ class MLIndexingIsolate extends SuperIsolate {}result = MLResult.fromJsonString(resultJsonString);} catch (e, s) {+ if (isExpectedMlSkipError(e)) {+ rethrow;+ }_logger.severe("Could not analyze image with ID ${instruction.fileKey} \n",e,diff --git a/mobile/apps/photos/lib/services/machine_learning/ml_service.dart b/mobile/apps/photos/lib/services/machine_learning/ml_service.dartindex 7c6a2a2e0f..cb95b14f89 100644--- a/mobile/apps/photos/lib/services/machine_learning/ml_service.dart+++ b/mobile/apps/photos/lib/services/machine_learning/ml_service.dart@@ -695,25 +695,20 @@ class MLService {_logger.info("ML result for fileID ${result.fileId} stored remote+local");return actuallyRanML;} catch (e, s) {- final String errorString = e.toString();final String format = instruction.file.displayName.split('.').last;final int? size = instruction.file.fileSize;final fileType = instruction.file.fileType;- final bool acceptedIssue =- errorString.contains('ThumbnailRetrievalException') ||- errorString.contains('InvalidImageFormatException') ||- errorString.contains('UnhandledExifOrientation') ||- errorString.contains('FileSizeTooLargeForMobileIndexing');+ final bool acceptedIssue = isExpectedMlSkipError(e);if (acceptedIssue) {- _logger.severe(- '$errorString for fileID ${instruction.fileKey} (format $format, type $fileType, size $size), storing empty results so indexing does not get stuck',- e,- s,+ _logger.warning(+ "Skipping ML indexing for fileID ${instruction.fileKey} (format $format, type $fileType, size $size): ${formatExpectedMlSkipReasonForLogs(e)}",);+ final storedMarkers = <String>[];if (instruction.shouldRunFaces) {await mlDataDB.bulkInsertFaces([Face.empty(instruction.fileKey, error: true)],);+ storedMarkers.add("faces");}if (instruction.shouldRunClip) {if (instruction.isOffline) {@@ -723,13 +718,18 @@ class MLService {instruction.file,);}+ storedMarkers.add("clip");}if (instruction.shouldRunPets) {await mlDataDB.deletePetDataForFiles([instruction.fileKey]);await mlDataDB.bulkInsertPetFaces([DBPetFace.empty(instruction.fileKey, error: true)],);+ storedMarkers.add("pets");}+ _logger.info(+ "Stored empty ML result markers for fileID ${instruction.fileKey}: ${storedMarkers.join(', ')}",+ );return true;}_logger.severe(diff --git a/mobile/apps/photos/lib/utils/ml_util.dart b/mobile/apps/photos/lib/utils/ml_util.dartindex d2bff9c7f0..a6dfdaaaed 100644--- a/mobile/apps/photos/lib/utils/ml_util.dart+++ b/mobile/apps/photos/lib/utils/ml_util.dart@@ -747,14 +747,9 @@ Future<MLResult> analyzeImageRust(Map args) async {rethrow;}- _logger.warning(- "Rust decode failed for fileID $enteFileID (format: $fileFormat), retrying with JPEG fallback",- e,- s,- );if (_shouldSkipJpegDecodeFallback(fileFormat)) {_logger.warning(- "Skipping JPEG fallback for fileID $enteFileID (format: $fileFormat) because flutter_image_compress is known to crash on unsupported RAW input",+ "Rust decode failed for fileID $enteFileID (format: $fileFormat); skipping JPEG fallback for known-unsupported RAW input",);throw _asInvalidImageFormatExceptionForRustDecodeFailure(enteFileID: enteFileID,@@ -762,19 +757,20 @@ Future<MLResult> analyzeImageRust(Map args) async {primaryError: e,);}+ _logger.warning(+ "Rust decode failed for fileID $enteFileID (format: $fileFormat), retrying with JPEG fallback",+ );final _DecodeFallbackFile? fallback;try {fallback = await _createJpegDecodeFallbackFile(imagePath: imagePath);} catch (fallbackError, fallbackStack) {- _logger.severe(- "JPEG fallback conversion threw for fileID $enteFileID (format: $fileFormat)",- fallbackError,- fallbackStack,- );if (_shouldStoreEmptyResultForRustDecodeFailure(primaryError: e,fallbackError: fallbackError,)) {+ _logger.warning(+ "JPEG fallback conversion failed for fileID $enteFileID (format: $fileFormat); storing empty result instead",+ );throw _asInvalidImageFormatExceptionForRustDecodeFailure(enteFileID: enteFileID,fileFormat: fileFormat,@@ -782,6 +778,11 @@ Future<MLResult> analyzeImageRust(Map args) async {fallbackError: fallbackError,);}+ _logger.severe(+ "JPEG fallback conversion threw for fileID $enteFileID (format: $fileFormat)",+ fallbackError,+ fallbackStack,+ );rethrow;}if (fallback == null) {@@ -811,15 +812,13 @@ Future<MLResult> analyzeImageRust(Map args) async {"Rust decode fallback succeeded for fileID $enteFileID (original format: $fileFormat)",);} catch (retryError, retryStack) {- _logger.severe(- "Rust decode fallback retry failed for fileID $enteFileID (original format: $fileFormat)",- retryError,- retryStack,- );if (_shouldStoreEmptyResultForRustDecodeFailure(primaryError: e,fallbackError: retryError,)) {+ _logger.warning(+ "Rust decode fallback retry failed for fileID $enteFileID (format: $fileFormat); storing empty result instead",+ );throw _asInvalidImageFormatExceptionForRustDecodeFailure(enteFileID: enteFileID,fileFormat: fileFormat,@@ -827,6 +826,11 @@ Future<MLResult> analyzeImageRust(Map args) async {fallbackError: retryError,);}+ _logger.severe(+ "Rust decode fallback retry failed for fileID $enteFileID (original format: $fileFormat)",+ retryError,+ retryStack,+ );rethrow;} finally {await _cleanupDecodeFallback(fallback);@@ -927,11 +931,44 @@ Future<MLResult> analyzeImageRust(Map args) async {return result;} catch (e, s) {+ if (isExpectedMlSkipError(e)) {+ rethrow;+ }_logger.severe("Could not analyze image with Rust pipeline", e, s);rethrow;}}+bool isExpectedMlSkipError(Object error) {+ final message = _normalizedErrorMessage(error);+ const acceptedIssueMarkers = <String>[+ "thumbnailretrievalexception",+ "invalidimageformatexception",+ "unhandledexiforientation",+ "filesizetoolargeformobileindexing",+ ];+ return acceptedIssueMarkers.any(message.contains);+}++String formatExpectedMlSkipReasonForLogs(Object error) {+ final normalized = _normalizedErrorMessage(error);+ if (normalized.contains("invalidimageformatexception")) {+ return "image decode failed";+ }+ if (normalized.contains("thumbnailretrievalexception")) {+ return "thumbnail retrieval failed";+ }+ if (normalized.contains("unhandledexiforientation")) {+ return "unsupported EXIF orientation";+ }+ if (normalized.contains("filesizetoolargeformobileindexing")) {+ return "file is too large for mobile indexing";+ }+ final compact = _stripExceptionPrefixes(error.toString()).trim();+ final firstLine = compact.split('\n').first.trim();+ return firstLine.isEmpty ? "unknown ML skip reason" : firstLine;+}+bool _isRustDecodeIssue(Object error) {final message = error.toString().toLowerCase();return message.contains("decode error");@@ -1028,6 +1065,15 @@ String _normalizedErrorMessage(Object error) {return error.toString().toLowerCase();}+String _stripExceptionPrefixes(String message) {+ var stripped = message.trimLeft();+ const prefix = "Exception: ";+ while (stripped.startsWith(prefix)) {+ stripped = stripped.substring(prefix.length);+ }+ return stripped;+}+Exception _asInvalidImageFormatExceptionForRustDecodeFailure({required int enteFileID,required String fileFormat,