SafeSpace
SafeSpace copied to clipboard
[Bug] backup freezes when app is working in background
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
Hi @UltraFeed can please translate those options you selected at 0:05. I kinda just know enough Russian to tell that this is Russian. 😅
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
Hey @starry-shivam , can you please take a look :)
@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.
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.
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 ?
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
Let’s keep it low priority, will revisit this in the future. Thanks for the ideas @starry-shivam
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 :)