π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Better full file prefetch and don't wait on full file for auto progress animation
laurenspriem833226364251
diff --git a/mobile/apps/photos/lib/ui/home/memories/full_screen_memory.dart b/mobile/apps/photos/lib/ui/home/memories/full_screen_memory.dartindex 2a878f2f52..1210fa752d 100644--- a/mobile/apps/photos/lib/ui/home/memories/full_screen_memory.dart+++ b/mobile/apps/photos/lib/ui/home/memories/full_screen_memory.dart@@ -116,17 +116,17 @@ class _FullScreenMemoryDataUpdaterState_wasConnected = true;// Release all refs we bumped so that ZoomableImage's handler can// decrement to 0 and cancel. Current file has 2 refs (bulk preload +- // ZoomableImage); next file also has 2 (bulk preload + per-index- // preloadThumbnail(nextFile) in the ValueListenableBuilder), so an- // extra release is needed for it too or its stale completer survives.+ // ZoomableImage); each lookahead file also has 2 (bulk preload ++ // per-index preloadThumbnail in the ValueListenableBuilder), so an+ // extra release is needed for each or its stale completer survives.for (final memory in widget.memories) {removePendingGetThumbnailRequestIfAny(memory.file);}- final nextIndex = indexNotifier.value + 1;- if (nextIndex < widget.memories.length) {- removePendingGetThumbnailRequestIfAny(- widget.memories[nextIndex].file,- );+ final currentIndex = indexNotifier.value;+ for (var i = 1; i <= _lookaheadCap; i++) {+ final j = currentIndex + i;+ if (j >= widget.memories.length) break;+ removePendingGetThumbnailRequestIfAny(widget.memories[j].file);}Bus.instance.fire(RetryFailedImageLoadEvent());// Re-kick on a microtask so the event handler runs first and clears@@ -142,6 +142,12 @@ class _FullScreenMemoryDataUpdaterState// per-index preload in the ValueListenableBuilder.static const _bulkThumbnailPreloadCap = 100;+ // How many files ahead of the current index to keep warming (thumbnail ++ // original). The per-file 5s slideshow cadence can't outpace multi-second+ // original downloads on a one-deep pipeline, so we keep several in flight.+ // preloadFile no-ops for videos, so this stays thumbnail-only for those.+ static const _lookaheadCap = 3;+void _preloadAllThumbnails() {for (final memory in widget.memories.take(_bulkThumbnailPreloadCap)) {preloadThumbnail(memory.file);@@ -523,10 +529,14 @@ class _FullScreenMemoryState extends State<FullScreenMemory> {ValueListenableBuilder<int>(valueListenable: inheritedData.indexNotifier,builder: (context, index, _) {- if (index < inheritedData.memories.length - 1) {- final nextFile = inheritedData.memories[index + 1].file;- preloadThumbnail(nextFile);- preloadFile(nextFile);+ for (var i = 1;+ i <= _FullScreenMemoryDataUpdaterState._lookaheadCap;+ i++) {+ final j = index + i;+ if (j >= inheritedData.memories.length) break;+ final file = inheritedData.memories[j].file;+ preloadThumbnail(file);+ preloadFile(file);}final currentMemory = inheritedData.memories[index];final isVideo =diff --git a/mobile/apps/photos/lib/ui/viewer/file/zoomable_image.dart b/mobile/apps/photos/lib/ui/viewer/file/zoomable_image.dartindex 3c0c80d2d6..3bb706d08c 100644--- a/mobile/apps/photos/lib/ui/viewer/file/zoomable_image.dart+++ b/mobile/apps/photos/lib/ui/viewer/file/zoomable_image.dart@@ -67,6 +67,10 @@ class _ZoomableImageState extends State<ZoomableImage> {bool _pendingFinalImageRetry = false;bool _convertToSupportedFormat = false;bool _showingThumbnailFallback = false;+ // onFinalFileLoad drives memory-slideshow auto-advance; fire it once as+ // soon as any presentable frame lands (small/large thumb or final), so+ // the timer isn't gated on the full original download.+ bool _firedOnReady = false;ValueChanged<PhotoViewScaleState>? _scaleStateChangedCallback;bool _isZooming = false;PhotoViewController _photoViewController = PhotoViewController();@@ -334,12 +338,25 @@ class _ZoomableImageState extends State<ZoomableImage> {);}+ // Deferred via microtask so synchronous callers inside build() (the+ // cached-thumbnail branches of _loadNetworkImage / _loadLocalImage) don't+ // mutate parent state during the current build phase.+ void _notifyReadyOnce() {+ if (_firedOnReady) return;+ _firedOnReady = true;+ scheduleMicrotask(() {+ if (!mounted) return;+ widget.onFinalFileLoad?.call(memoryDuration: 5);+ });+ }+void _loadNetworkImage() {if (!_loadedSmallThumbnail && !_loadedFinalImage) {final cachedThumbnail = ThumbnailInMemoryLruCache.get(_photo);if (cachedThumbnail != null) {_imageProvider = Image.memory(cachedThumbnail).image;_loadedSmallThumbnail = true;+ _notifyReadyOnce();} else {getThumbnailFromServer(_photo).then((file) {final imageProvider = Image.memory(file).image;@@ -350,6 +367,7 @@ class _ZoomableImageState extends State<ZoomableImage> {_imageProvider = imageProvider;_loadedSmallThumbnail = true;});+ _notifyReadyOnce();}}).catchError((e) {_logger.severe("Could not load image " + _photo.toString());@@ -399,6 +417,7 @@ class _ZoomableImageState extends State<ZoomableImage> {if (cachedThumbnail != null) {_imageProvider = Image.memory(cachedThumbnail).image;_loadedSmallThumbnail = true;+ _notifyReadyOnce();}}@@ -457,6 +476,7 @@ class _ZoomableImageState extends State<ZoomableImage> {_imageProvider = imageProvider;_loadedLargeThumbnail = true;});+ _notifyReadyOnce();}});}@@ -522,7 +542,7 @@ class _ZoomableImageState extends State<ZoomableImage> {_loadedFinalImage = true;_logger.info("Final image loaded");});- widget.onFinalFileLoad?.call(memoryDuration: 5);+ _notifyReadyOnce();}Future<void> _updatePhotoViewController({@@ -592,6 +612,7 @@ class _ZoomableImageState extends State<ZoomableImage> {InheritedDetailPageState.maybeOf(context)?.showingThumbnailFallbackNotifier.value = detailPageFileIdentifier(_photo);+ _notifyReadyOnce();}return;}@@ -646,6 +667,7 @@ class _ZoomableImageState extends State<ZoomableImage> {InheritedDetailPageState.maybeOf(context)?.showingThumbnailFallbackNotifier.value = detailPageFileIdentifier(_photo);+ _notifyReadyOnce();}}}