-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
High
-
Affects Version/s: None
-
STOP TB Sprint 12
Summary
Investigate and fix ForegroundServiceDidNotStartInTimeException raised by WorkManager's SystemForegroundService.
Background / Context
Source: StopTB Android Crashlytics RCA (Oct 15–21 2026, release 2.2.3). RCA ref RCA-07, status: Root Cause Not Conclusively Established (hypothesis H7 unresolved). Priority: P1. 42 events / 35 users (4.4% of crashes), 2 variants, first seen 2.0, still occurring in 2.2.3. Not tagged repetitive by Crashlytics.
Problem Statement
A worker that calls setForeground() starts but does not reach startForeground() within the platform timeout, so the OS kills the app.
Current Behaviour (Actual)
- Crash: RemoteServiceException$ForegroundServiceDidNotStartInTimeException at ActivityThread.java:2591 (framework frame, no app frame).
- PullAshaWorker and PullFilariaFromAmritWorker call setForeground(); nothing in the code explains the delay.
- Possible contributor (unproven): memory/CPU pressure from the OOM cluster (RCA-01).
Expected Behaviour / Requirement
Workers promote to foreground within the platform timeout and no ForegroundServiceDidNotStartInTimeException occurs. Root cause to be established first.
User Story
As a field user, I want background data pulls to run without the app being killed, so that sync completes reliably.
Acceptance Criteria
- Given the two Crashlytics variants, When analysed, Then the root cause is documented (stack-trace variants examined, all workers using setForeground/expedited work reviewed) (CAPA-16).
- Given the fix, When doWork starts, Then setForeground() is called first.
- After release, Crashlytics shows no new events for this issue.
Business Rules / Validations
None identified.
Dependencies
Possibly related to RCA-01 OOM ticket (STOP-778); relationship unproven.
Impact / Affected Areas
PullAshaWorker.kt, PullFilariaFromAmritWorker.kt, other workers using setForeground/getForegroundInfo; background sync.
Out of Scope
Changes to unrelated worker logic.
QA / Testing Considerations
Run workers under low-memory/CPU-constrained conditions; verify foreground notification appears promptly; monitor Crashlytics after release.
Open Questions / Clarifications
- Only two workers found; other workers and the 2 stack-trace variants not examined [TBD].
- Re-evaluate after the OOM fix (STOP-778) ships, since pressure from RCA-01 may be a contributor.
Source: StopTB_Crashlytics_RCA.xlsx (RCA-07, CAPA-16).
- relates to
-
STOP-786 [Crashlytics][2.4] ForegroundServiceDidNotStartInTimeException from WorkManager still crashing in 2.3 (250 events / 155 users in 30 days)
-
- Analysis
-