Android crash report when forcing sync on 100GB folder: `java.lang.IllegalStateException: Not allowed to start service Intent [...] app is in background`
- Dominant language
- Kotlin
- Stars
- 5.6k
- Forks
- 2k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 92
Description
### ⚠️ Before posting ⚠️
- [X] This is a **bug**, not a question or an enhancement.
- [X] I've [searched for similar issues](https://github.com/nextcloud/android/issues) and didn't find a duplicate.
- [X] I've written a clear and descriptive title for this issue, not just "Bug" or "Crash".
- [X] I agree to follow Nextcloud's [Code of Conduct](https://nextcloud.com/contribute/code-of-conduct/).
### Steps to reproduce
1. From a computer, copy 100GB of mp3 sorted into folders (genre, artist, album), and a few other types of files (e.g. AlbumArt.jpg) into your local Nextcloud folder. Let it sync with the server.
2. On Android, open the app and, next to the given folder, tap the sandwitch menu and tap the "Sync" option that has a cloud icon to force downloading the files on the device (freely translated from FR).
3. A few GB sync, then the app crashes and gives a crash report (see logs below) :
4. Kill the app. The notification for sync stays even though you kill the app. Restart the app. It crashes after 30 secs or a few minutes.
5. Reboot the device. Relaunch the app. The app crashes with the same way and sync doesn't continue.
### Expected behaviour
Files are synced and available locally.
### Actual behaviour
See above.
### Android version
9
### Device brand and model
Samsung Galaxy S8+
### Stock or custom OS?
Stock
### Nextcloud android app version
30240290 (3.24.2)
### Nextcloud server version
25.0.5
### Using a reverse proxy?
I don't know
### Android logs
`### Cause of error
```java
Exception in thread "Syncfolder thread" java.lang.IllegalStateException: Not allowed to start service Intent { act=SYNC_FOLDER cmp=com.nextcloud.client/com.owncloud.android.services.OperationsService (has extras) }: app is in background uid UidRecord{99d8c5d u0a329 CAC bg:+4m10s773ms idle change:cached procs:1 proclist:11195, seq(0,0,0)}
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1666)
at android.app.ContextImpl.startService(ContextImpl.java:1611)
at android.content.ContextWrapper.startService(ContextWrapper.java:677)
at com.owncloud.android.operations.SynchronizeFolderOperation.startSyncFolderOperation(SynchronizeFolderOperation.java:540)
at com.owncloud.android.operations.SynchronizeFolderOperation.classifyFileForLaterSyncOrDownload(SynchronizeFolderOperation.java:387)
at com.owncloud.android.operations.SynchronizeFolderOperation.synchronizeData(SynchronizeFolderOperation.java:335)
at com.owncloud.android.operations.SynchronizeFolderOperation.fetchAndSyncRemoteFolder(SynchronizeFolderOperation.java:220)
at com.owncloud.android.operations.SynchronizeFolderOperation.run(SynchronizeFolderOperation.java:146)
at com.owncloud.android.lib.common.operations.RemoteOperation.execute(RemoteOperation.java:205)
at com.owncloud.android.services.SyncFolderHandler.doOperation(SyncFolderHandler.java:115)
at com.owncloud.android.services.SyncFolderHandler.handleMessage(SyncFolderHandler.java:88)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.os.HandlerThread.run(HandlerThread.java:65)
```
### App information
* ID: `com.nextcloud.client`
* Version: `30240290`
* Build flavor: `gplay`
### Device information
* Brand: `samsung`
* Device: `dream2lte`
* Model: `SM-G955F`
* Id: `PPR1.180610.011`
* Product: `dream2ltexx`
### Firmware
* SDK: `28`
* Release: `9`
* Incremental: `G955FXXUCDVG4`
### Server error logs
_No response_
### Additional information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.