Skip to content

Bug 2059390: fix crash in SitePermissionsFragment.onDismiss - #321

Closed
pollym wants to merge 1 commit into
mozilla-firefox:autolandfrom
pollym:fix-crash-site-permissions
Closed

Bug 2059390: fix crash in SitePermissionsFragment.onDismiss#321
pollym wants to merge 1 commit into
mozilla-firefox:autolandfrom
pollym:fix-crash-site-permissions

Conversation

@pollym

@pollym pollym commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

If a fragment is detached, it is no longer safe to call requireComponents, because this method throws if the context is null. In this case, BaseBrowserFragment is not attached and returning true from shouldHide will stop us from showing the permission prompt, rather than crashing. Also checked hidePermissionsPrompt which will be called if shouldHide is true. This allows for the case of the fragment not being attached by using an optional and a let, so should be safe to call in this detached fragment case.

try is running here

If a fragment is detached, it is no longer safe to call `requireComponents`, because this method throws if the `context` is null.
In this case, `BaseBrowserFragment` is not attached and returning true from `shouldHide` will stop us from showing the permission prompt, rather than crashing.
Also checked `hidePermissionsPrompt` which will be called if `shouldHide` is true. This allows for the case of the fragment not being attached by using an optional and a let, so should be safe to call in this detached fragment case.
@github-actions

Copy link
Copy Markdown
Contributor

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

@pollym

pollym commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

i couldn't think of an easy way to write a unit test around this, but if anyone has an idea lmk

@segunfamisa segunfamisa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this patch!

lando-worker Bot pushed a commit that referenced this pull request Jul 31, 2026
…misa

If a fragment is detached, it is no longer safe to call `requireComponents`, because this method throws if the `context` is null. In this case, `BaseBrowserFragment` is not attached and returning true from `shouldHide` will stop us from showing the permission prompt, rather than crashing. Also checked `hidePermissionsPrompt` which will be called if `shouldHide` is true. This allows for the case of the fragment not being attached by using an optional and a let, so should be safe to call in this detached fragment case.

[try is running here](https://treeherder.mozilla.org/jobs?repo=try&revision=8dbfc878c87991d2da9167e8ad5daed2bb54579a)

Pull request: #321
@lando-worker

lando-worker Bot commented Jul 31, 2026

Copy link
Copy Markdown

Pull request closed by commit 4dbfb9d

@lando-worker lando-worker Bot closed this Jul 31, 2026
lando-worker Bot pushed a commit that referenced this pull request Aug 11, 2026
If a fragment is detached, it is no longer safe to call `requireComponents`, because this method throws if the `context` is null. In this case, `BaseBrowserFragment` is not attached and returning true from `shouldHide` will stop us from showing the permission prompt, rather than crashing. Also checked `hidePermissionsPrompt` which will be called if `shouldHide` is true. This allows for the case of the fragment not being attached by using an optional and a let, so should be safe to call in this detached fragment case.

[try is running here](https://treeherder.mozilla.org/jobs?repo=try&revision=8dbfc878c87991d2da9167e8ad5daed2bb54579a)

Pull request: #321

Differential Revision: https://phabricator.services.mozilla.com/D317829
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