Skip to content

Bug 2053379 - Fix ShareFragment crash on rapid menu clicks. r=#android-reviewers#318

Closed
toaha63 wants to merge 1 commit into
mozilla-firefox:mainfrom
toaha63:toaha63-patch-1
Closed

Bug 2053379 - Fix ShareFragment crash on rapid menu clicks. r=#android-reviewers#318
toaha63 wants to merge 1 commit into
mozilla-firefox:mainfrom
toaha63:toaha63-patch-1

Conversation

@toaha63

@toaha63 toaha63 commented Jul 8, 2026

Copy link
Copy Markdown

The crash occurs when the user clicks the share icon rapidly. The root cause is a race condition in MenuNavigationMiddleware.kt.

Problem:
In the MenuAction.Navigate.Share block, onDismiss() is called asynchronously after shareUseCases.shareUrl(). This can interfere with the back stack when the share button is clicked multiple times in quick succession, leading to an IllegalStateException.

Solution:
Replace onDismiss() with a synchronous and safe navigation call: navController.popBackStack(R.id.menuDialogFragment, true).

This ensures the menu dialog is removed from the back stack immediately and before navigating to the ShareFragment, eliminating the race condition.

Tested:

  • Verified locally that rapid clicking no longer causes a crash.
  • Confirmed that the share functionality works as expected in both normal and private browsing modes.

…d-reviewers

The crash occurs when the user clicks the share icon rapidly. 
The root cause is a race condition in `MenuNavigationMiddleware.kt`.

**Problem:**
In the `MenuAction.Navigate.Share` block, `onDismiss()` is called 
asynchronously after `shareUseCases.shareUrl()`. This can interfere 
with the back stack when the share button is clicked multiple times 
in quick succession, leading to an `IllegalStateException`.

**Solution:**
Replace `onDismiss()` with a synchronous and safe navigation call:
`navController.popBackStack(R.id.menuDialogFragment, true)`.

This ensures the menu dialog is removed from the back stack 
immediately and *before* navigating to the ShareFragment, 
eliminating the race condition.

**Tested:**
- Verified locally that rapid clicking no longer causes a crash.
- Confirmed that the share functionality works as expected in both 
  normal and private browsing modes.

Signed-off-by: Hasin Israk Toaha <128958545+toaha63@users.noreply.github.com>
@firefoxci-taskcluster

Copy link
Copy Markdown
No Taskcluster jobs started for this pull request

The allowPullRequests configuration for this repository (in .taskcluster.yml on the default branch) does not allow starting tasks for this pull request.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

(Automated Close) Please do not file pull requests here, see https://firefox-source-docs.mozilla.org/contributing/how_to_submit_a_patch.html

@github-actions github-actions Bot closed this Jul 8, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant