Fix crash when Snackbar callback triggered after fragment detach#6911
Merged
seadowg merged 1 commit intogetodk:v2025.3.xfrom Oct 1, 2025
Merged
Fix crash when Snackbar callback triggered after fragment detach#6911seadowg merged 1 commit intogetodk:v2025.3.xfrom
seadowg merged 1 commit intogetodk:v2025.3.xfrom
Conversation
03250a5 to
e1c8117
Compare
6 tasks
seadowg
approved these changes
Oct 1, 2025
Member
seadowg
left a comment
There was a problem hiding this comment.
Good catch!
@alyblenkin I think it'd be worth having a think about this flow: scanning a barcode and then hitting back while the snackbar is showing. Currently, that's going to return the user to the form, but not save the value.
Collaborator
|
Interesting! If they scanned the barcode successfully and they hit back I would assume the value should be saved. If you hit back before it saved, I would expect to go back to get barcode button / page. When we remove this interstitial state (green state and snackbar) as part of #6914 you won't be able to get into this scenario. |
grzesiek2010
pushed a commit
to grzesiek2010/collect
that referenced
this pull request
Oct 13, 2025
Fix crash when Snackbar callback triggered after fragment detach
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This should prevent a crash we've seen on Crashlytics.
Steps to reproduce the issue:
The crash occurs because the fragment gets detached, and then the Snackbar callback still tries to handle the scanned code.
Why is this the best possible solution? Were any other approaches considered?
This is the easiest solution. One alternative approach could be to dismiss the Snackbar when the fragment is detached to avoid handling the callback, but that would likely be more complex.
How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
It should just fix the issue. I can't think of any risk here that we should take into account.
Do we need any specific form for testing your changes? If so, please attach one.
No.
Does this change require updates to documentation? If so, please file an issue here and include the link below.
No.
Before submitting this PR, please make sure you have:
./gradlew connectedAndroidTest(or./gradlew testLab) and confirmed all checks still passDateFormatsTest