Tobi823 / ffupdater

FFUpdater: Updater for privacy friendly browser
https://f-droid.org/en/packages/de.marmaro.krt.ffupdater
GNU General Public License v3.0
687 stars 33 forks source link

Background download fails #442

Closed Hew-ux closed 1 year ago

Hew-ux commented 1 year ago

Describe the bug The background downloading of browser updates fail. Running Android 10 on a Lenovo M10 tablet. It has happened multiple times.

It does sometimes successfully download the update though.

To Reproduce Steps to reproduce the behavior:

  1. Go to Settings > Background and enable update downloads.
  2. Sit and wait a long time (several hours).
  3. See error about the background update failing.

Expected behavior For the background downloads to succeed, or at least try again later if failed.

Error message from FFUpdater Stacktrace:

de.marmaro.krt.ffupdater.background.BackgroundException: The background job fails due to an unrecoverable exception.
    at de.marmaro.krt.ffupdater.BackgroundJob.doWork(BackgroundJob.kt:98)
    at de.marmaro.krt.ffupdater.BackgroundJob$doWork$1.invokeSuspend(BackgroundJob.kt:0)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
Caused by: kotlinx.coroutines.JobCancellationException: Job was cancelled; job=JobImpl{Cancelling}@4c3655e

--------- beginning of main
07-18 13:04:55.851 I/FFUpdater(26452): BackgroundJob: Execute background job.
07-18 13:04:55.938 I/FFUpdater(26452): InstalledAppsCache: Update cache of installed apps.
07-18 13:04:56.001 I/FFUpdater(26452): InstalledAppsCache: Cache was updated.
07-18 13:04:56.002 I/FFUpdater(26452): InstalledAppsCache: Update cache of installed apps.
07-18 13:04:56.033 I/FFUpdater(26452): InstalledAppsCache: Cache was updated.
07-18 13:04:56.867 I/FFUpdater(26452): Execute real network request: https://api.github.com/repos/Tobi823/ffupdater/releases/latest
07-18 13:04:56.895 I/FFUpdater(26452): findAppUpdateStatus(): Found FFUPDATER 78.0.6 (860ms).
07-18 13:04:57.284 I/FFUpdater(26452): Execute real network request: https://api.github.com/repos/fork-maintainers/iceraven-browser/releases/latest
07-18 13:04:57.301 I/FFUpdater(26452): findAppUpdateStatus(): Found ICERAVEN 2.7.0 (399ms).
07-18 13:04:59.045 I/FFUpdater(26452): Execute real network request: https://divestos.org/fdroid/official/index-v1.json
07-18 13:04:59.174 I/FFUpdater(26452): findAppUpdateStatus(): Found MULCH 115.0.5790.85 (1868ms).
07-18 13:04:59.238 I/FFUpdater(26452): BackgroundJob: Download update for MULCH.
07-18 13:05:01.306 I/FFUpdater(26452): Execute real network request: https://divestos.org/fdroid/official/Mulch-arm64-115.0.5790.85-1.apk
07-18 13:06:05.860 I/FFUpdater(26452): InstalledAppsCache: Update cache of installed apps.
07-18 13:06:05.950 I/FFUpdater(26452): InstalledAppsCache: Cache was updated.
07-18 13:14:55.988 E/FFUpdater(26452): BackgroundJob: Job failed.
07-18 13:14:55.988 E/FFUpdater(26452): de.marmaro.krt.ffupdater.background.BackgroundException: The background job fails due to an unrecoverable exception.
07-18 13:14:55.988 E/FFUpdater(26452):  at de.marmaro.krt.ffupdater.BackgroundJob.doWork(BackgroundJob.kt:98)
07-18 13:14:55.988 E/FFUpdater(26452):  at de.marmaro.krt.ffupdater.BackgroundJob$doWork$1.invokeSuspend(BackgroundJob.kt:0)
07-18 13:14:55.988 E/FFUpdater(26452):  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
07-18 13:14:55.988 E/FFUpdater(26452):  at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
07-18 13:14:55.988 E/FFUpdater(26452):  at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
07-18 13:14:55.988 E/FFUpdater(26452):  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
07-18 13:14:55.988 E/FFUpdater(26452):  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
07-18 13:14:55.988 E/FFUpdater(26452):  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
07-18 13:14:55.988 E/FFUpdater(26452): Caused by: kotlinx.coroutines.JobCancellationException: Job was cancelled; job=JobImpl{Cancelling}@4c3655e
Device information: Key Value
FFUpdater version 78.0.6 (148) release
Device Lenovo TB-X606F (LenovoTB-X606F, X606F, achilles6_row_wifi)
Manufacturer Lenovo (LENOVO)
Supported ABIs arm64-v8a, armeabi-v7a, armeabi
Android version 10 (SDK: 29)
OS bjsl188, buildslave, release-keys, 1655108507000
Tobi823 commented 1 year ago

I finally understand the issue ... the background job is running longer than 10 minutes (see duration between BackgroundJob: Execute background job. and BackgroundJob: Job failed.). The OS kills the background job which causes a JobCancellationException in the download code

Tobi823 commented 1 year ago

I should use setForground() https://developer.android.com/guide/background/persistent/how-to/long-running

Tobi823 commented 1 year ago

Fix will be part of the next release