Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Treat Rust decode fallback nulls as empty ML results

laurenspriemd569704e596e
diff --git a/mobile/apps/photos/lib/utils/image_ml_util.dart b/mobile/apps/photos/lib/utils/image_ml_util.dart
index 72a14704d2..cfc0d07242 100644
--- a/mobile/apps/photos/lib/utils/image_ml_util.dart
+++ b/mobile/apps/photos/lib/utils/image_ml_util.dart
@@ -152,8 +152,13 @@ Uint8List? createSafeJpegDecodeFallbackBytesFromData(Uint8List imageData) {
}
final jpeg = img.encodeJpg(decoded, quality: 95);
return Uint8List.fromList(jpeg);
- } catch (e, s) {
- _logger.warning("Safe JPEG conversion failed", e, s);
+ } catch (e) {
+ final firstLine = e.toString().split('\n').first.trim();
+ _logger.warning(
+ firstLine.isEmpty
+ ? "Safe JPEG conversion failed"
+ : "Safe JPEG conversion failed: $firstLine",
+ );
return null;
}
}
diff --git a/mobile/apps/photos/lib/utils/ml_util.dart b/mobile/apps/photos/lib/utils/ml_util.dart
index 6d519d8a2f..173a18665f 100644
--- a/mobile/apps/photos/lib/utils/ml_util.dart
+++ b/mobile/apps/photos/lib/utils/ml_util.dart
@@ -775,21 +775,24 @@ Future<MLResult> analyzeImageRust(Map args) async {
rethrow;
}
if (fallback == null) {
- _logger.severe(
- "JPEG fallback conversion returned null/empty bytes for fileID $enteFileID (format: $fileFormat)",
- e,
- s,
- );
if (_shouldStoreEmptyResultForRustDecodeFailure(
primaryError: e,
fallbackReturnedEmpty: true,
)) {
+ _logger.warning(
+ "JPEG fallback conversion returned null/empty bytes for fileID $enteFileID (format: $fileFormat); storing empty result instead",
+ );
throw _asInvalidImageFormatExceptionForRustDecodeFailure(
enteFileID: enteFileID,
fileFormat: fileFormat,
primaryError: e,
);
}
+ _logger.severe(
+ "JPEG fallback conversion returned null/empty bytes for fileID $enteFileID (format: $fileFormat)",
+ e,
+ s,
+ );
throw Exception(
"RustMLDecodeFallbackFailed: JPEG fallback conversion returned null/empty bytes for fileID $enteFileID (format: $fileFormat)",
);
@@ -968,10 +971,7 @@ bool _shouldStoreEmptyResultForRustDecodeFailure({
bool fallbackReturnedEmpty = false,
}) {
if (fallbackReturnedEmpty) {
- // Empty output from FlutterImageCompress is ambiguous on Android and can
- // happen after internal OOM retries. Treat it as transient so valid
- // images are retried instead of being permanently marked invalid.
- return false;
+ return _isFileSpecificDecodeFailure(primaryError);
}
if (fallbackError == null) {