Repository navigation
[Android]Fix for Android BlazorWebView crash when opening image links in a new window - #38195
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 38195Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 38195" |
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
|
/azp run maui-pr-uitests , maui-pr-devicetests |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
This comment has been minimized.
This comment has been minimized.
MauiBot
left a comment
There was a problem hiding this comment.
Expert Review — 1 findings
See inline comments for details.
I have addressed mentioned concerns following:
|
|
/azp run maui-pr-uitests , maui-pr-devicetests |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
🟡 Changes recommended
The claimed Android regression test is missing from the submitted changes.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Fixes Android BlazorWebView crashes when opening _blank image links by resolving enclosing anchor URLs and safely handling unsupported launches.
Changes:
- Resolves image-link URLs via
RequestFocusNodeHref. - Rejects non-launchable schemes and handles
ActivityNotFoundException. - The supplied diff does not include the claimed Android regression test.
File summaries
| File | Description |
|---|---|
src/BlazorWebView/src/Maui/Android/BlazorWebChromeClient.cs |
Updates Android new-window URL handling and external launching. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
| var hitTestResult = view.GetHitTestResult(); | ||
| if (hitTestResult?.Type == global::Android.Webkit.HitTestResult.SrcImageAnchorType) | ||
| { | ||
| var handler = new FocusNodeHrefHandler(view.Context); | ||
| view.RequestFocusNodeHref(handler.ObtainMessage()); |
This comment has been minimized.
This comment has been minimized.
MauiBot
left a comment
There was a problem hiding this comment.
AI Review Summary
@BagavathiPerumal — new AI review results are available based on commit
333f637.
🗂️ Review Sessions — click to expand
🚦 Gate — Test Before & After Fix
Gate Result: ⚠️ SKIPPED
No tests were detected in this PR.
Recommendation: Add tests to verify the fix using the write-tests-agent.
📋 Pre-Flight — Context & Validation
PR #38195 Pre-Flight
Scope
- Issue: #35157 -
<a target="_blank">with image child<img src="data:image"/>causes app crash on Android in MAUI Blazor Hybrid - PR: #38195 -
[Android]Fix for Android BlazorWebView crash when opening image links in a new window - Base / head:
main/fix-35157 - Materialized review commit:
443f7fdf90d710891ca1d0f21f7cdadef609fbd7 - Platform: Android
- Gate: SKIPPED because the current PR contains no detected tests. Gate verification was not rerun and
gate/content.mdwas not modified.
Problem
For a BlazorWebView link such as <a href="https://www.google.com" target="_blank"><img src="data:image/..."></a>, Android reports the touched image source through WebView.GetHitTestResult().Extra. The current base implementation passes that data: URI to an ACTION_VIEW intent. Because Android has no activity for the URI, ActivityNotFoundException escapes from OnCreateWindow and crashes the app instead of opening the enclosing anchor URL.
Current PR Approach
The PR changes only src/BlazorWebView/src/Maui/Android/BlazorWebChromeClient.cs (+59/-4):
- Detect
HitTestResult.SrcImageAnchorType. - Use
RequestFocusNodeHrefwith a main-looperHandlerto retrieve the enclosing anchor's URL asynchronously. - Route ordinary and recovered URLs through
TryOpenInExternalBrowser. - Reject
data:,blob:,javascript:, andabout:URLs and containActivityNotFoundException.
Any candidate must use a materially different root-cause mechanism, not a relocated version of these checks.
Relevant Feedback and Edge Cases
- The current head removed the earlier UI-test changes; current inline feedback requests a regression test proving that the enclosing
hrefis used. - Ordinary text links must continue to open externally.
- Image anchors must open the enclosing anchor target rather than the nested image source.
- Missing, malformed, unsupported, or unhandled URLs must not crash the application.
- Prior design-only attempts recorded in PR discussion proposed suppressing
SrcImageAnchorTypelaunches and using a temporaryWebViewTransport; neither was implemented or validated. New candidates should avoid repeating those mechanisms.
Validation Boundary
No primary test or mandatory regression test is available in the current PR, and the hard execution contract does not authorize substituting an unrelated test or running a full suite. A candidate therefore cannot be reported as passing without new authorized test evidence.
The required baseline dry run also reports DIRTY WORKING DIRECTORY because unrelated pre-existing .github and eng changes are present. Those changes are outside this review and must remain untouched. If baseline establishment remains blocked, each try-fix attempt must record the blocker, create its required artifacts, run only pwsh .github/scripts/EstablishBrokenBaseline.ps1 -Restore, and leave no candidate edit applied.
🔬 Code Review — Deep Analysis
Expert PR Evaluation
Code Review — PR #38195
Independent Assessment
What this changes: Android BlazorWebChromeClient.OnCreateWindow now treats SrcImageAnchorType hits as a special case. It asks the WebView for the focused anchor's href through RequestFocusNodeHref, while ordinary hits continue to use HitTestResult.Extra. Both paths use a shared launcher that ignores blank and clearly non-launchable URLs and contains ActivityNotFoundException.
Inferred motivation: For an image inside a target="_blank" anchor, Android can return the nested image's data: URI from HitTestResult.Extra. Sending that value directly to an ACTION_VIEW intent can throw instead of opening the enclosing anchor.
Approach assessment: The production approach is sound and localized. RequestFocusNodeHref is the Android API intended to recover the focused link URL, the one-shot callback is bound to the main looper and disposed after delivery, normal text-link behavior remains on the direct path, and no static state or persistent subscription is introduced. The single mandated MAUI expert pass found no actionable code-line defects and wrote an empty inline-findings.json.
Reconciliation with PR Narrative
The stated root cause, Android-specific mechanism, scheme filtering, and ActivityNotFoundException handling match the submitted production diff. The description is not fully current, however: it discusses an Android-only regression test, but the submitted HEAD changes only BlazorWebChromeClient.cs and contains no test.
Prior Review Reconciliation
| Prior finding | Source | Status | Evidence |
|---|---|---|---|
| An earlier UI test could pass without proving that external navigation occurred. | MauiBot inline review on an earlier revision | 🔄 Obsolete in current HEAD | The entire test was removed from the submitted diff. |
| The current submitted change has no regression test for the data-image anchor path. | Copilot inline review on the current production file | The materialized diff contains one production file and no test files. |
No prior ❌ Error findings remain unresolved across the top-level review, inline-review, or PR issue-comment surfaces.
Blast Radius Assessment
- Runs for all instances: The changed helper is used for every Android BlazorWebView
_blanklaunch; only image-anchor hits take the new asynchronous focus-node branch. - Startup impact: None. The behavior runs only from
OnCreateWindow. - Static/shared state: None.
- Lifecycle: Each image-anchor request owns an independent one-shot
Handler; it retains no subscription or shared latch and disposes after message delivery.
CI Status
- Required-check result: Undetermined.
gh pr checks --requiredwas unavailable because GitHub CLI authentication is absent. - Anonymous evidence: The live PR head has a mixture of pending and cancelled
maui-prchecks, so it cannot be treated as passing. - Trusted Gate:
⚠️ SKIPPED because no tests were detected in the current PR; Gate verification was not rerun. - Classification/action: Coverage remains undetermined and confidence is capped at low.
Findings
⚠️ Warning — The submitted fix has no focused regression test
The production mechanism is plausible and no code defect was validated, but the current diff does not exercise the behavior that distinguishes the fix from a no-op: an image with a data: source inside a _blank anchor must launch the enclosing href without crashing. This also leaves the description's test claims stale.
No raw file-line finding was added for this gap because there is no changed test line on which to place an inline comment.
Failure-Mode Probing
- Ordinary text anchor: It still launches
HitTestResult.Extra, now through the guarded helper. - Image anchor with a data-image child: The focused-node callback uses the enclosing anchor URL instead of dispatching the nested image URI.
- Blank or clearly non-launchable URL: The helper returns without constructing or launching an intent.
- No activity handles the URL:
ActivityNotFoundExceptionis contained rather than escaping the WebChromeClient callback. - Disconnected WebView or repeated taps: No handler-level state is shared; each callback has its own message handler and context. The code does not subscribe to the WebView or mutate handler lifecycle state.
External Output Contract
Not applicable.
Verdict: NEEDS_DISCUSSION
Confidence: low — this is Android platform UI plumbing, required CI is not complete, and the current submitted HEAD has no regression-test evidence.
Summary: The production implementation is coherent and the expert pass found no actionable code-line defect. The missing focused test and undetermined CI prevent an LGTM recommendation for the submitted revision.
🛠️ Try-Fix — Analysis & Comparison
STEP 5a Try-Fix Aggregate - PR #38195
Candidate 1 - JavaScript Anchor Resolution
- Model:
gpt-5.3-codex - Result: Blocked
- Approach: When the leaf hit-test URL is non-launchable, use
WebView.EvaluateJavascriptto walk fromdocument.activeElementto its nearest enclosing anchor and return that anchor's resolvedhref. - Prior approaches avoided: This does not use the PR's
RequestFocusNodeHref/customHandlermechanism, hit-test-type suppression, or a temporaryWebViewTransport. - Mechanism-level difference: The candidate would resolve the DOM anchor directly instead of asking Android hit testing for the touched child resource or asking WebView's focus-node callback for an href.
- Files changed: None.
- Diff: Empty.
- Test result: Not run; no primary or mandatory regression test is authorized by the current Gate result.
- Failure analysis:
EstablishBrokenBaseline.ps1rejected the unrelated pre-existing dirty.githubandengfiles. No baseline state orRevertedFilesallow-list was created, so the skill prohibited implementation. The exact restore command ran and reportedNo baseline state found/Restored=False; no candidate edits existed. - Inline self-review: 0 findings; there was no candidate diff.
- Details:
../try-fix-1/content.md - Artifacts:
attempt-1/
Attempt Status
Both bounded candidates are complete.
Candidate 2 - Native Intent Capability Preflight
- Model:
gpt-5.6-sol - Result: Blocked
- Approach: Before calling
StartActivity, ask Android'sPackageManagerwhether theACTION_VIEWintent resolves to an installed activity, and decline an unresolvable launch rather than allowingActivityNotFoundExceptionto escape. - Prior approaches avoided: This does not use the PR's focus-node callback and scheme blacklist, the historical hit-test suppression or temporary
WebViewTransport, or Candidate 1's JavaScript DOM traversal. - Mechanism-level difference: The candidate would make native intent dispatch conditional on Android-reported handler availability. It addresses the crash at the activity-launch boundary rather than recovering an enclosing anchor URL from WebView state.
- Files changed: None.
- Diff: Empty.
- Test result: Not run; no primary or mandatory regression test is authorized by the current Gate result.
- Failure analysis: The mandatory baseline command again rejected the unrelated pre-existing dirty
.githubandengfiles. No baseline state orRevertedFilesallow-list was created, so implementation was prohibited. The exact restore command ran and reportedNo baseline state found/Restored=False; no candidate edits existed. - Inline self-review: 0 findings; there was no candidate diff.
- Details:
../try-fix-2/content.md - Artifacts:
attempt-2/
Comparison
| # | Model | Mechanism | Result | Empirical Test | Main Limitation |
|---|---|---|---|---|---|
| 1 | gpt-5.3-codex |
Resolve the nearest DOM anchor through JavaScript | Blocked | Not run | Asynchronous DOM/script dependency; unimplemented |
| 2 | gpt-5.6-sol |
Preflight native intent handler availability | Blocked | Not run | Prevents the crash but does not recover the enclosing anchor URL |
Final Aggregate Status
The maximum of two sequential candidates was reached. Both are design-only and unvalidated: the required try-fix baseline guard rejected unrelated pre-existing tracked changes before either candidate could edit the sole production target, and the current PR supplies no authorized test. No candidate code remains applied, both required restore commands completed with the expected verified no-state outcome, and no gate, build, full suite, or unrelated test was run.
Selected Fix: None. Neither blocked candidate has implementation or test evidence; Candidate 2 also does not preserve the intended image-anchor navigation behavior. The current PR approach remains the only implementation, but the Gate result provides no regression-test evidence for the current head.
Constraints
- Maximum two sequential candidates:
gpt-5.3-codex, thengpt-5.6-sol. - No cross-pollination, final audit, separate reviewer, or full test suite.
- Gate was skipped because no tests were detected; no substitute test is authorized.
📝 PR Finalize — Recommended Title & Description
Assessment: ✏️ Recommend updating — the title needs the component delimiter, and the description incorrectly says an Android regression test is present even though the submitted HEAD changes only production code.
Recommended title
[Android] BlazorWebView: Fix crash when opening target="_blank" image links
Recommended description
### Root cause
When a `target="_blank"` anchor contains an image, Android WebView can return the nested image's `data:` URI through `HitTestResult.Extra`. `BlazorWebChromeClient.OnCreateWindow` then passes that non-launchable URI to an `ACTION_VIEW` intent, causing an `ActivityNotFoundException` and crashing the app instead of opening the enclosing anchor URL.
### Description of Change
For `HitTestResult.SrcImageAnchorType`, the Android `BlazorWebChromeClient` now calls `RequestFocusNodeHref` with a main-looper `Handler` to retrieve the enclosing anchor's actual URL. Ordinary text links continue to use `HitTestResult.Extra`.
Both paths now use a shared launch helper that:
- ignores blank URLs and the `data:`, `blob:`, `javascript:`, and `about:` schemes;
- opens other URLs with an Android `ACTION_VIEW` intent; and
- handles `ActivityNotFoundException` when no activity can process the URL.
### Platform behavior and scope
**Android**
This implementation is Android-specific because it corrects Android WebView's `HitTestResult` and `RequestFocusNodeHref` path.
**Windows**
WebView2 receives new-window navigation through `NewWindowRequestedEventArgs.Uri` rather than Android's `HitTestResult.Extra`, so it does not resolve the nested image's `data:` URI through this code path. The `https://0.0.0.1/` address is BlazorWebView's internal virtual origin and represents separate WebView2 new-window routing behavior.
**iOS and Mac Catalyst**
These platforms use WKWebView and follow a different new-window navigation path; this Android implementation does not change their behavior.
### Platforms validated
- [x] iOS
- [x] Mac
- [x] Android
- [x] Windows
### Issues Fixed
Fixes #35157
### Output
| Platform | Before | After |
|---|---|---|
| Android | <video src="https://github.com/user-attachments/assets/be2fa02a-90bf-4413-9c53-7d4a1b12991f"> | <video src="https://github.com/user-attachments/assets/1e46f601-5b66-486f-a7aa-9526e4e67299"> |
🏁 Report — Final Recommendation
⚠️ Final Recommendation: REQUEST CHANGES
Winner: pr
The submitted production fix is the only implemented candidate and directly addresses both required behaviors: it avoids dispatching the nested image's data: URI and recovers the enclosing anchor URL so the intended external navigation can still occur. The single MAUI expert pass found no actionable production-code defect.
Approval is not warranted for the current revision because the trusted Gate was skipped after detecting no tests, the submitted diff contains no focused regression test, and current required-check coverage is undetermined. The author should add an Android regression test that proves the enclosing href is launched without crashing; a survival-only assertion or a no-op navigation path is insufficient.
Comparative Ranking
| Rank | Candidate | Implementation | Regression evidence | Assessment |
|---|---|---|---|---|
| 1 | pr |
Complete production change in BlazorWebChromeClient.cs |
Not run — Gate skipped | Sound, localized Android mechanism; the only candidate that both prevents the crash and preserves image-anchor navigation. |
| 2 | pr-plus-reviewer |
Identical to pr; reviewer.patch is empty |
Not run — no authorized targeted command | The expert found no code correction to apply. It has no behavioral or evidence advantage over the raw PR, so the raw candidate wins the tie. |
| 3 | try-fix-1 |
No diff; design-only JavaScript/DOM anchor lookup | Blocked / not run | Potentially preserves navigation, but baseline authorization failed and the asynchronous DOM mechanism was neither implemented nor validated. |
| 4 | try-fix-2 |
No diff; design-only Android intent-capability preflight | Blocked / not run | Preventing an unresolvable intent could avoid the crash, but it does not recover or open the enclosing anchor and therefore does not satisfy the full behavior. |
Regression-Test Ordering
No candidate executed the current regression test because the current PR supplies none. Consequently, there is no passing candidate or regression-test failure to compare directly. The two STEP 5a candidates remain below the implemented PR candidates because they were blocked before producing code or empirical evidence; no failed candidate is ranked above a passing candidate.
Expert Review
inline-findings.jsonis a valid empty JSON array.- The Android callback is one-shot, main-looper-bound, and disposed after delivery.
- Ordinary text links retain their direct hit-test URL path.
- Blank and clearly non-launchable URLs are ignored, and an absent activity handler no longer crashes the callback.
- No startup path, static state, subscription, or cross-platform implementation is changed.
Evidence Limits
- Trusted Gate:
⚠️ SKIPPED — no tests detected in this PR. - GitHub required checks: unavailable through unauthenticated
gh; anonymous live-head evidence showed pending and cancelledmaui-prchecks, not a completed pass. pr-plus-reviewer: sandbox identity and immutable baseline verified;git diff --checkpassed; no validation command was invented or rerun.
Required Change
Add focused Android coverage for a target="_blank" anchor containing a data: image. The test must distinguish the intended implementation from simply suppressing the launch by proving that the enclosing anchor navigation was initiated and that the HostApp remains usable after returning.
🧭 Next Steps — review latest findings
No alternative fix was selected for this run. Review the session findings and CI results before merging.
… in a new window (#38195) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Root cause The issue occurs because the Android WebView returns the nested image's data: URI through HitTestResult.Extra when a target="_blank" link contains an image. MAUI then attempts to open this non-launchable URI using an Android activity, causing an ActivityNotFoundException and crashing the app. ### Solution description The fix involves using RequestFocusNodeHref to retrieve the enclosing anchor's actual URL for image links while preserving the existing behavior for normal text links. It also rejects non-launchable URL schemes and safely handles ActivityNotFoundException, preventing the app from crashing. **Windows Behavior** The test behaves differently on Windows because WebView2 receives new-window navigation through NewWindowRequestedEventArgs.Uri instead of Android's HitTestResult.Extra. Therefore, Windows does not use the nested image's data: URI when resolving the enclosing link. The https://0.0.0.1/ address is BlazorWebView's internal virtual origin and represents a separate WebView2 new-window routing behavior. **Test Restriction** The regression test is compiled only for Android because it specifically verifies the Android WebView's HitTestResult and RequestFocusNodeHref behavior. Windows uses WebView2, while iOS and Mac Catalyst use WKWebView. Therefore, these platforms follow different new-window navigation paths and do not exercise this Android-specific code. Validated the behavior in the following platforms - [x] iOS - [x] Mac - [x] Android - [x] Windows ### Issues Fixed Fixes #35157 ### Output ScreenShot |Platform|Before|After| |--|--|--| |Android|<video src="https://github.com/user-attachments/assets/be2fa02a-90bf-4413-9c53-7d4a1b12991f">|<video src="https://github.com/user-attachments/assets/1e46f601-5b66-486f-a7aa-9526e4e67299">|
… in a new window (#38195) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Root cause The issue occurs because the Android WebView returns the nested image's data: URI through HitTestResult.Extra when a target="_blank" link contains an image. MAUI then attempts to open this non-launchable URI using an Android activity, causing an ActivityNotFoundException and crashing the app. ### Solution description The fix involves using RequestFocusNodeHref to retrieve the enclosing anchor's actual URL for image links while preserving the existing behavior for normal text links. It also rejects non-launchable URL schemes and safely handles ActivityNotFoundException, preventing the app from crashing. **Windows Behavior** The test behaves differently on Windows because WebView2 receives new-window navigation through NewWindowRequestedEventArgs.Uri instead of Android's HitTestResult.Extra. Therefore, Windows does not use the nested image's data: URI when resolving the enclosing link. The https://0.0.0.1/ address is BlazorWebView's internal virtual origin and represents a separate WebView2 new-window routing behavior. **Test Restriction** The regression test is compiled only for Android because it specifically verifies the Android WebView's HitTestResult and RequestFocusNodeHref behavior. Windows uses WebView2, while iOS and Mac Catalyst use WKWebView. Therefore, these platforms follow different new-window navigation paths and do not exercise this Android-specific code. Validated the behavior in the following platforms - [x] iOS - [x] Mac - [x] Android - [x] Windows ### Issues Fixed Fixes #35157 ### Output ScreenShot |Platform|Before|After| |--|--|--| |Android|<video src="https://github.com/user-attachments/assets/be2fa02a-90bf-4413-9c53-7d4a1b12991f">|<video src="https://github.com/user-attachments/assets/1e46f601-5b66-486f-a7aa-9526e4e67299">|
… in a new window (#38195) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Root cause The issue occurs because the Android WebView returns the nested image's data: URI through HitTestResult.Extra when a target="_blank" link contains an image. MAUI then attempts to open this non-launchable URI using an Android activity, causing an ActivityNotFoundException and crashing the app. ### Solution description The fix involves using RequestFocusNodeHref to retrieve the enclosing anchor's actual URL for image links while preserving the existing behavior for normal text links. It also rejects non-launchable URL schemes and safely handles ActivityNotFoundException, preventing the app from crashing. **Windows Behavior** The test behaves differently on Windows because WebView2 receives new-window navigation through NewWindowRequestedEventArgs.Uri instead of Android's HitTestResult.Extra. Therefore, Windows does not use the nested image's data: URI when resolving the enclosing link. The https://0.0.0.1/ address is BlazorWebView's internal virtual origin and represents a separate WebView2 new-window routing behavior. **Test Restriction** The regression test is compiled only for Android because it specifically verifies the Android WebView's HitTestResult and RequestFocusNodeHref behavior. Windows uses WebView2, while iOS and Mac Catalyst use WKWebView. Therefore, these platforms follow different new-window navigation paths and do not exercise this Android-specific code. Validated the behavior in the following platforms - [x] iOS - [x] Mac - [x] Android - [x] Windows ### Issues Fixed Fixes #35157 ### Output ScreenShot |Platform|Before|After| |--|--|--| |Android|<video src="https://github.com/user-attachments/assets/be2fa02a-90bf-4413-9c53-7d4a1b12991f">|<video src="https://github.com/user-attachments/assets/1e46f601-5b66-486f-a7aa-9526e4e67299">|
… in a new window (#38195) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Root cause The issue occurs because the Android WebView returns the nested image's data: URI through HitTestResult.Extra when a target="_blank" link contains an image. MAUI then attempts to open this non-launchable URI using an Android activity, causing an ActivityNotFoundException and crashing the app. ### Solution description The fix involves using RequestFocusNodeHref to retrieve the enclosing anchor's actual URL for image links while preserving the existing behavior for normal text links. It also rejects non-launchable URL schemes and safely handles ActivityNotFoundException, preventing the app from crashing. **Windows Behavior** The test behaves differently on Windows because WebView2 receives new-window navigation through NewWindowRequestedEventArgs.Uri instead of Android's HitTestResult.Extra. Therefore, Windows does not use the nested image's data: URI when resolving the enclosing link. The https://0.0.0.1/ address is BlazorWebView's internal virtual origin and represents a separate WebView2 new-window routing behavior. **Test Restriction** The regression test is compiled only for Android because it specifically verifies the Android WebView's HitTestResult and RequestFocusNodeHref behavior. Windows uses WebView2, while iOS and Mac Catalyst use WKWebView. Therefore, these platforms follow different new-window navigation paths and do not exercise this Android-specific code. Validated the behavior in the following platforms - [x] iOS - [x] Mac - [x] Android - [x] Windows ### Issues Fixed Fixes #35157 ### Output ScreenShot |Platform|Before|After| |--|--|--| |Android|<video src="https://github.com/user-attachments/assets/be2fa02a-90bf-4413-9c53-7d4a1b12991f">|<video src="https://github.com/user-attachments/assets/1e46f601-5b66-486f-a7aa-9526e4e67299">|
… in a new window (#38195) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Root cause The issue occurs because the Android WebView returns the nested image's data: URI through HitTestResult.Extra when a target="_blank" link contains an image. MAUI then attempts to open this non-launchable URI using an Android activity, causing an ActivityNotFoundException and crashing the app. ### Solution description The fix involves using RequestFocusNodeHref to retrieve the enclosing anchor's actual URL for image links while preserving the existing behavior for normal text links. It also rejects non-launchable URL schemes and safely handles ActivityNotFoundException, preventing the app from crashing. **Windows Behavior** The test behaves differently on Windows because WebView2 receives new-window navigation through NewWindowRequestedEventArgs.Uri instead of Android's HitTestResult.Extra. Therefore, Windows does not use the nested image's data: URI when resolving the enclosing link. The https://0.0.0.1/ address is BlazorWebView's internal virtual origin and represents a separate WebView2 new-window routing behavior. **Test Restriction** The regression test is compiled only for Android because it specifically verifies the Android WebView's HitTestResult and RequestFocusNodeHref behavior. Windows uses WebView2, while iOS and Mac Catalyst use WKWebView. Therefore, these platforms follow different new-window navigation paths and do not exercise this Android-specific code. Validated the behavior in the following platforms - [x] iOS - [x] Mac - [x] Android - [x] Windows ### Issues Fixed Fixes #35157 ### Output ScreenShot |Platform|Before|After| |--|--|--| |Android|<video src="https://github.com/user-attachments/assets/be2fa02a-90bf-4413-9c53-7d4a1b12991f">|<video src="https://github.com/user-attachments/assets/1e46f601-5b66-486f-a7aa-9526e4e67299">|
… in a new window (#38195) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Root cause The issue occurs because the Android WebView returns the nested image's data: URI through HitTestResult.Extra when a target="_blank" link contains an image. MAUI then attempts to open this non-launchable URI using an Android activity, causing an ActivityNotFoundException and crashing the app. ### Solution description The fix involves using RequestFocusNodeHref to retrieve the enclosing anchor's actual URL for image links while preserving the existing behavior for normal text links. It also rejects non-launchable URL schemes and safely handles ActivityNotFoundException, preventing the app from crashing. **Windows Behavior** The test behaves differently on Windows because WebView2 receives new-window navigation through NewWindowRequestedEventArgs.Uri instead of Android's HitTestResult.Extra. Therefore, Windows does not use the nested image's data: URI when resolving the enclosing link. The https://0.0.0.1/ address is BlazorWebView's internal virtual origin and represents a separate WebView2 new-window routing behavior. **Test Restriction** The regression test is compiled only for Android because it specifically verifies the Android WebView's HitTestResult and RequestFocusNodeHref behavior. Windows uses WebView2, while iOS and Mac Catalyst use WKWebView. Therefore, these platforms follow different new-window navigation paths and do not exercise this Android-specific code. Validated the behavior in the following platforms - [x] iOS - [x] Mac - [x] Android - [x] Windows ### Issues Fixed Fixes #35157 ### Output ScreenShot |Platform|Before|After| |--|--|--| |Android|<video src="https://github.com/user-attachments/assets/be2fa02a-90bf-4413-9c53-7d4a1b12991f">|<video src="https://github.com/user-attachments/assets/1e46f601-5b66-486f-a7aa-9526e4e67299">|
… in a new window (#38195) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Root cause The issue occurs because the Android WebView returns the nested image's data: URI through HitTestResult.Extra when a target="_blank" link contains an image. MAUI then attempts to open this non-launchable URI using an Android activity, causing an ActivityNotFoundException and crashing the app. ### Solution description The fix involves using RequestFocusNodeHref to retrieve the enclosing anchor's actual URL for image links while preserving the existing behavior for normal text links. It also rejects non-launchable URL schemes and safely handles ActivityNotFoundException, preventing the app from crashing. **Windows Behavior** The test behaves differently on Windows because WebView2 receives new-window navigation through NewWindowRequestedEventArgs.Uri instead of Android's HitTestResult.Extra. Therefore, Windows does not use the nested image's data: URI when resolving the enclosing link. The https://0.0.0.1/ address is BlazorWebView's internal virtual origin and represents a separate WebView2 new-window routing behavior. **Test Restriction** The regression test is compiled only for Android because it specifically verifies the Android WebView's HitTestResult and RequestFocusNodeHref behavior. Windows uses WebView2, while iOS and Mac Catalyst use WKWebView. Therefore, these platforms follow different new-window navigation paths and do not exercise this Android-specific code. Validated the behavior in the following platforms - [x] iOS - [x] Mac - [x] Android - [x] Windows ### Issues Fixed Fixes #35157 ### Output ScreenShot |Platform|Before|After| |--|--|--| |Android|<video src="https://github.com/user-attachments/assets/be2fa02a-90bf-4413-9c53-7d4a1b12991f">|<video src="https://github.com/user-attachments/assets/1e46f601-5b66-486f-a7aa-9526e4e67299">|
… in a new window (#38195) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Root cause The issue occurs because the Android WebView returns the nested image's data: URI through HitTestResult.Extra when a target="_blank" link contains an image. MAUI then attempts to open this non-launchable URI using an Android activity, causing an ActivityNotFoundException and crashing the app. ### Solution description The fix involves using RequestFocusNodeHref to retrieve the enclosing anchor's actual URL for image links while preserving the existing behavior for normal text links. It also rejects non-launchable URL schemes and safely handles ActivityNotFoundException, preventing the app from crashing. **Windows Behavior** The test behaves differently on Windows because WebView2 receives new-window navigation through NewWindowRequestedEventArgs.Uri instead of Android's HitTestResult.Extra. Therefore, Windows does not use the nested image's data: URI when resolving the enclosing link. The https://0.0.0.1/ address is BlazorWebView's internal virtual origin and represents a separate WebView2 new-window routing behavior. **Test Restriction** The regression test is compiled only for Android because it specifically verifies the Android WebView's HitTestResult and RequestFocusNodeHref behavior. Windows uses WebView2, while iOS and Mac Catalyst use WKWebView. Therefore, these platforms follow different new-window navigation paths and do not exercise this Android-specific code. Validated the behavior in the following platforms - [x] iOS - [x] Mac - [x] Android - [x] Windows ### Issues Fixed Fixes #35157 ### Output ScreenShot |Platform|Before|After| |--|--|--| |Android|<video src="https://github.com/user-attachments/assets/be2fa02a-90bf-4413-9c53-7d4a1b12991f">|<video src="https://github.com/user-attachments/assets/1e46f601-5b66-486f-a7aa-9526e4e67299">|
… in a new window (#38195) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Root cause The issue occurs because the Android WebView returns the nested image's data: URI through HitTestResult.Extra when a target="_blank" link contains an image. MAUI then attempts to open this non-launchable URI using an Android activity, causing an ActivityNotFoundException and crashing the app. ### Solution description The fix involves using RequestFocusNodeHref to retrieve the enclosing anchor's actual URL for image links while preserving the existing behavior for normal text links. It also rejects non-launchable URL schemes and safely handles ActivityNotFoundException, preventing the app from crashing. **Windows Behavior** The test behaves differently on Windows because WebView2 receives new-window navigation through NewWindowRequestedEventArgs.Uri instead of Android's HitTestResult.Extra. Therefore, Windows does not use the nested image's data: URI when resolving the enclosing link. The https://0.0.0.1/ address is BlazorWebView's internal virtual origin and represents a separate WebView2 new-window routing behavior. **Test Restriction** The regression test is compiled only for Android because it specifically verifies the Android WebView's HitTestResult and RequestFocusNodeHref behavior. Windows uses WebView2, while iOS and Mac Catalyst use WKWebView. Therefore, these platforms follow different new-window navigation paths and do not exercise this Android-specific code. Validated the behavior in the following platforms - [x] iOS - [x] Mac - [x] Android - [x] Windows ### Issues Fixed Fixes #35157 ### Output ScreenShot |Platform|Before|After| |--|--|--| |Android|<video src="https://github.com/user-attachments/assets/be2fa02a-90bf-4413-9c53-7d4a1b12991f">|<video src="https://github.com/user-attachments/assets/1e46f601-5b66-486f-a7aa-9526e4e67299">|
… in a new window (#38195) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Root cause The issue occurs because the Android WebView returns the nested image's data: URI through HitTestResult.Extra when a target="_blank" link contains an image. MAUI then attempts to open this non-launchable URI using an Android activity, causing an ActivityNotFoundException and crashing the app. ### Solution description The fix involves using RequestFocusNodeHref to retrieve the enclosing anchor's actual URL for image links while preserving the existing behavior for normal text links. It also rejects non-launchable URL schemes and safely handles ActivityNotFoundException, preventing the app from crashing. **Windows Behavior** The test behaves differently on Windows because WebView2 receives new-window navigation through NewWindowRequestedEventArgs.Uri instead of Android's HitTestResult.Extra. Therefore, Windows does not use the nested image's data: URI when resolving the enclosing link. The https://0.0.0.1/ address is BlazorWebView's internal virtual origin and represents a separate WebView2 new-window routing behavior. **Test Restriction** The regression test is compiled only for Android because it specifically verifies the Android WebView's HitTestResult and RequestFocusNodeHref behavior. Windows uses WebView2, while iOS and Mac Catalyst use WKWebView. Therefore, these platforms follow different new-window navigation paths and do not exercise this Android-specific code. Validated the behavior in the following platforms - [x] iOS - [x] Mac - [x] Android - [x] Windows ### Issues Fixed Fixes #35157 ### Output ScreenShot |Platform|Before|After| |--|--|--| |Android|<video src="https://github.com/user-attachments/assets/be2fa02a-90bf-4413-9c53-7d4a1b12991f">|<video src="https://github.com/user-attachments/assets/1e46f601-5b66-486f-a7aa-9526e4e67299">|
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Root cause
The issue occurs because the Android WebView returns the nested image's data: URI through HitTestResult.Extra when a target="_blank" link contains an image. MAUI then attempts to open this non-launchable URI using an Android activity, causing an ActivityNotFoundException and crashing the app.
Solution description
The fix involves using RequestFocusNodeHref to retrieve the enclosing anchor's actual URL for image links while preserving the existing behavior for normal text links. It also rejects non-launchable URL schemes and safely handles ActivityNotFoundException, preventing the app from crashing.
Windows Behavior
The test behaves differently on Windows because WebView2 receives new-window navigation through NewWindowRequestedEventArgs.Uri instead of Android's HitTestResult.Extra. Therefore, Windows does not use the nested image's data: URI when resolving the enclosing link. The https://0.0.0.1/ address is BlazorWebView's internal virtual origin and represents a separate WebView2 new-window routing behavior.
Test Restriction
The regression test is compiled only for Android because it specifically verifies the Android WebView's HitTestResult and RequestFocusNodeHref behavior. Windows uses WebView2, while iOS and Mac Catalyst use WKWebView. Therefore, these platforms follow different new-window navigation paths and do not exercise this Android-specific code.
Validated the behavior in the following platforms
Issues Fixed
Fixes #35157
Output ScreenShot
35157-BeforeFix.mov
35157-AfterFix.mov