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: direct usage from Lazy<CoreLogic> (WPB-10304) 🍒 #3281

Merged

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Aug 5, 2024

BugWPB-10304 [Android] circular dependency on app start

This PR was automatically cherry-picked based on the following PR:

Original PR description:



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 SQPIT-764
    • 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

Getting this crash when opening and closing the app multiple times in a sequence:

java.lang.IllegalStateException: Scoped provider was invoked recursively returning different results: Ub.r@6b06a8f & Ub.r@32f211c. This is likely due to a circular dependency.

Causes (Optional)

Although it looked like a circular dependency in the first instance, looking at the code and the crash error, it felt more like a direct trying access to Lazy<CoreLogic.

My conclusion is that It was introduced from this PR : fix: inject usecases lazily in WireActivityViewModel (WPB-6874) by adding CoreLogic as Lazy<CoreLogic>

You can check datadog from here:
DataDog All Errors

DataDog First Error

Solutions

  1. Add Lazy<> for CoreLogic on these ViewModels:
  • FeatureFlagNotificationViewModel
  • CommonTopAppBarViewModel
  • LegalHoldRequestedViewModel
  • LegalHoldDeactivatedViewModel

The reason the issue crashes on LegalHoldRequestedViewModel is because as soon as WireActivity starts, it starts listening for legal hold status to show the dialog, thus invoking coreLogic when it needs a .get() before or something was it was not initialized in time.

  • With the fix we can now monitor datadog for this specific crash if it happens again. If it does, we can then try another approach, which would be removing the changes from this PR and also remove the usage of Lazy<CoreLogic from WireActivityViewModel.

Testing

Test Coverage (Optional)

  • I have added automated test to this contribution

How to Test

Currently the only way to test (as from seeing from the ticket as well) is to open and close the app multiple times until there is a crash (but not very reliable).

@github-actions github-actions bot added cherry-pick PR is cherry-picking changes from another banch echoes: unplanned Any work item that isn’t part of the product or technical roadmap. size/XS labels Aug 5, 2024
Copy link

sonarcloud bot commented Aug 6, 2024

@codecov-commenter
Copy link

codecov-commenter commented Aug 6, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 4 lines in your changes missing coverage. Please review.

Project coverage is 44.55%. Comparing base (eafc978) to head (3fc35f3).

Files Patch % Lines
...d/ui/home/sync/FeatureFlagNotificationViewModel.kt 86.66% 2 Missing ⚠️
...ialog/deactivated/LegalHoldDeactivatedViewModel.kt 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #3281   +/-   ##
========================================
  Coverage    44.55%   44.55%           
========================================
  Files          453      453           
  Lines        15198    15198           
  Branches      2527     2527           
========================================
  Hits          6772     6772           
  Misses        7708     7708           
  Partials       718      718           
Files Coverage Δ
...ld/dialog/requested/LegalHoldRequestedViewModel.kt 88.63% <100.00%> (ø)
...d/ui/home/sync/FeatureFlagNotificationViewModel.kt 56.57% <86.66%> (ø)
...ialog/deactivated/LegalHoldDeactivatedViewModel.kt 81.57% <60.00%> (ø)

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 eafc978...3fc35f3. Read the comment docs.

Copy link
Contributor Author

github-actions bot commented Aug 6, 2024

Built wire-android-staging-compat-pr-3281.apk is available for download

Copy link
Contributor Author

github-actions bot commented Aug 6, 2024

Built wire-android-dev-debug-pr-3281.apk is available for download

@alexandreferris alexandreferris added this pull request to the merge queue Aug 6, 2024
github-merge-queue bot pushed a commit that referenced this pull request Aug 6, 2024
Signed-off-by: alexandreferris <[email protected]>
Co-authored-by: Alexandre Ferris <[email protected]>
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 6, 2024
@alexandreferris alexandreferris added this pull request to the merge queue Aug 6, 2024
Merged via the queue into develop with commit 55117ba Aug 6, 2024
12 checks passed
@alexandreferris alexandreferris deleted the fix/direct_usage_from_lazy_corelogic-cherry-pick branch August 6, 2024 09:00
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: unplanned Any work item that isn’t part of the product or technical roadmap. size/XS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants