Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Background crash trying to start foreground downloadservice #438

Closed
e-t-l opened this issue Feb 27, 2023 · 3 comments
Closed

Background crash trying to start foreground downloadservice #438

e-t-l opened this issue Feb 27, 2023 · 3 comments

Comments

@e-t-l
Copy link

e-t-l commented Feb 27, 2023

Occasionally I'll get a random crash notif (I have Background ANR's enabled in dev settings) with the following error:

type: crash
osVersion: google/panther/panther:13/TQ1A.230205.002/2023022300:user/release-keys
package: com.machiav3lli.fdroid:926
process: com.machiav3lli.fdroid
processUptime: 34577 + 1152 ms

android.app.ForegroundServiceStartNotAllowedException: startForegroundService() not allowed due to mAllowStartForeground false: service com.machiav3lli.fdroid/.service.DownloadService
	at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:54)
	at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:50)
	at android.os.Parcel.readParcelableInternal(Parcel.java:4837)
	at android.os.Parcel.readParcelable(Parcel.java:4799)
	at android.os.Parcel.createExceptionOrNull(Parcel.java:3016)
	at android.os.Parcel.createException(Parcel.java:3005)
	at android.os.Parcel.readException(Parcel.java:2981)
	at android.os.Parcel.readException(Parcel.java:2923)
	at android.app.IActivityManager$Stub$Proxy.startService(IActivityManager.java:5302)
	at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1915)
	at android.app.ContextImpl.startForegroundService(ContextImpl.java:1891)
	at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:822)
	at com.machiav3lli.fdroid.service.ConnectionService.startSelf(ConnectionService.kt:18)
	at com.machiav3lli.fdroid.service.DownloadService.access$handleDownload(DownloadService.kt:28)
	at com.machiav3lli.fdroid.service.DownloadService$Binder.enqueue(DownloadService.kt:102)
	at com.machiav3lli.fdroid.utility.Utils$startUpdate$5.emit(Utils.kt:25)
	at kotlinx.coroutines.flow.StateFlowImpl.collect(StateFlow.kt:194)
	at com.machiav3lli.fdroid.utility.Utils.startUpdate(Utils.kt:410)
	at com.machiav3lli.fdroid.service.SyncService$batchUpdate$1$1$3$1.invokeSuspend(SyncService.kt:43)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:9)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:107)
	at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:154)
	at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source:106)
	at com.machiav3lli.fdroid.service.SyncService$batchUpdate$1.invokeSuspend(SyncService.kt:18)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:9)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:107)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:79)
	Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@bb37341, Dispatchers.Default]

I'm not sure if this is related to #102? It doesn't seem related to fetching updates, since I still get "new app version available" notifications.

@e-t-l
Copy link
Author

e-t-l commented Feb 27, 2023

It looks like this has to do with the Android 12+ Restriction on Background Starts. It should be circumventable by:

  1. Disabling battery optimization (not ideal)
  2. Using an Accessibility Service

@machiav3lli
Copy link
Member

Yes it seems so. The sync and download services run as background services to allow longer runs (e.g. downloading bigger updates). I'm planning to replace these with WorkManager jobs, but that's something planned post v1.0

@machiav3lli
Copy link
Member

Should be fixed on 1.0.0 (although limitations on background are now even more strict on A14 if battery optimization is on)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants