Skip to content

armgit / ente

Public Imported from GitHub
0

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

Improve lru cache thumbnail rendering speed when scrolling gallery by precaching it it flutter's image cache

ashilknfbdec00a620d
diff --git a/mobile/apps/photos/lib/ui/viewer/file/thumbnail_widget.dart b/mobile/apps/photos/lib/ui/viewer/file/thumbnail_widget.dart
index a8ebac8086..3cd3488a85 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/thumbnail_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/thumbnail_widget.dart
@@ -245,12 +245,12 @@ class _ThumbnailWidgetState extends State<ThumbnailWidget> {
final cachedSmallThumbnail =
ThumbnailInMemoryLruCache.get(widget.file, thumbnailSmallSize);
if (cachedSmallThumbnail != null) {
- _imageProvider = Image.memory(
+ final imageProvider = Image.memory(
cachedSmallThumbnail,
cacheHeight: optimizedImageHeight,
cacheWidth: optimizedImageWidth,
).image;
- _hasLoadedThumbnail = true;
+ _cacheAndRender(imageProvider);
} else {
if (widget.diskLoadDeferDuration != null) {
Future.delayed(widget.diskLoadDeferDuration!, () {
@@ -383,12 +383,12 @@ class _ThumbnailWidgetState extends State<ThumbnailWidget> {
_isLoadingRemoteThumbnail = true;
final cachedThumbnail = ThumbnailInMemoryLruCache.get(widget.file);
if (cachedThumbnail != null) {
- _imageProvider = Image.memory(
+ final imageProvider = Image.memory(
cachedThumbnail,
cacheHeight: optimizedImageHeight,
cacheWidth: optimizedImageWidth,
).image;
- _hasLoadedThumbnail = true;
+ _cacheAndRender(imageProvider);
return;
}