Skip to content

Stop the dataSync foreground service on Android 15 timeout - #50

Merged
dhruv-dangi-openspace merged 1 commit into
masterfrom
dhruv/workmanager-2.12
Sep 29, 2026
Merged

dhruv-dangi-openspace merged 1 commit into
masterfrom
dhruv/workmanager-2.12

Conversation

@dhruv-dangi-openspace

@dhruv-dangi-openspace dhruv-dangi-openspace commented Sep 29, 2026 •

Copy link
Copy Markdown

Fixes the top Android crash on Diana 110.3: ForegroundServiceDidNotStopInTimeException. Sentry DIANA-FT0, 280 users.

What breaks

Android 15 gives dataSync foreground services six hours per day while the app is in the background. When the budget runs out the system calls the service's onTimeout and waits a few seconds for stopSelf. If that never comes, it kills the process. WorkManager 2.9 does not implement onTimeout, so a capture upload that outlives the budget takes the app down. Every event is on Android 15 or newer with the app in the background.

What changes

androidx.work goes from 2.9.1 to 2.12.0. Since 2.10, WorkManager answers the timeout: it stops each worker of the timed-out type with STOP_REASON_FOREGROUND_SERVICE_TIMEOUT and stops the service. The stopped workers re-run, setForeground is refused because the budget is spent, and isForegroundStartDenied already handles that by continuing the upload without foreground priority. The budget resets when the user opens the app.

The library's minSdk floor becomes 24 with this version. Ours is 29.

Not changed

The raw upload worker still retries transport failures with no network constraint, so an offline worker spends the same six hours a real upload would. The worker carries a comment that WorkManager constraints were unreliable, so that stays a separate decision.

Verification

:react-native-background-upload:compileDebugKotlin and testDebugUnitTest pass locally on the example app, 84 tests. Not run on a device: reproducing needs an upload that sits in the background for six hours on an Android 15 phone.

🤖 Generated with Claude Code

@dhruv-dangi-openspace
dhruv-dangi-openspace marked this pull request as ready for review September 29, 2026 15:24
Android 15 gives an app's dataSync foreground services six hours per day in
the background. At the limit the system calls onTimeout and expects stopSelf
within a few seconds, or it kills the process with
ForegroundServiceDidNotStopInTimeException. WorkManager 2.9 never implemented
onTimeout, so every long upload that outlived the budget took the app down.

WorkManager 2.10 added the handler: it stops each worker of the timed-out type
with STOP_REASON_FOREGROUND_SERVICE_TIMEOUT and stops the service. The stopped
workers re-run, setForeground is refused because the budget is spent, and the
existing isForegroundStartDenied path carries the upload on without foreground
priority until the user opens the app and the budget resets.

Bumps androidx.work to 2.12.0, which raises the library's floor to minSdk 24.
Ours is 29.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@dhruv-dangi-openspace
dhruv-dangi-openspace merged commit 2aae118 into master Sep 29, 2026
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants