Skip to content

Fix crash on SubmitDataUseCase - #3885

Open
andreia-ferreira wants to merge 4 commits into
masterfrom
andreia/3882/fix-submit-data-usecase-crash
Open

Fix crash on SubmitDataUseCase#3885
andreia-ferreira wants to merge 4 commits into
masterfrom
andreia/3882/fix-submit-data-usecase-crash

Conversation

@andreia-ferreira

@andreia-ferreira andreia-ferreira commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Fixes #3882

The crash could be reproduced by doing the following:

  1. Start collecting data and past a draw area/drop pin task
  2. Put the app on background
  3. Simulate destroying the background process by executing either adb shell am kill org.groundplatform.android or having developer options 'no background processes'
  4. Go back to the app and complete data collection
  5. The app would crash when reaching the end of data collection

This was because, when the OS kills the app in the background, the data collection screen is recreated at the task the user was in, but with none of the data collected recovered, which caused the crash mentioning the AddLoi task was missing, and previous answers were also silently missing. The only draft recovery path was when the activity would be recreated and the home screen carried the data in nav arguments.

This PR does the following changes:

  • DataCollectionInitializer now restores draft data so that the screen recovers correctly regardless of how it was opened
  • TaskSequenceHandler makes it impossible for a task sequence to resume past a mandatory task that the user hasn't answered to avoid cases where data is silently missing

Before:

Screen_recording_20260814_160426.webm

After:

Screen_recording_20260814_160539.webm

@shobhitagarwal1612 PTAL?

Comment on lines +144 to +149
private suspend fun findDraft(survey: Survey, jobId: String, loiId: String?): DraftSubmission? {
val draftId = submissionRepository.getDraftSubmissionsId()
val draft =
if (draftId.isEmpty()) null else submissionRepository.getDraftSubmission(draftId, survey)
return draft?.takeIf { it.surveyId == survey.id && it.jobId == jobId && it.loiId == loiId }
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we move this to SubmissionRepository? Or move this logic within getDraftSubmission

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.

[Trending crash] IllegalStateException: AddLoi task response missing

2 participants