fix: prevent sticky node crash#987
Conversation
Emulator setup (once per session)
Shorten the adb shell device_config put activity_manager data_sync_fgs_timeout_duration 30000
adb shell device_config get activity_manager data_sync_fgs_timeout_durationStep 1 — Repro on v2.2.0 (expect crash) ✅Checkoutgit checkout v2.2.0Local-only patch (
|
piotr-iohk
left a comment
There was a problem hiding this comment.
tACK. see #987 (comment)
Incorporated into the PR QA Notes. No code changes were needed. |
Fixes #980
Fixes #981
Refs #986
Description
This PR:
LightningNodeServicestartup so Android does not promote the service from sticky/null restarts.dataSyncforeground-service type.Preview
N/A - service lifecycle crash fix, no UI changes.
QA Notes
Repro / Fix Evidence
to.bitkit.dev, target SDK 36, and shorteneddataSynctimeout:v2.2.0, install dev build, apply a local-only stress patch that delaysstopSelf()inLightningNodeService.onTimeout()afterlightningRepo.stop(), start the app, press Home, and wait about 35s..ai/issue_980_prefix/logcat.txtline 1187 showsForegroundServiceDidNotStopInTimeExceptionafterFGS (dataSync) timed out..ai/issue_980_postfix/logcat.txtline 2044 showsFGS (dataSync) timed out, followed by service timeout handling andonDestroy, with noFGS Crashed, noRemoteServiceException, and no process death.lightningRepo.stop()afterstopForegroundService(startId)inonTimeout; the FGS is already stopped before the delay, so the process still does not crash.Manual Tests
regression:Android 15+ or 16+ device → enable shorteneddataSyncFGS timeout → background Bitkit with node service running: service stops cleanly withoutForegroundServiceDidNotStopInTimeException.regression:Bitkit with notifications enabled → start background node service → force sticky/null restart condition: service does not promote fromonCreate()and does not crash withForegroundServiceStartNotAllowedException.regression:Node notification → tap Stop: foreground service notification is removed and app/service stops cleanly.Automated Checks
app/src/test/java/to/bitkit/androidServices/LightningNodeServiceTest.ktcovers explicit start action, typeddataSyncforeground promotion, null/unsupported restart intents, promotion failure, duplicate starts, stop action ordering, and API-35 timeout ordering../gradlew testDevDebugUnitTest --tests to.bitkit.androidServices.LightningNodeServiceTestjust compilejust testjust lintjust lintexited successfully; it printed existing unrelated detekt findings inAppViewModel.ktandSupportScreen.kt.