immich-app / immich

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

iOS App keeps crashing - local backup to server #8141

Closed EliasMarine closed 2 months ago

EliasMarine commented 6 months ago

The bug

When uploading via immich app iOS v1.99 after a few minutes of uploading, the app crashes. App needs to be restarted to resume backup. After a few more minutes, app craches again.

iOS v17.3.1

The OS that Immich Server is running on

Unraid 6.12.8

Version of Immich Server

v1.99

Version of Immich Mobile App

v1.99

Platform with the issue

Your docker-compose.yml content

n/a

Your .env content

n/a

Reproduction steps

1. opens iOS app
2. upload resumes
3. app crashes
...

Additional information

No response

alextran1502 commented 6 months ago

I assume you are using iCloud, and these photos/videos have been uploaded from iCloud. These seems to be a memory leaked when downloading/uploading asset from iCloud that causes the crash

EliasMarine commented 6 months ago

Correct using iCloud. It worked fine downloading from iCloud and pushing to the server for about ~2.5k photos then it would crash after about ~300 photos or so repeatedly. I absolutely love the app btw...amazing work!

alextran1502 commented 6 months ago

Thank you for the report, I don't use iCloud so there might be some cases we haven't properly handled when downloading/uploading from iCloud

shumancw commented 6 months ago

I'm having the same issue: The bug When uploading via immich app iOS v1.99.0 build .145 after a few minutes of uploading, the app crashes. App needs to be restarted to resume backup. After a few more minutes, app craches again.

iOS v17.4.1

The OS that Immich Server is running on Debian 12.5 Docker 20.10.24+dfsg1, build 297e128 Docker-compose 1.29.2

Version of Immich Server v1.99.0

Version of Immich Mobile App v1.99.0 build .145

Reproduction steps

  1. opens iOS app
  2. upload resumes
  3. app crashes ... Additional information No response

Also, my phone is getting seriously hot when performing this backup. At one point it went into thermal protect.

hjspencer commented 6 months ago

I'm also having the same issue but with App v1.100.0 build .146 & server v1.100.0

iOSv17.3.1 Immich v1.100.p0 Mobile app v1.100.0 build 146

Immich Server running on QNAP NAS vQTS 5.1.5.2679 Docker version 20.10.27-qnap1, build 662936b Docker Compose version v2.15.1-qnap1

The compose files are the standard ones taken from https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml

Same reproduction steps as above

Bod1985 commented 6 months ago

I have the same issue - let me know if there's anything useful I can do to debug. Same release and config as the above.

This is my first full backup of 200GB so for now I've made an iOS Shortcut that opens the app automatically when it closes. That way I can leave my device with auto-lock disabled overnight and be confident it will continue until I wake up.

douginoz commented 6 months ago

Just an FYI to those with this problem (like me). If you enable analytics on your iphone, it will create a crash report that you can then give to the developers here.
I have been getting this constant crash while trying to get all 9,800 images/videos transferred. Then I found this issue here and I enabled analytics to get a crash report. Strangely, now I'm not getting a single crash.

There may be a correlation here worth looking into. If you are getting crashes, check if you have analytics reporting enabled: To locate and email crash reports for iOS, iPadOS, watchOS, and tvOS apps:

  1. Open the Analytics & Improvements section of Settings on the device. See Share analytics, diagnostics, and usage information with Apple.
  2. Tap Analytics Data.
  3. Locate the log for your app. The log name starts with for crash reports, or JetsamEvent for high-memory use crashes.
  4. Select the desired log.
  5. Tap the Share icon, and select Mail to send the crash report as a mail attachment.

At that point you'd want to upload that report into here.

nothing2obvi commented 6 months ago

I have the same issue on latest iOS (just upgraded last night). Indeed using iCloud.

brendanclement commented 6 months ago

@alextran1502 - what makes you think this is a memory leak? Just found this project and I use icloud and i'm eager to help fix this.

Any assistance you can give would be appreciated, I should have a few cycles this weekend to download the repo and try and root cause this issue.

alextran1502 commented 6 months ago

@brendanclement My hunch for memory leaked is because this issue happens for folks that have their assets on iCloud, so the process of downloading and discarding the iCloud might be the cause here.

douginoz commented 6 months ago

Worth testing if app crashes with/without crash dump logging enabled on phone. Strangely, crashes stopped when I enabled logging.

On Thu, 4 Apr 2024 at 19:08, Alex @.***> wrote:

@brendanclement https://github.com/brendanclement My hunch for memory leaked is because this issue happens for folks that have their assets on iCloud, so the process of downloading and discarding the iCloud might be the cause here.

— Reply to this email directly, view it on GitHub https://github.com/immich-app/immich/issues/8141#issuecomment-2038631380, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAO3F6NRWI44O35FUA77JCDY3YBS3AVCNFSM6AAAAABFAX5RS2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZYGYZTCMZYGA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

brendanclement commented 6 months ago

@alextran1502 - got the workspace set up. I'm new to flutter but went through the docs to get up to speed.

i'm having trouble signing the application to get it to run on my device. Do i need to work with you to get a profile to enable development? I looked at the README and other issues in this repo and couldn't find a solution.

this is the error I get when trying to run and debug from vscode

Launching lib/main.dart on BRENFONE in debug mode...
Automatically signing iOS for device deployment using specified development team in Xcode project: 2F67MQ8R79
Xcode build done.                                            3.4s
Failed to build iOS app
Could not build the precompiled application for the device.
Error (Xcode): No profiles for 'app.alextran.immich' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'app.alextran.immich'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild.
/Users/brendan/Code/immich/mobile/ios/Runner.xcodeproj
2

It appears that there was a problem signing your application prior to installation on the device.

Verify that the Bundle Identifier in your project is your signing id in Xcode
  open ios/Runner.xcworkspace

