Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: missing ServerConfig crashes after session expired / logout [WPB-5960] #2581

Merged
merged 4 commits into from
Jan 15, 2024

Conversation

AndroidBob
Copy link
Collaborator

@AndroidBob AndroidBob commented Jan 12, 2024

BugWPB-5960 [Android] missing serverConfig crash

Cherry pick from the original PR:


⚠️ Conflicts during cherry-pick:
app/src/main/kotlin/com/wire/android/GlobalObserversManager.kt
app/src/main/kotlin/com/wire/android/ui/WireActivity.kt
app/src/main/kotlin/com/wire/android/ui/home/sync/FeatureFlagNotificationViewModel.kt
app/src/test/kotlin/com/wire/android/ui/home/sync/FeatureFlagNotificationViewModelTest.kt
kalium


PR Submission Checklist for internal contributors

  • The PR Title

    • conforms to the style of semantic commits messages¹ supported in Wire's Github Workflow²
    • contains a reference JIRA issue number like
    • answers the question: If merged, this PR will: ... ³
  • The PR Description

    • is free of optional paragraphs and you have filled the relevant parts to the best of your ability

What's new in this PR?

Issues

Top crashes types currently are the ones related to missing ServerConfig when making some actions.

Causes (Optional)

When session is expired (the app receives 403 when trying to refresh a token) there is an infinite loop, because the app tries to logout - deregister token which results in 401 and it triggers the auth token refresh again resulting in 403 and trying to logout again. After each iteration, CurrentSessionFlowUseCase emits the same item again, which triggers multiple actions in the whole app and creates a race condition when logging out (session should be invalid but with all the loop iterations in a fraction of a second the app can still get the previous value).
Some logout actions in Android project are not executed when account is logged out from kalium (when session expires, device is removed from another place or account deleted).
Some actions that require user session are allowed to be executed after the logout when this session is cleared and not existing anymore resulting in crashes.

Solutions

  • use instead of getting just a single initial value from to not show a state for the previous session when changed
  • update properties when the session changed
  • cancel the observing flows for previous session when changed
  • do not execute actions (at least dialog dismiss actions) if the current session is invalid or there is no session
  • fix issue with continue button on set app lock screen not always making actions properly (race condition)
  • register for logout callback triggered when the logout happens in kalium to execute all other required logout-related actions in Android
  • make non-dismissable
  • provide logs for

Dependencies (Optional)

Needs releases with:

Testing

Test Coverage (Optional)

  • I have added automated test to this contribution

PR Post Submission Checklist for internal contributors (Optional)

  • Wire's Github Workflow has automatically linked the PR to a JIRA issue

PR Post Merge Checklist for internal contributors

  • If any soft of configuration variable was introduced by this PR, it has been added to the relevant documents and the CI jobs have been updated.

References
  1. https://sparkbox.com/foundry/semantic_commit_messages
  2. https://github.com/wireapp/.github#usage
  3. E.g. .

@AndroidBob AndroidBob added the cherry-pick PR is cherry-picking changes from another banch label Jan 12, 2024
Copy link
Contributor

github-actions bot commented Jan 12, 2024

Test Results

743 tests  +1   743 ✅ +1   6m 36s ⏱️ - 4m 18s
102 suites ±0     0 💤 ±0 
102 files   ±0     0 ❌ ±0 

Results for commit 8dc5db2. ± Comparison against base commit e5ee064.

This pull request removes 1 and adds 2 tests. Note that renamed tests count towards both.
com.wire.android.ui.WireActivityViewModelTest ‑ when dismissNewClientsDialog is called, then cleared NewClients for user()
com.wire.android.ui.WireActivityViewModelTest ‑ given session does not exist, when dismissNewClientsDialog is called, then do nothing()
com.wire.android.ui.WireActivityViewModelTest ‑ given session exists, when dismissNewClientsDialog is called, then cleared NewClients for user()

♻️ This comment has been updated with latest results.

@AndroidBob
Copy link
Collaborator Author

Build 2525 failed.

@pull-request-size pull-request-size bot added size/M and removed size/S labels Jan 12, 2024
@saleniuk saleniuk requested review from a team, alexandreferris, borichellow, MohamadJaara, vitorhugods and Garzas and removed request for a team January 12, 2024 13:18
Copy link

codecov bot commented Jan 12, 2024

Codecov Report

Attention: 35 lines in your changes are missing coverage. Please review.

Comparison is base (e5ee064) 41.24% compared to head (8dc5db2) 41.39%.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #2581      +/-   ##
=============================================
+ Coverage      41.24%   41.39%   +0.14%     
+ Complexity      1132     1129       -3     
=============================================
  Files            361      361              
  Lines          13206    13255      +49     
  Branches        1744     1742       -2     
=============================================
+ Hits            5447     5487      +40     
- Misses          7226     7236      +10     
+ Partials         533      532       -1     
Files Coverage Δ
...rc/main/kotlin/com/wire/android/ui/WireActivity.kt 0.00% <ø> (ø)
...otlin/com/wire/android/ui/WireActivityViewModel.kt 72.13% <90.90%> (+0.59%) ⬆️
...id/ui/userprofile/self/SelfUserProfileViewModel.kt 0.00% <0.00%> (ø)
...n/com/wire/android/feature/AccountSwitchUseCase.kt 65.16% <62.50%> (+0.23%) ⬆️
.../kotlin/com/wire/android/GlobalObserversManager.kt 70.21% <50.00%> (-9.20%) ⬇️
...d/ui/home/sync/FeatureFlagNotificationViewModel.kt 55.61% <69.23%> (+4.72%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e5ee064...8dc5db2. Read the comment docs.

Copy link
Contributor

APKs built during tests are available here. Scroll down to Artifacts!

@AndroidBob
Copy link
Collaborator Author

Build 2536 succeeded.

The build produced the following APK's:

Copy link
Contributor

APKs built during tests are available here. Scroll down to Artifacts!

@AndroidBob
Copy link
Collaborator Author

Build 2543 succeeded.

The build produced the following APK's:

@saleniuk saleniuk added this pull request to the merge queue Jan 15, 2024
Merged via the queue into develop with commit fbc3835 Jan 15, 2024
14 checks passed
@saleniuk saleniuk deleted the fix/missing-serverconfig-crashes-cherry-pick branch January 15, 2024 13:43
@echoes-hq echoes-hq bot added the echoes: technical-roadmap Work contributing to the Technical Roadmap, to improve our velocity or reduce the technical debt. label Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick PR is cherry-picking changes from another banch echoes: technical-roadmap Work contributing to the Technical Roadmap, to improve our velocity or reduce the technical debt. size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants