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) #3279

Merged

Conversation

alexandreferris
Copy link
Contributor

@alexandreferris alexandreferris commented Aug 5, 2024

BugWPB-10304 [Android] circular dependency on app start


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).

@echoes-hq echoes-hq bot added the echoes: unplanned Any work item that isn’t part of the product or technical roadmap. label Aug 5, 2024
@alexandreferris alexandreferris self-assigned this Aug 5, 2024
@alexandreferris alexandreferris requested review from a team, typfel, yamilmedina, MohamadJaara, vitorhugods and saleniuk and removed request for a team August 5, 2024 08:10
@codecov-commenter
Copy link

codecov-commenter commented Aug 5, 2024

Codecov Report

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

Project coverage is 44.56%. Comparing base (deb752a) to head (15a6e53).

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                 @@
##           release/candidate    #3279   +/-   ##
==================================================
  Coverage              44.56%   44.56%           
==================================================
  Files                    453      453           
  Lines                  15188    15188           
  Branches                2522     2522           
==================================================
  Hits                    6768     6768           
  Misses                  7702     7702           
  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 deb752a...15a6e53. Read the comment docs.

Copy link

sonarcloud bot commented Aug 5, 2024

Copy link
Contributor

github-actions bot commented Aug 5, 2024

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

Copy link
Contributor

github-actions bot commented Aug 5, 2024

Built wire-android-internal-compat-pr-3279.apk is available for download

@alexandreferris alexandreferris added this pull request to the merge queue Aug 5, 2024
Merged via the queue into release/candidate with commit 4c52a26 Aug 5, 2024
12 checks passed
@alexandreferris alexandreferris deleted the fix/direct_usage_from_lazy_corelogic branch August 5, 2024 10:33
github-actions bot pushed a commit that referenced this pull request Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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