SafeSpace icon indicating copy to clipboard operation
SafeSpace copied to clipboard

[Bug] backup freezes when app is working in background

Open UltraFeed opened this issue 1 year ago • 9 comments
trafficstars

Rom: Evolution X 9.3, Android 14 Device: Nothing Phone 2 SafeSpace 2.0.5 All battery optimizations are disabled.

https://github.com/user-attachments/assets/a3d2c52d-7c29-4c6a-9e5d-4cbd203f3a77

UltraFeed avatar Aug 17 '24 18:08 UltraFeed

Hi @UltraFeed can please translate those options you selected at 0:05. I kinda just know enough Russian to tell that this is Russian. 😅

aashishksahu avatar Aug 17 '24 18:08 aashishksahu

It says running in background is enabled in unrestricted mode. All my other apps are working in background properly, so this is not ROM issue

Screenshot_20240818-005534_Settings

UltraFeed avatar Aug 17 '24 18:08 UltraFeed

Hey @starry-shivam , can you please take a look :)

aashishksahu avatar Aug 18 '24 14:08 aashishksahu

@aashishksahu It's expected because backups are created within the current app's process instead of a background or foreground service. When the user minimizes the app, Android suspends the app's process after some time, causing the backup to pause. The backup resumes when the user returns to the app. This is not a bug (at least from the development side) but intentional behavior based on the way backups are implemented. One way to solve this issue is to use a foreground service to create backup files. That way, even if Android suspends the app's process when the app is minimized and sent to the background, the foreground service will keep running until the backup is complete without any interruption.

starry-shivam avatar Aug 18 '24 15:08 starry-shivam

Btw, if you don't want to use a foreground service, we can also use the WorkManager API to run long-running tasks, like creating backups, reliably without being interrupted by the system's usual behavior.

starry-shivam avatar Aug 18 '24 16:08 starry-shivam

How big of an effort do you think it will be? Although, improving the UX is a priority but I am not sure exporting and importing backups is a feature that is used a lot and most people wouldn’t keep a large amount of data in the app. What do you think @starry-shivam ?

aashishksahu avatar Aug 18 '24 18:08 aashishksahu

How big of an effort do you think it will be? Although, improving the UX is a priority but I am not sure exporting and importing backups is a feature that is used a lot and most people wouldn’t keep a large amount of data in the app. What do you think @starry-shivam ?

Basically, we need to call the import/exportBackup() methods of DataManager from within a foreground service or WorkManager. I don't think it will require much effort, but I can't say for sure about any additional challenges that may or may not arise while working on it

starry-shivam avatar Aug 20 '24 06:08 starry-shivam

Let’s keep it low priority, will revisit this in the future. Thanks for the ideas @starry-shivam

aashishksahu avatar Aug 20 '24 15:08 aashishksahu

Let’s keep it low priority, will revisit this in the future. Thanks for the ideas @starry-shivam

No problem, I might create a PR for it around the weekend if I'm free :)

starry-shivam avatar Aug 21 '24 03:08 starry-shivam