Skip to content

armgit / ente

Public Imported from GitHub
0

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

Validate remote images by decoding in isolate before rendering

Prateek Sunalefceb0d66c6e
diff --git a/mobile/apps/photos/lib/services/home_widget_service.dart b/mobile/apps/photos/lib/services/home_widget_service.dart
index 4dd00724e5..24755412f7 100644
--- a/mobile/apps/photos/lib/services/home_widget_service.dart
+++ b/mobile/apps/photos/lib/services/home_widget_service.dart
@@ -256,8 +256,18 @@ class HomeWidgetService {
return false;
}
- // Read bytes into memory for widget rendering
+ // Read bytes into memory
final Uint8List imageBytes = await imageFile.readAsBytes();
+
+ // Decode in isolate to validate and avoid blocking main thread
+ final ui.Image decodedImage = await compute(
+ _decodeImageInIsolate,
+ imageBytes,
+ );
+
+ // Clean up decoded image (we just needed it for validation)
+ decodedImage.dispose();
+
imageProvider = MemoryImage(imageBytes);
}
// Remote videos/live photos fall back to V1 (avoid large downloads)