immich-app / immich

High performance self-hosted photo and video management solution.
https://immich.app
GNU Affero General Public License v3.0
53.36k stars 2.82k forks source link

Slow cold startup time for mobile app #9707

Open justin13888 opened 6 months ago

justin13888 commented 6 months ago

The bug

The immich mobile app on Android takes 6-10 seconds regularly for it to startup.

For some context.... Device: Samsung S22 Ultra Number of photos: 1000 ish Misc: I'm using mobile data (20Mbps down)

I think it's fine if it takes a moment for the app to fetch metadata about the photos in the album but it should try to optimistically display all local photos, and previously cached photos (if possible). That'd be a much better user experience.

If any dev is able to give some insight as to the reasons for these behaviours, I would love to know. If the issue isn't isolated, I could make a PR

The OS that Immich Server is running on

Ubuntu 22.04

Version of Immich Server

v1.105.1

Version of Immich Mobile App

v1.105.0

Platform with the issue

Your docker-compose.yml content

NA

Your .env content

NA

Reproduction steps

1. Force close app or restart device
2. Open immich app

It takes 6-10 seconds on the loading screen before rendering any gallery timelines

Relevant log output

No response

Additional information

No response

### Tasks
AlmightyFrog commented 6 months ago

I have some more assets in my library (about 180000 in total) and can also confirm that startup time sometimes is all over the place.

What I want to add is, that maybe not pure network connection is the issue as i have same issue when being at home in my 5 GHz WLAN just few meters away from accespoint.

Sometimes load feels like instant, mostly it takes a few seconds, but sometimes it also takes at least a minute. I then switch to use the webinterface in browser on same smartphone which shows pictures instant with no delay.

My guess would be my home server might cause the bottleneck but not sure where, as it is not a banana but also not top tier and mostly idleing:

Best guess would be postgres is the bottleneck but not sure.

justin13888 commented 6 months ago

I have some more assets in my library (about 180000 in total) and can also confirm that startup time sometimes is all over the place.

What I want to add is, that maybe not pure network connection is the issue as i have same issue when being at home in my 5 GHz WLAN just few meters away from accespoint.

Sometimes load feels like instant, mostly it takes a few seconds, but sometimes it also takes at least a minute. I then switch to use the webinterface in browser on same smartphone which shows pictures instant with no delay.

My guess would be my home server might cause the bottleneck but not sure where, as it is not a banana but also not top tier and mostly idleing:

* i5-7500

* 32 GB RAM in total; RAM used by immich currently is machine learning uses 800 MB, microservices 1.3 GB, postgres 2,7 GB, redis 30 MB and server 350 MB; still about 15 GB RAM free so can't be the issue.

* gigabit lan

* OS, assets and database on same SSD

Best guess would be postgres is the bottleneck but not sure.

Glad to hear I'm not the only one.

Database and library storage may be part of the story but based on my hardware and setup, and the fact that the web app also loads the latest images in the timeline significantly faster than the other images, I'm confident there's definitely room for improvement for the mobile app itself.

For the record, my hardware situation is as follows:

As @AlmightyFrog said, hardware shouldn't be the problem because resources are idling anyways.

Even if I "warmed" up the server by scrolling through the whole timeline, the perceived load speed on the web app on another device is obviously faster for me than that of the mobile app.

A few more observations:

I have a few hypotheses so far:

justin13888 commented 6 months ago

These are a few things I believe should be investigated:

For any devs who worked on Immich, would appreciate any guidance or ideas here!

alextran1502 commented 6 months ago

The issue is the way we currently use to initial rendered, which we will need to fetch all data from the server in chunk, parse them all then render. We are working towards a refactor to fetch then render then fetch then render to help with the initial "blank state" on slow network

SHU-red commented 5 months ago

+1 for this!

So i hope (not being a person knowing much about the technical details) the suggestions above include something like:

heri3x commented 3 months ago

I'm using the Immich app v1.111.0 build 167 on iOS 17.5.1.