Also try selecting 'Product > Build' to fix the problem.

Error launching application on BRENFONE.

I tried opening the Runner in xcode but i face the same issue, and I don't have an apple developer account.

Screenshot 2024-04-05 at 23 07 51
brendanclement commented 6 months ago

figured it out. just needed to change the bundle identifier to something of mine.. kinda sucks that i need to keep renewing the cert every 7 days though :P

brendanclement commented 6 months ago

So interesting find.. Got the app running with the debugger. i saw the logs spewing out ERROR backupAsset: failed to parse <html>.

the request to the backend was returning 413 entity too large with an HTML payload https://github.com/immich-app/immich/blob/8f981b60529140af839171dc052bc49784c73911/mobile/lib/modules/backup/services/backup.service.dart#L357

and then this line was throwing an error as it's not valid JSON https://github.com/immich-app/immich/blob/8f981b60529140af839171dc052bc49784c73911/mobile/lib/modules/backup/services/backup.service.dart#L368

this was coming from nginx, a reverse proxy i have in front of immich. I changed the configuration to allow larger files and now it's backing up without crashing

I have some videos that are around ~2GB so i added the following to my nginx.conf

http {
   ...
   client_max_body_size 2000M;
}

now the backup seems to be working great.

As i presume reverse proxies are common, I'm thinking we could add some logic here to detect this status code and emit a warning / error in the app. Is this a PR you'd welcome @alextran1502 ?

EliasMarine commented 5 months ago

iOS 17.4.1 (21E236) crash log

Runner-2024-04-17-095629.txt

mattnovelli commented 4 months ago

Also experiencing this. 413s causing a parse error and crash sounds super plausible.

allgoewer commented 4 months ago

Same issue here. I'm trying to upload ~ 10000 images via an iphone which are partially stored in iCloud. The app always crashes after some minutes.

surenrao commented 4 months ago

Same as above, it crashes after a couple of seconds when tapping the backup button, however when iphone is charging its working without any issue

danst0 commented 4 months ago

Same here it crashes constantly. I have 100k+ images and after three weeks still 75k to go.

Daniel

JohanSelmosson commented 4 months ago

In my case it seemed like caddy that i use as reverse proxy in front of immich rejected uploads bigger than whatever the default value allows.

More info here https://caddyserver.com/docs/caddyfile/directives/request_body

I changed my Caddy configuration like this and then it started to work!


https://immich.example.com {

    reverse_proxy immich_server:3001

    request_body {             # Added this statement
        max_size 5GB       # to allow bigger
    }                          # uploads.
}
agster27 commented 3 months ago

This is also happening to me:

IOS 17.5.1 immich app 1.108.0 build 163 immich server v1.108.0

No proxy being used, mobile cellular service turned off, wifi turned on, all on a local network from the iphone to the server.

alextran1502 commented 3 months ago

@agster27 you can turn on "Ignore Icloud" asset in the backup settings to temporarily workaround this issur

skndmx commented 2 months ago

I have the same issue - let me know if there's anything useful I can do to debug. Same release and config as the above.

This is my first full backup of 200GB so for now I've made an iOS Shortcut that opens the app automatically when it closes. That way I can leave my device with auto-lock disabled overnight and be confident it will continue until I wake up.

That's a smart workaround for initial batch upload.

agster27 commented 2 months ago

@alextran1502 I ended up asking iCloud to download all photos to the iphone and then I did the immich backup with the iPhone Autolock turned off.

If anyone does this. It works great. HOWEVER your iPhone will get as hot as Death Valley. So I took my cover off and propped up the phone to make sure there was plenty of space for it to release it's heat.

This worked like a charm.

I backed up over 200GB of photos from the iPhone. It took two nights. I did not backup during the day as I needed to use the phone.

sinofool commented 2 months ago

@alextran1502 I ended up asking iCloud to download all photos to the iphone and then I did the immich backup with the iPhone Autolock turned off.

If anyone does this. It works great. HOWEVER your iPhone will get as hot as Death Valley. So I took my cover off and propped up the phone to make sure there was plenty of space for it to release it's heat.

This worked like a charm.

I backed up over 200GB of photos from the iPhone. It took two nights. I did not backup during the day as I needed to use the phone.

Thanks for the tips. I turned off autolock and put on an active cooling fan. It runs smoothing for now. 17K/400GB to go this weekend.

Before the memory leak fixed, I think it's better to have the tips in the backup screen. Not everyone knows how to search solutions from Github.

vfedetz commented 2 months ago

I am also experiencing this issue trying to perform an initial sync my wife's iPhone with immich. Can't attempt the work around of downloading all iCloud photos locally to the phone due to lack of space. What is infuriating is the sync progress constantly resets after the app crashes. Has anyone figured out a way to at least "save" your progress during a sync so that when I reopen the app it does not have to start from scratch?

elkaboing commented 2 months ago

I am also experiencing this issue trying to perform an initial sync my wife's iPhone with immich. Can't attempt the work around of downloading all iCloud photos locally to the phone due to lack of space. What is infuriating is the sync progress constantly resets after the app crashes. Has anyone figured out a way to at least "save" your progress during a sync so that when I reopen the app it does not have to start from scratch?

My experience is the same. I gave up and rely on icloudpd to download my photos and videos every night and added the directory to immich as an external library.

philjak commented 2 months ago

Hey there, hi @alextran1502,

I'm running Immich in a Docker Environment and updated to the version "main" (i.e. ghcr.io/immich-app/immich-server:main) to check if the crashing issue has been resolved by that release.

Unfortunately, the App still crashes after a few minutes.

Thanks, philjak

alextran1502 commented 2 months ago

@philjak it will be fixed in the next release. The issue is closed because we implemented the fix, but the new code hasn't been released yet