Skip to content

Bug 2011184 - check fragment is added before finding nav controller.#56

Closed
pollym wants to merge 1 commit intomozilla-firefox:autolandfrom
pollym:illegalstate-qrcode-search-crash
Closed

Bug 2011184 - check fragment is added before finding nav controller.#56
pollym wants to merge 1 commit intomozilla-firefox:autolandfrom
pollym:illegalstate-qrcode-search-crash

Conversation

@pollym
Copy link
Contributor

@pollym pollym commented Feb 5, 2026

We are seeing IllegalStateExceptions in the play store from calling findNavController when the fragment is not associated with a transaction (the parentFragmentManager is null) isAdded() is the recommended way to find out if this fragment is attached to an activity and findNavController() is safe to call

NB this fix is based on static analysis only - plan is to keep an eye on the crash logs after it lands to confirm it works.

running a try here but it seems to have included every commit since dinosaurs roamed the earth, not sure what happened there

We are seeing `IllegalStateException`s in the play store from calling `findNavController` when the fragment is not associated with a transaction (the parentFragmentManager is null)
`isAdded()` is the recommended way to find out if this fragment is attached to an activity and  `findNavController()` is safe to call

NB this fix is based on static analysis only - plan is to keep an eye on the crash logs after it lands to confirm it works.
@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

View this pull request in Lando to land it once approved.

Copy link
Contributor

@segunfamisa segunfamisa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I think the speculative fix is okay, thank you.

Copy link
Contributor

@segunfamisa segunfamisa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to do anything when the fragment is not added? Log an error with some state?

@pollym
Copy link
Contributor Author

pollym commented Feb 6, 2026

Do we need to do anything when the fragment is not added? Log an error with some state?

it's a good question, but i don't think so - suspect nobody would care about this error, and it would just create noise in the logs.
this branch would only happen if the fragment is being removed, like if the user launched it then quickly hit back or something, so it wouldn't be user-perceivable (if that is a word 😅)

lando-prod-mozilla bot pushed a commit that referenced this pull request Feb 6, 2026
We are seeing `IllegalStateException`s in the play store from calling `findNavController` when the fragment is not associated with a transaction (the parentFragmentManager is null) `isAdded()` is the recommended way to find out if this fragment is attached to an activity and  `findNavController()` is safe to call

NB this fix is based on static analysis only - plan is to keep an eye on the crash logs after it lands to confirm it works.

[running a try here](https://treeherder.mozilla.org/jobs?repo=try&revision=f74abab716cd9b4f9af2b1742294c4712f80644c) but it seems to have included every commit since dinosaurs roamed the earth, not sure what happened there

Pull request: #56
@lando-prod-mozilla
Copy link

Pull request closed by commit c0d96cf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants