I
Immichโ€ข2y ago
Azsde

Android app take forever to list albums

Hello everyone, I have set up my server and am having issues with the app, it takes forever to load the '' albums '', I managed to have them show up once but I cannot see them anymore. Does anyone have a solution?
No description
110 Replies
Alex Tran
Alex Tranโ€ข2y ago
which phone model do you have? How many photos/videos do you have on your phone? Can you provide the mobile app log?
Azsde
AzsdeOPโ€ข2y ago
I have a Galaxy Z Fold 4, I have quite a large number of photo/videos in the DCIM folder (3172 to be exact)
Alex Tran
Alex Tranโ€ข2y ago
that is not large by any mean, hmm, not sure what is happening there. Can you go into the app setting > advanced > prefer remote images, turn it on and then try again
Azsde
AzsdeOPโ€ข2y ago
Alright, for the logs do you need ADB logs ? Or the one from the app directly ?
Alex Tran
Alex Tranโ€ข2y ago
No just the app log from the profile drawer > log
Azsde
AzsdeOPโ€ข2y ago
Alright
Alex Tran
Alex Tranโ€ข2y ago
Do you allow permission to access all photos when you first started the app?
Azsde
AzsdeOPโ€ข2y ago
I think so, let me check Yeah, it has permissions for pictures and videos Setting "Prefer remote images" doesn't fix the issue
Alex Tran
Alex Tranโ€ข2y ago
navigate the that album selection page, wait a few second, navigate back to the back up page, wait a few second then back to the selection page, does it work? Please export the app log and send it here so I can take a look
Azsde
AzsdeOPโ€ข2y ago
Still buggy, I'm exporting the logs right now
Alex Tran
Alex Tranโ€ข2y ago
Hmm I see an error, somehow the app cannot get all the assets from the server, is this a brand new instance?
Azsde
AzsdeOPโ€ข2y ago
yes But I don't see how remote assets can affect local albums from being listed
Alex Tran
Alex Tranโ€ข2y ago
I am just suspecting, I don't think it is the cause either
Azsde
AzsdeOPโ€ข2y ago
Azsde
AzsdeOPโ€ข2y ago
I am trying to send a video capture of the issue
Alex Tran
Alex Tranโ€ข2y ago
Can you try reinstall the app?
Azsde
AzsdeOPโ€ข2y ago
Sure
Alex Tran
Alex Tranโ€ข2y ago
Thank you
Azsde
AzsdeOPโ€ข2y ago
From the play store right ? Great, now the immich app doesn't start at all ๐Ÿฅฒ it is stuck on the immich logo I'm rebooting my phone
Alex Tran
Alex Tranโ€ข2y ago
correct strange
Azsde
AzsdeOPโ€ข2y ago
Still stuck even after rebooting
Alex Tran
Alex Tranโ€ข2y ago
Can you access the server from the web
Azsde
AzsdeOPโ€ข2y ago
Yes Ah, the app finally launched
Alex Tran
Alex Tranโ€ข2y ago
were you using local IP or dns?
Azsde
AzsdeOPโ€ข2y ago
I cleared the storage and the cache so it was not trying to access the server But I have a reverse proxy to access my immich server
Alex Tran
Alex Tranโ€ข2y ago
Can you bypass that and access the server with local IP just to keep everything contained for debugging purposes
Azsde
AzsdeOPโ€ข2y ago
Yes I am accessing via the local IP And it still struggles to list all albums on my phone
Azsde
AzsdeOPโ€ข2y ago
No description
Alex Tran
Alex Tranโ€ข2y ago
hmm This is with newly install app and adequate permissions, correct?
Azsde
AzsdeOPโ€ข2y ago
Yes
Alex Tran
Alex Tranโ€ข2y ago
I am suspecting this is specific phone's model issue and without the phone I cannot really debug it. Are you a developer by any chance?
Azsde
AzsdeOPโ€ข2y ago
Yes I am I've worked on AOSP for 6+ years
Alex Tran
Alex Tranโ€ข2y ago
Do you mind installing the flutter toolchain and run the app under development on your phone to see if it catch any error?
Azsde
AzsdeOPโ€ข2y ago
But on the framework part, I have limited experience regarding androids apps but I should be able to figure it out Alright
Alex Tran
Alex Tranโ€ข2y ago
it is quite straight forward, here is a guide https://immich.app/docs/developer/setup#mobile-app
Setup | Immich
Environment
Alex Tran
Alex Tranโ€ข2y ago
let me know if I can assist
Azsde
AzsdeOPโ€ข2y ago
Alright, I'm on it (I'm surprised it doesn't use Android Studio :D)
Alex Tran
Alex Tranโ€ข2y ago
it does actually ๐Ÿ˜„ but just for installting drivers you can run the development environment in vscode entirely
Azsde
AzsdeOPโ€ข2y ago
cd immich oops Ok so I think I've setup everyhting What do I need to do to compile the app and get an APK ?
Alex Tran
Alex Tranโ€ข2y ago
you would run it in development mode run flutter doctor and check the output
Azsde
AzsdeOPโ€ข2y ago
No description
Azsde
AzsdeOPโ€ข2y ago
I've ran the command : flutter build apk --split-per-abi It does seem to trigger a build, I don't know if that is the "official" way to do it Build failed because I don't have the signing key (that's normal)
Alex Tran
Alex Tranโ€ข2y ago
Run flutter run for debug mode
Azsde
AzsdeOPโ€ข2y ago
I launched the same command with --debug and the APK built succesfully The debug APK behaves the same way I should type "flutter run" ?
Alex Tran
Alex Tranโ€ข2y ago
Yes
Azsde
AzsdeOPโ€ข2y ago
Alright Ok I do have an ADB log output and the apk launched onto my phone What do you need from here ?
Alex Tran
Alex Tranโ€ข2y ago
When you access the album selection page do you see anything logged?
Azsde
AzsdeOPโ€ข2y ago
I/ViewRootImpl@9fbccc7MainActivity: ViewPostIme pointer 0 I/ViewRootImpl@9fbccc7MainActivity: ViewPostIme pointer 1 I/flutter (23403): [INFO] [2023-08-29 12:28:25.266535] Found 36 local albums And then nothing
Azsde
AzsdeOPโ€ข2y ago
The logs now show this
Azsde
AzsdeOPโ€ข2y ago
( I need to leave for lunch, I'll be back soon) I'm back Do you need more logs ?
Alex Tran
Alex Tranโ€ข2y ago
I/flutter (23403): [INFO] [2023-08-29 12:29:40.495339] Not found albums or assets on the device to backup Hmm Are all the albums and photos/videos are on your local device?
Azsde
AzsdeOPโ€ข2y ago
Yes ( Using an Android emulator it works as expected without any issue)
Alex Tran
Alex Tranโ€ข2y ago
I am suspecting issue with photo_manager package we use to get the local photos and videos with your device's system API call
Azsde
AzsdeOPโ€ข2y ago
I know samsung is famous for doing weird stuff with the Android Framework
Alex Tran
Alex Tranโ€ข2y ago
yeah pretty strange :/
Azsde
AzsdeOPโ€ข2y ago
Do you want me to share my screen or something to try to pinpoint the issue ? I/flutter (26896): [INFO] [2023-08-29 13:46:33.495851] Found 36 local albums I do have this log but the app never finishes loading My friend also has a ZFold 4 and has the exact same issue
Azsde
AzsdeOPโ€ข2y ago
No description
Azsde
AzsdeOPโ€ข2y ago
No description
Azsde
AzsdeOPโ€ข2y ago
After a while they DO show up in the end That is a really weird behavior Is it possible to put breakpoints in the code ? @Alex I don't think the issue comes from the photo_manager package I've written a really quick and dirty app using flutter void _test() async { final PermissionState ps = await PhotoManager.requestPermissionExtend(); if (ps.hasAccess) { List<AssetPathEntity> albums = await PhotoManager.getAssetPathList(); print(albums); } } And it works instanteanously : I/flutter (21219): [AssetPathEntity(id: isAll, name: Recent), AssetPathEntity(id: -214169408, name: Instagram), AssetPathEntity(id: -1432612566, name: WhatsApp Video), AssetPathEntity(id: -786583970, name: Reddit), AssetPathEntity(id: 1519174419, name: Messenger), AssetPathEntity(id: 402919108, name: Whatsapp), AssetPathEntity(id: -613830029, name: Twitter), AssetPathEntity(id: 1028075469, name: Screenshots), AssetPathEntity(id: 1331207306, name: Seal), AssetPathEntity(id: -1744159402, name: DSphoto), AssetPathEntity(id: -1183850781, name: PowerDirector), AssetPathEntity(id: 1385037952, name: Screen Recorder), AssetPathEntity(id: -1104308479, name: Twitter), AssetPathEntity(id: -572399359, name: Telegram), AssetPathEntity(id: -680697881, name: WhatsApp Documents), AssetPathEntity(id: 1285198534, name: Facebook), AssetPathEntity(id: 540528482, name: Download), AssetPathEntity(id: -815228101, name: WhatsApp Animated Gifs), AssetPathEntity(id: -1829889111, name: WhatsApp Images), AssetPathEntity(id: 1389444597, name: ), AssetPath
Alex Tran
Alex Tranโ€ข2y ago
Hmm perhaps state management issue but then it would be present on all phone model, correct?
Azsde
AzsdeOPโ€ข2y ago
No description
Azsde
AzsdeOPโ€ข2y ago
This is from a fresh install, with the initial setup After the getAssetPathList first call Albums are correctly detected ( I've put a breakpoint to see the value of the variable)
Alex Tran
Alex Tranโ€ข2y ago
so for some reason the album aren't render on screen we can narrow down to the provider that handle render the album
Azsde
AzsdeOPโ€ข2y ago
Yeah and the UI is stuck "loading" Hm. The issue seems to come from the _getBackupAlbumsInfo function I've added a log at the end of the function which is printed only after a VERY long time By the way: D/flutter (32252): [INFO] [2023-08-29 15:24:30.617169] _getBackupAlbumsInfo takes 97761ms That's 1m36s to list the albums I will try to determine which part of the function is taking forever to finish Well, the thumbnail generation is taking forever ๐Ÿ˜„
Alex Tran
Alex Tranโ€ข2y ago
There is known issue with thumbnail generation on some android device reading from the disk let me find the issue
Alex Tran
Alex Tranโ€ข2y ago
GitHub
[BUG] Mobile app: Backup settings page takes a long time to load st...
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...
Alex Tran
Alex Tranโ€ข2y ago
GitHub
[BUG] Slow preview and pictures/video load from device memory ยท Iss...
The bug When loading from memory, the app starts to lag and the time required to load the previews goes to around 10s, 20s at times. It happened as soon as I updated the app to the 1.51.0 version. ...
Azsde
AzsdeOPโ€ข2y ago
The issue seems to be related to mine
Alex Tran
Alex Tranโ€ข2y ago
If you remove the code to get the thumbnail, does it work better?
Azsde
AzsdeOPโ€ข2y ago
Let me try I need to determine which line to comment to still have my albums listed
Alex Tran
Alex Tranโ€ข2y ago
which file are you looking at right now?
Azsde
AzsdeOPโ€ข2y ago
backup.provider.dart I need to update this line to use a "placeholder" thumbnail availableAlbum = availableAlbum.copyWith(thumbnailData: thumbnailData);
Alex Tran
Alex Tranโ€ข2y ago
it is a nullable value, you can remove it
Alex Tran
Alex Tranโ€ข2y ago
No description
Alex Tran
Alex Tranโ€ข2y ago
this whole block can be commented out
Azsde
AzsdeOPโ€ข2y ago
Alright, testing right now lol yeah it works Instantly
Alex Tran
Alex Tranโ€ข2y ago
ah nice ok I can start working on a fix
Azsde
AzsdeOPโ€ข2y ago
Here's a log trace when the issue happens, note that I've added those logs: I/flutter (14796): [INFO] [2023-08-29 15:34:00.648336] AZSDE - Hello before thumbnail I/flutter (14796): [INFO] [2023-08-29 15:35:08.595915] AZSDE - Hello after thumbnail
Azsde
AzsdeOPโ€ข2y ago
It would seem that OpenGLRenderer is trying to do something ? Let me see if I can pinpoint a little bit more on what is taking so long in this commented block
Alex Tran
Alex Tranโ€ข2y ago
Thank you for looking into this it has been an issue for a while
Thom
Thomโ€ข2y ago
Same issue on my Samsung S23 Snapdragon by the way. @Azsde are you shooting HEIC/HEIF by any chance instead of JPEG? My S23 suffers from this GH issue https://github.com/immich-app/immich/issues/2128 where heic's take really long do display in the timeline (whereas JPEGs are quite fast) (so I use the "use remote assets" workaround). Maybe it is related to this thumbnail generation problem.
GitHub
[BUG] Slow preview and pictures/video load from device memory ยท Iss...
The bug When loading from memory, the app starts to lag and the time required to load the previews goes to around 10s, 20s at times. It happened as soon as I updated the app to the 1.51.0 version. ...
Azsde
AzsdeOPโ€ข2y ago
It doesn't seem to be the case as my pictures do have the .jpeg extension ?
Thom
Thomโ€ข2y ago
Alright, then it's probably not related to heic files ๐Ÿ™‚
Azsde
AzsdeOPโ€ข2y ago
This line seems to be the culprit: log.info('AZSDE - Before get asset list'); final assetList = await album.getAssetListRange(start: 0, end: assetCountInAlbum); log.info('AZSDE - After get asset list'); The logs are showing I/flutter (24082): [INFO] [2023-08-29 16:00:25.354140] AZSDE - Before get asset list I/flutter (24082): [INFO] [2023-08-29 16:01:45.543699] AZSDE - After get asset list 1min20s to retrieve the asset list ?! Wow @Alex I'll update my "hello-world" app to add asset retrieval, I suspect I will have the same issue then
Alex Tran
Alex Tranโ€ข2y ago
hmm
Azsde
AzsdeOPโ€ข2y ago
Yeah, exactly as I suspected updating my hello world app produces the same issue The "recent" album on my phone has 36606 pictures
Alex Tran
Alex Tranโ€ข2y ago
Oh that is quite a lot
Azsde
AzsdeOPโ€ข2y ago
The first getAssetListRange call is taking forever
Alex Tran
Alex Tranโ€ข2y ago
how much storage do you have on your phone?
Azsde
AzsdeOPโ€ข2y ago
512Gb
Alex Tran
Alex Tranโ€ข2y ago
I see
Azsde
AzsdeOPโ€ข2y ago
But
Alex Tran
Alex Tranโ€ข2y ago
sdcard or built-in nvme?
Azsde
AzsdeOPโ€ข2y ago
Samsung phones are "stupid" They have a "recent" album which regroups EVERYTHING
Alex Tran
Alex Tranโ€ข2y ago
same thing for iOS ๐Ÿ˜„
Azsde
AzsdeOPโ€ข2y ago
That's stupid Especially that my REAL camera folder Has only 3172 items That being said, I don't know if it is "normal" for getAssetListRange to take such a long time, but the issue doesn't seem to be on Immich side
Alex Tran
Alex Tranโ€ข2y ago
Let me think of a better way to handle this case thank you for reporting and helping pin down the issue
Azsde
AzsdeOPโ€ข2y ago
You're welcome, thank you for such an awesome tool Maybe a better way to do it Would be to to only get the first picture directly ?
Alex Tran
Alex Tranโ€ข2y ago
yeah for that page it would probably work better that way the calculation still need to happen at some point
Azsde
AzsdeOPโ€ข2y ago
I am looking at their documentation Future<List<AssetEntity>> getAssetListRange({ required int start, required int end, }) async { assert(albumType == 1, 'Only album can request for assets.'); assert(start >= 0, 'The start must be greater than 0.'); assert(end > start, 'The end must be greater than start.'); We can't use this to get a single asset Since we need to specify a range From a quick look, they seem to have a getAssetListPaged method If it is named correctly, it might be the way to go ? As pagination is often used to retrieve larges amounts of data in chunks ?
Alex Tran
Alex Tranโ€ข2y ago
yeah this makes sense
Azsde
AzsdeOPโ€ข2y ago
Another approach would be to exclude the "recent" album Or at least make it optional But that doesn't fully resolve the issue
Alex Tran
Alex Tranโ€ข2y ago
This comes down to UX, some people want to upload everything on their phone, and if they have like 30 albums/folders to choose from, I think it might be bad UX. But a good point regardless, let me contemplate on this
Azsde
AzsdeOPโ€ข2y ago
Yeah, I can understand that some people might want this ๐Ÿ™‚ And as I said, it doesn't cover the case where someone whould have a large amount of assets in an album
Alex Tran
Alex Tranโ€ข2y ago
I have plan to revamp the whole backup/selection mechanism anyway so these things can change the current backup mechanism has been there since the start and it has been working so we are focusing manpower on other issues/features first
Azsde
AzsdeOPโ€ข2y ago
Yeah obviously (I've excluded the recent album but now whatsapp causes a similar issue has it has 30k+ assets ... ) Ok, so IMO, the proper fix for the time being is to use: final assetList = await album.getAssetListPaged(page: 0, size: 1); ( on another note, I find that the album selection UI is quite laggy ๐Ÿ˜œ ) Do you want me do to a PR ? ( for the thumbnail issue, not the laggy UI)
Alex Tran
Alex Tranโ€ข2y ago
yes thank you
Azsde
AzsdeOPโ€ข2y ago
Alright Tehre you go
Azsde
AzsdeOPโ€ข2y ago
GitHub
fix (mobile): Fix slow album thumbnail generation on Android by azs...
When generating the thumbnail of an album, all of the pictures of the album are retrieved but only the first picture of the album is used. Retrieving all of the pictures of the album at once can ca...

Did you find this page helpful?