immich-app / immich

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

[BUG] Background service not respecting WiFi only setting #2075

Open EnochPrime opened 1 year ago

EnochPrime commented 1 year ago

The bug

The background service can still use mobile data despite being configured for WiFi only. I started with a fresh setup and choose the desired album. Then while home started the backup. After leaving the WiFi network I realized mobile data was being used.

Screenshot_2023-03-24-12-46-28-28_d8aea95ef633eb6b7eb1cae13c34b40e

Screenshot_2023-03-24-12-46-45-38_f477f0d1f9efd6499236910aab472e51

The OS that Immich Server is running on

Various

Version of Immich Server

v1.51.2

Version of Immich Mobile App

v1.51.0

Platform with the issue

Your docker-compose.yml content

N/A

Your .env content

N/A

Reproduction steps

1. Open backup settings and ensure background WiFi is enabled.
2. Press start backup button while on WiFi
3. Leave WiFi network

Additional information

No response

bo0tzz commented 1 year ago

The WiFi setting only applies to the background backup.

EnochPrime commented 1 year ago

The WiFi setting only applies to the background backup.

Was I not backing up in the background? There is significant data usage from the background.

jrasm91 commented 1 year ago

I think the issue was changing networks after the backup had started. Maybe it's worth verifying where the network check is actually used as it could only be checked at the beginning, not before each upload.

fyfrey commented 1 year ago

On Android, this setting is managed by the system. The system scheduler automatically stops the task if connection to wifi is lost. However, the upload currently in progress might have a few seconds where it continues upload an asset.

You also have the foreground backup enabled (which is not affected by the setting) and on the screenshot it currently shows uploading a video file while not being on wifi. I'm not sure how Android counts the data usage of foreground and background but maybe it's not directly translatable to our foreground/background backup. I'd suggest you disable automatic foreground backup and see whether your phone still uploads images without wifi.

bo0tzz commented 1 year ago

I've just (inadvertently) reproduced this on an Android phone. At the time where this happened, I'd been off wifi for at least 6 hours and the uploading video was one I'd just taken. See https://photos.bo0tzz.me/share/48d7c8ebc3e511e589096d78224fd261ebc97072bd9a9d23281bce0eae13fa7ef2fadbfaac7291c3734869aee36710ff4e01 for screenshots.

fyfrey commented 1 year ago

I'll take a look whether we can read out the currently configured background task settings from Android system within the app. Otherwise, it'll be very challenging to further debug this.

fyfrey commented 1 year ago

There is actually no setting for "only on wifi" for Android, there is only metered and unmetered connections (typically wifi). However, you can set your mobile data connection as unmetered in the Android system settings. If set, Immich would also upload if not connected to wifi

gmag11 commented 1 year ago

Hi. Same happens here. During my holidays trip I wasn't connected to any wifi, but all my pictures were uploaded just after taking them.

A possible workaround may be restricting mobile data for Immich in Android settings.

Screenshot_2023-08-05-23-24-36-174_com.miui.securitycenter-edit.jpg

Screenshot_2023-08-05-23-25-03-419_com.miui.securitycenter-edit.jpg

titro commented 1 year ago

would be great having this issue solved together with a option to restrict Wifi sync only to specific WIFI SSIDs. The background sync service is going crazy when connected with a not at home WIFI and the app then tries to connect to the immich server (which is not reachable) and tries to sync.

sidamos commented 5 months ago

Same happens on iOS with the latest app version 1.105.1. I have enabled background sync on WiFi only and still it uploads new photos when I am not on WiFi.

Edit: I had a quick look at the code (no iOS expert) and it looks like the background sync does respect the setting "require_wifi", but it does not get its current value from the caller. It does get "require charging" and "require unmetered network" (which cannot even be configured in the iOS UI).

In BackgroundServicePlugin.swift:

    // Parse the arguments from the method call
    let requireUnmeteredNetwork = args[0] as? Bool
    let requireCharging = args[1] as? Bool
    let triggerUpdateDelay = args[2] as? Int
    let triggerMaxDelay = args[3] as? Int
interunivers commented 1 month ago

Still happening regularly in the ios app (app version 1.115)