-
Notifications
You must be signed in to change notification settings - Fork 132
Attempt to fix crash on ProductListToolbarHelper #11484
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
Conversation
@kidinov @jd-alexander I requested your review since you seem to have some past background about this, I'm keeping the PR as draft for now, my goal is just to start a discussion, and see if the theory above makes sense, then discuss if the fix is the appropriate one. |
@@ -86,7 +90,7 @@ class ProductListToolbarHelper @Inject constructor( | |||
this.viewModel = productListViewModel | |||
this.binding = binding | |||
|
|||
fragment.lifecycle.addObserver(this) | |||
fragment.viewLifecycleOwner.lifecycle.addObserver(this) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change also ensures that we don't leak the fragment's view, we were setting binding
to null
in the fragment's onDestroy
due to tying it to its Lifecycle
, but now it'll be executed correctly on a matching callback of onDestroyView
.
📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #11484 +/- ##
============================================
+ Coverage 40.84% 40.88% +0.04%
Complexity 5180 5180
============================================
Files 1068 1067 -1
Lines 62283 62208 -75
Branches 8495 8484 -11
============================================
- Hits 25437 25436 -1
+ Misses 34559 34486 -73
+ Partials 2287 2286 -1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hichamboushaba Thank you! The potential fix makes sense to me
Have you considered adding a line in the release notes?
Thanks @kidinov for the review.
Done. |
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
Closes: #11089 Closes: #11480
Description
This is just an attempt to fix the crash occurring on
ProductListToolbarHelper
, my theory of the crash is this: "if we check the events in Sentry, we can see that it always occur during a configuration change, and since wepost
the action to refresh the menu to theToolbar
's handler, there seems to be a race condition where the posting happens, and then a configuration change happens before the callback is executed, which means that when it does, the app'sNavHostFragment
could be still not attached"To solve this, I did two changes to the
ProductListToolbarHelper
:Lifecycle
instead of the Fragment's one, this is needed to ensureonDestroy
is called during the View's detachment, and not after.Toolbar
's Handler when the view is destroyed.Testing instructions
I couldn't reproduce the crash, so it's just code review, and ensuring nothing breaks.
Images/gif
RELEASE-NOTES.txt
if necessary. Use the "[Internal]" label for non-user-facing changes.