chore(runway): cherry-pick fix: Android In-App Browser Crash#22269
Merged
joaoloureirop merged 1 commit intorelease/7.58.1from Nov 6, 2025
Merged
chore(runway): cherry-pick fix: Android In-App Browser Crash#22269joaoloureirop merged 1 commit intorelease/7.58.1from
joaoloureirop merged 1 commit intorelease/7.58.1from
Conversation
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> The app crashes on Android when users grant **camera + microphone** permissions through the in-app browser (e.g., visiting https://permission.site/). Root Cause: The WebView permission handling code had a fundamental architectural flaw when multiple permissions (camera + microphone) were requested simultaneously: Old behavior: Showed separate dialogs for each permission (one for camera, one for microphone) Each dialog's "Allow" button independently called request.grant() Android's WebView API only allows calling grant() or deny() once per permission request When the user clicked "Allow" on the second dialog → CRASH: "Either grant() or deny() has been already called" Solution: Rewrote the permission handling logic in RNCWebChromeClient.java: Changed permission handling to show ONE dialog for all permissions: - "Allow example.com to use your camera and microphone?" - Call grant() only once with all permissions together - Added error handling to prevent crashes in edge cases Android build for this PR: https://app.bitrise.io/build/560c02e8-611e-4bfd-a24c-34e69751c86b?tab=artifacts PR to browser: MetaMask/react-native-webview-mm#72 <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry:null Fixes: #22162 ```gherkin Feature: Fix Android double permission bug on webview Scenario: App does not crash when user grant/deny camera + microphone permission Given user navigates to website https://permission.site in website When user select Camera + Microphone Then user is able give/deny permission to Camera and Microphone without app crashing ``` <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> Android Before  Android After  <!-- [screenshots/recordings] --> - [x] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. - [x] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [x] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Consolidates Android WebView permission flow into a single dialog with a single grant call for multiple resources, adds error handling, and delivers via a Yarn patch of @metamask/react-native-webview. > > - **Android WebView (`RNCWebChromeClient.java`)**: > - Show a single confirmation dialog for multiple already-OS-granted permissions with a combined message. > - Aggregate requested resources and call `request.grant()` once; map `CAMERA` → `RESOURCE_VIDEO_CAPTURE`, `RECORD_AUDIO` → `RESOURCE_AUDIO_CAPTURE`, handle `RESOURCE_PROTECTED_MEDIA_ID`. > - Reset state before handling requests; manage `permissionRequest`/`grantedPermissions` lifecycle; only set `permissionRequest` when system permissions must be requested. > - Wrap `grant()` with `try/catch` to ignore `IllegalStateException` and prevent duplicate grant/deny errors. > - Minor UX: delay enabling the "Allow" button to avoid accidental taps. > - **Dependencies**: > - Use Yarn patch for `@metamask/react-native-webview@14.5.0` via `.yarn/patches/...`; update `package.json` and `yarn.lock`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 7396b7f. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: metamaskbot <metamaskbot@users.noreply.github.com>
Contributor
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
joaoloureirop
approved these changes
Nov 6, 2025
|
Collaborator
|
No release label on PR. Adding release label release-7.58.1 on PR, as PR was cherry-picked in branch 7.58.1. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.



Description
The app crashes on Android when users grant camera + microphone
permissions through the in-app browser (e.g., visiting
https://permission.site/).
Root Cause:
The WebView permission handling code had a fundamental architectural
flaw when multiple permissions (camera + microphone) were requested
simultaneously:
Old behavior: Showed separate dialogs for each permission (one for
camera, one for microphone)
Each dialog's "Allow" button independently called request.grant()
Android's WebView API only allows calling grant() or deny() once per
permission request
When the user clicked "Allow" on the second dialog → CRASH: "Either
grant() or deny() has been already called"
Solution:
Rewrote the permission handling logic in RNCWebChromeClient.java:
Changed permission handling to show ONE dialog for all permissions:
Android build for this PR:
https://app.bitrise.io/build/560c02e8-611e-4bfd-a24c-34e69751c86b?tab=artifacts
PR to browser:
MetaMask/react-native-webview-mm#72
Changelog
CHANGELOG entry:null
Related issues
Fixes: #22162
Manual testing steps
Screenshots/Recordings
Before
Android Before

After
Android After

Pre-merge author checklist
Docs and MetaMask Mobile
Coding
Standards.
if applicable
guidelines).
Not required for external contributors.
Pre-merge reviewer checklist
app, test code being changed).
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
Note
Aggregates Android WebView camera/microphone permission flows into a single confirmation and safely grants once, wired via a Yarn patch to @metamask/react-native-webview.
grantedPermissions/permissionRequestconsistently.@metamask/react-native-webview@14.5.0to a Yarn patch via.yarn/patches/@metamask-react-native-webview-*.patchand updateyarn.lock.Written by Cursor Bugbot for commit 712412c. This will update automatically on new commits. Configure here.
Co-authored-by: metamaskbot metamaskbot@users.noreply.github.com 5c63946