[FIX] ProductImagesFragment activity death #9111
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes: #9100
Description
Sentry Issue: WOOCOMMERCE-ANDROID-6VF
To reproduce the crash:
don't keep activitiesThe crash happens because two fragments use the same ViewModel while inside of the model, it expects specific sets of arguments passed from a Bundle
In the older version of Hilt, for some unclear reason in this situation, it was a passing bundle from the first fragment in the back stack, which was
ProductImagesFragment, and therefore crash didn't happen, although the state could be inconsistent already because state inside of the VM not recreated properly.With the update hilt, it passes the latest bundle there; that's why it cannot recover required
imagesAs a quick workaround, I just pass all the arguments from the first fragment to the second, but issues with the state still stay here because there is an inconsistency between the stored in the bundle state and the state that is kept inside the VM
Ideally, we should decouple two fragments and use 2 VMs and communicate.
Testing instructions
Images/gif
RELEASE-NOTES.txtif necessary.