High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
perf(mobile): remove load of thumbnails in the image provider (#17773)
Toni1de2eae12d6a
diff --git a/mobile/lib/providers/image/immich_local_image_provider.dart b/mobile/lib/providers/image/immich_local_image_provider.dartindex c152934333..4c77ee4b56 100644--- a/mobile/lib/providers/image/immich_local_image_provider.dart+++ b/mobile/lib/providers/image/immich_local_image_provider.dart@@ -53,50 +53,35 @@ class ImmichLocalImageProvider extends ImageProvider<ImmichLocalImageProvider> {ImageDecoderCallback decode,StreamController<ImageChunkEvent> chunkEvents,) async* {- ui.ImmutableBuffer? buffer;try {final local = asset.local;if (local == null) {throw StateError('Asset ${asset.fileName} has no local data');}- var thumbBytes = await local- .thumbnailDataWithSize(const ThumbnailSize.square(256), quality: 80);- if (thumbBytes == null) {- throw StateError("Loading thumbnail for ${asset.fileName} failed");- }- buffer = await ui.ImmutableBuffer.fromUint8List(thumbBytes);- thumbBytes = null;- yield await decode(buffer);- buffer = null;-switch (asset.type) {case AssetType.image:final File? file = await local.originFile;if (file == null) {throw StateError("Opening file for asset ${asset.fileName} failed");}- buffer = await ui.ImmutableBuffer.fromFilePath(file.path);+ final buffer = await ui.ImmutableBuffer.fromFilePath(file.path);yield await decode(buffer);- buffer = null;break;case AssetType.video:final size = ThumbnailSize(width.ceil(), height.ceil());- thumbBytes = await local.thumbnailDataWithSize(size);+ final thumbBytes = await local.thumbnailDataWithSize(size);if (thumbBytes == null) {throw StateError("Failed to load preview for ${asset.fileName}");}- buffer = await ui.ImmutableBuffer.fromUint8List(thumbBytes);- thumbBytes = null;+ final buffer = await ui.ImmutableBuffer.fromUint8List(thumbBytes);yield await decode(buffer);- buffer = null;break;default:throw StateError('Unsupported asset type ${asset.type}');}} catch (error, stack) {log.severe('Error loading local image ${asset.fileName}', error, stack);- buffer?.dispose();} finally {chunkEvents.close();}diff --git a/mobile/lib/providers/image/immich_remote_image_provider.dart b/mobile/lib/providers/image/immich_remote_image_provider.dartindex 9e1d8aa120..d5189fa4fc 100644--- a/mobile/lib/providers/image/immich_remote_image_provider.dart+++ b/mobile/lib/providers/image/immich_remote_image_provider.dart@@ -57,12 +57,6 @@ class ImmichRemoteImageProviderAppSettingsEnum.loadOriginal.defaultValue,);- /// Whether to load the preview thumbnail first or not- bool get _loadPreview => Store.get(- AppSettingsEnum.loadPreview.storeKey,- AppSettingsEnum.loadPreview.defaultValue,- );-// Streams in each stage of the image as we ask for itStream<ui.Codec> _codec(ImmichRemoteImageProvider key,@@ -70,21 +64,6 @@ class ImmichRemoteImageProviderImageDecoderCallback decode,StreamController<ImageChunkEvent> chunkEvents,) async* {- // Load a preview to the chunk events- if (_loadPreview) {- final preview = getThumbnailUrlForRemoteId(- key.assetId,- type: api.AssetMediaSize.thumbnail,- );-- yield await ImageLoader.loadImageFromCache(- preview,- cache: cache,- decode: decode,- chunkEvents: chunkEvents,- );- }-// Load the higher resolution version of the imagefinal url = getThumbnailUrlForRemoteId(key.assetId,