Skip to content

Fix navigation crash - #3853

Merged
andreia-ferreira merged 7 commits into
masterfrom
andreia/3846/fix-navigation-crash
Jul 27, 2026
Merged

Fix navigation crash#3853
andreia-ferreira merged 7 commits into
masterfrom
andreia/3846/fix-navigation-crash

Conversation

@andreia-ferreira

@andreia-ferreira andreia-ferreira commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Fixes #3846

The crash could be reproduced with the following steps:
1 - Enable 'Don't keep activities' on Developer Settings
2 - Turn off network connection
3 - Start data collection and complete a few tasks
4 - Put the app on the background
5 - Go back to Ground
6 - Crash

After the app was killed in the background, MainViewModel was recreated and immediately received the signed-in user again. When in offline mode, the MainVM would be recreated and get the user right away since there was no connection for updateRemoteUserInfo. Offline this happened almost instantly, because updateRemoteUserInfo returns early when there is no connection instead, navigation then proceeded to the Home screen, popping the restored back stack. So when the data collection screen tried to fetch its VM from the back stack it crashed.

Now the MainActivity will only proceed with this rerouting if the user is still on startup or signIn screen so a restored screen is left alone.
There is also a small refactor changing MainUiState to MainUiEffect since it mostly works with one time events rather than a screen state.

@shobhitagarwal1612 PTAL?

@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.00000% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.40%. Comparing base (44bcd71) to head (7c1ca33).

Files with missing lines Patch % Lines
...rg/groundplatform/android/ui/main/MainViewModel.kt 68.00% 5 Missing and 3 partials ⚠️
...org/groundplatform/android/ui/main/MainActivity.kt 73.91% 1 Missing and 5 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3853      +/-   ##
============================================
+ Coverage     67.37%   67.40%   +0.03%     
- Complexity     1838     1840       +2     
============================================
  Files           407      407              
  Lines         10755    10759       +4     
  Branches       1418     1420       +2     
============================================
+ Hits           7246     7252       +6     
+ Misses         2763     2762       -1     
+ Partials        746      745       -1     
Files with missing lines Coverage Δ
...org/groundplatform/android/ui/main/MainUiEffect.kt 100.00% <100.00%> (ø)
...org/groundplatform/android/ui/main/MainActivity.kt 43.82% <73.91%> (+6.91%) ⬆️
...rg/groundplatform/android/ui/main/MainViewModel.kt 65.57% <68.00%> (-0.53%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@andreia-ferreira
andreia-ferreira force-pushed the andreia/3846/fix-navigation-crash branch from d5219ab to c0ea35e Compare July 23, 2026 09:41
@andreia-ferreira
andreia-ferreira marked this pull request as ready for review July 23, 2026 10:32
Comment thread app/src/main/java/org/groundplatform/android/ui/main/MainViewModel.kt Outdated
Comment thread app/src/main/java/org/groundplatform/android/ui/main/MainViewModel.kt Outdated
@andreia-ferreira
andreia-ferreira merged commit 0f57b1e into master Jul 27, 2026
19 checks passed
@andreia-ferreira
andreia-ferreira deleted the andreia/3846/fix-navigation-crash branch July 27, 2026 08:03
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] IllegalArgumentException: action_home_screen_fragment_to_dataCollectionFragment cannot be found from the current destination

2 participants