[BUG] Mobile app: Backup settings page takes a long time to load state #366

Closed
opened 2026-02-04 20:02:58 +03:00 by OVERLORD · 8 comments
Owner

Originally created by @bo0tzz on GitHub (Oct 16, 2022).

When the mobile app's backup_controller_page is initializing, one of the steps in getting its state involves loading the list of local albums that are present on the device. This is implemented in _getBackupAlbumsInfo() simply by looping through all the albums on the device.
This process happens synchronously when instantiating the backup settings view. Something about it is very slow, and as it blocks the loading of the state, it takes quite a while for the view to be loaded properly (displaying incorrect settings, counts, etc until then).

The exact reason for the slowness is unclear. It could be in our code, but the photo_manager library we use is also suspicious. As one example, the PhotoManager.getAssetPathList() function loops through all the assets in order to get a total asset count. To determine the exact cause of the slowness, actual profiling would be desired.

Regardless of the reason this album loading process is slow though, there are some steps we can take to mitigate it. This would include for example caching the local albums data and/or loading it asynchronously separate from the other backup state. People who are more familiar than me with the mobile app code might have other ideas as well.

All of the above is based on Android. I do not know whether the iOS app has this issue as well.

Originally created by @bo0tzz on GitHub (Oct 16, 2022). When the mobile app's backup_controller_page is initializing, one of the steps in getting its state involves loading the list of local albums that are present on the device. This is implemented in [`_getBackupAlbumsInfo()`](https://github.com/immich-app/immich/blob/47b73a5b64ec7ee53d51564c3807e6e93279511f/mobile/lib/modules/backup/providers/backup.provider.dart#L175) simply by looping through all the albums on the device. This process happens synchronously when instantiating the backup settings view. Something about it is very slow, and as it blocks the loading of the state, it takes quite a while for the view to be loaded properly (displaying incorrect settings, counts, etc until then). The exact reason for the slowness is unclear. It could be in our code, but the photo_manager library we use is also suspicious. As one example, the `PhotoManager.getAssetPathList()` function [loops through all the assets](https://github.com/fluttercandies/flutter_photo_manager/blob/main/android/src/main/kotlin/com/fluttercandies/photo_manager/core/PhotoManager.kt#L53-L55) in order to get a total asset count. To determine the exact cause of the slowness, actual profiling would be desired. Regardless of the reason this album loading process is slow though, there are some steps we can take to mitigate it. This would include for example caching the local albums data and/or loading it asynchronously separate from the other backup state. People who are more familiar than me with the mobile app code might have other ideas as well. All of the above is based on Android. I do not know whether the iOS app has this issue as well.
OVERLORD added the 📱mobile label 2026-02-04 20:02:58 +03:00
Author
Owner

@gorootde commented on GitHub (Nov 4, 2022):

I am experiencing the very same issue on iOS. As soon as I go to the page to select the albums for backup, the loading indicator is displayed and the page never finishes loading. My photo Library contains ~340GB of data in ~50 Albums.

I've tried to keep the page open (and prevented the phone from sleeping) for more than 15 minutes. Even this long time wasn't enough to finish loading.

@gorootde commented on GitHub (Nov 4, 2022): I am experiencing the very same issue on iOS. As soon as I go to the page to select the albums for backup, the loading indicator is displayed and the page never finishes loading. My photo Library contains ~340GB of data in ~50 Albums. I've tried to keep the page open (and prevented the phone from sleeping) for more than 15 minutes. Even this long time wasn't enough to finish loading.
Author
Owner

@alextran1502 commented on GitHub (Nov 4, 2022):

@gorootde Do you have those photos on iCloud with the Optimized Storage setting enabled?

@alextran1502 commented on GitHub (Nov 4, 2022): @gorootde Do you have those photos on iCloud with the Optimized Storage setting enabled?
Author
Owner

@gorootde commented on GitHub (Nov 4, 2022):

Yes I do.

@gorootde commented on GitHub (Nov 4, 2022): Yes I do.
Author
Owner

@alextran1502 commented on GitHub (Nov 4, 2022):

@gorootde So that means the photos are not on the device. That is why the scan result doesn't show any. The app currently works with photos and videos physically on the device.

@alextran1502 commented on GitHub (Nov 4, 2022): @gorootde So that means the photos are not on the device. That is why the scan result doesn't show any. The app currently works with photos and videos physically on the device.
Author
Owner

@gorootde commented on GitHub (Nov 4, 2022):

Thanks for pointing that out. I assumed because of this comment that it works (but is slow). However, not even the photos which are physically on my device (e.g. a photo taken a few seconds ago) show up. I assume this is the expected behaviour until #477 is fixed

@gorootde commented on GitHub (Nov 4, 2022): Thanks for pointing that out. I assumed because of [this comment](https://github.com/immich-app/immich/issues/477#issuecomment-1244793818) that it works (but is slow). However, not even the photos which are physically on my device (e.g. a photo taken a few seconds ago) show up. I assume this is the expected behaviour until #477 is fixed
Author
Owner

@alextran1502 commented on GitHub (Nov 5, 2022):

Thanks for pointing that out. I assumed because of this comment that it works (but is slow). However, not even the photos which are physically on my device (e.g. a photo taken a few seconds ago) show up. I assume this is the expected behaviour until #477 is fixed

@gorootde I thought so too but apparently not.

@alextran1502 commented on GitHub (Nov 5, 2022): > Thanks for pointing that out. I assumed because of [this comment](https://github.com/immich-app/immich/issues/477#issuecomment-1244793818) that it works (but is slow). However, not even the photos which are physically on my device (e.g. a photo taken a few seconds ago) show up. I assume this is the expected behaviour until #477 is fixed @gorootde I thought so too but apparently not.
Author
Owner

@eygraber commented on GitHub (Sep 4, 2023):

I experienced this, and if I type in the search bar and then clear the query then all the results show.

@eygraber commented on GitHub (Sep 4, 2023): I experienced this, and if I type in the search bar and then clear the query then all the results show.
Author
Owner

@EnochPrime commented on GitHub (Sep 20, 2023):

I believe this is solved now thanks to #3905.

@EnochPrime commented on GitHub (Sep 20, 2023): I believe this is solved now thanks to #3905.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#366