Skip to content

[Android]Fix for Android BlazorWebView crash when opening image links in a new window - #38195

Merged
kubaflo merged 3 commits into
dotnet:inflight/currentfrom
BagavathiPerumal:fix-35157
Sep 11, 2026
Merged

kubaflo merged 3 commits into
dotnet:inflight/currentfrom
BagavathiPerumal:fix-35157

Conversation

@BagavathiPerumal

Copy link
Copy Markdown
Contributor

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

  • iOS
  • Mac
  • Android
  • Windows

Issues Fixed

Fixes #35157

Output ScreenShot

Platform Before After
Android
35157-BeforeFix.mov
35157-AfterFix.mov

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 38195

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 38195"

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Sep 4, 2026
@BagavathiPerumal BagavathiPerumal added the community ✨ Community Contribution label Sep 4, 2026
@github-actions github-actions Bot added area-blazor Blazor Hybrid / Desktop, BlazorWebView platform/android labels Sep 4, 2026
@vishnumenon2684

Copy link
Copy Markdown
Contributor

/azp run maui-pr-uitests , maui-pr-devicetests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Sep 4, 2026

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Expert Review — 1 findings

See inline comments for details.

MauiBot

This comment was marked as outdated.

@MauiBot MauiBot added s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-fix-win AI found a better alternative fix than the PR s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) and removed s/agent-review-in-progress AI review is currently running for this PR labels Sep 4, 2026
@BagavathiPerumal

Copy link
Copy Markdown
Contributor Author

AI Review Summary

@BagavathiPerumal — new AI review results are available based on commit 29363f3.

Gate Passed Confidence Medium Platform Android

🗂️ Review Sessions — click to expand

🚦 Gate — Test Before & After Fix

Gate Result: ✅ PASSED

Platform: ANDROID · Base: main · Merge base: 7d9efcdc

Test Without Fix (expect FAIL) With Fix (expect PASS)
🖥️ Issue35157 Issue35157 ✅ FAIL — 2864s ✅ PASS — 610s
🔴 Without fix — 🖥️ Issue35157: FAIL ✅ · 2864s
Error-relevant lines (filtered from the build log):

/home/vsts/work/1/s/.dotnet/packs/Microsoft.Android.Sdk.Linux/36.1.2/tools/Xamarin.Android.Common.Debugging.targets(333,5): error ADB0010:    at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName) [/home/vsts/work/1/s/src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj::TargetFramework=net10.0-android]
/home/vsts/work/1/s/.dotnet/packs/Microsoft.Android.Sdk.Linux/36.1.2/tools/Xamarin.Android.Common.Debugging.targets(333,5): error ADB0010:    at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass105_0.<InstallPackage>b__0(Task`1 t) [/home/vsts/work/1/s/src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj::TargetFramework=net10.0-android]
/home/vsts/work/1/s/.dotnet/packs/Microsoft.Android.Sdk.Linux/36.1.2/tools/Xamarin.Android.Common.Debugging.targets(333,5): error ADB0010:    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) [/home/vsts/work/1/s/src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj::TargetFramework=net10.0-android]
/home/vsts/work/1/s/.dotnet/packs/Microsoft.Android.Sdk.Linux/36.1.2/tools/Xamarin.Android.Common.Debugging.targets(333,5): error ADB0010: --- End of stack trace from previous location --- [/home/vsts/work/1/s/src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj::TargetFramework=net10.0-android]
/home/vsts/work/1/s/.dotnet/packs/Microsoft.Android.Sdk.Linux/36.1.2/tools/Xamarin.Android.Common.Debugging.targets(333,5): error ADB0010:    at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) [/home/vsts/work/1/s/src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj::TargetFramework=net10.0-android]
/home/vsts/work/1/s/.dotnet/packs/Microsoft.Android.Sdk.Linux/36.1.2/tools/Xamarin.Android.Common.Debugging.targets(333,5): error ADB0010:    at AndroidDeviceExtensions.PushAndInstallPackageAsync(AndroidDevice device, PushAndInstallCommand command, CancellationToken token) [/home/vsts/work/1/s/src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj::TargetFramework=net10.0-android]
/home/vsts/work/1/s/.dotnet/packs/Microsoft.Android.Sdk.Linux/36.1.2/tools/Xamarin.Android.Common.Debugging.targets(333,5): error ADB0010:    at Xamarin.Android.Tasks.FastDeploy.InstallPackage(Boolean installed) [/home/vsts/work/1/s/src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj::TargetFramework=net10.0-android]
/home/vsts/work/1/s/.dotnet/packs/Microsoft.Android.Sdk.Linux/36.1.2/tools/Xamarin.Android.Common.Debugging.targets(333,5): error ADB0010:    at Xamarin.Android.Tasks.FastDeploy.RunInstall() [/home/vsts/work/1/s/src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj::TargetFramework=net10.0-android]
Build FAILED.
     at UITest.Appium.HelperExtensions.Wait(Func`1 query, Func`2 satisfactory, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 2757
   at UITest.Appium.HelperExtensions.WaitForAtLeastOne(Func`1 query, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 2784
   at UITest.Appium.HelperExtensions.WaitForElement(IApp app, String marked, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency, Nullable`1 postTimeout) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 793
   at Microsoft.Maui.TestCases.Tests.Issues.Issue35157.TargetBlankLinkWithDataImageDoesNotCrash() in /_/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue35157.cs:line 23
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

🟢 With fix — 🖥️ Issue35157: PASS ✅ · 610s
(no coded error found; showing last 1200 chars)

(x64)
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.8.2+699d445a1a (64-bit .NET 10.0.0)
[xUnit.net 00:00:00.12]   Discovering: Controls.TestCases.Android.Tests
[xUnit.net 00:00:00.37]   Discovered:  Controls.TestCases.Android.Tests
NUnit Adapter 4.5.0.0: Test execution started
Running selected tests in /home/vsts/work/1/s/artifacts/bin/Controls.TestCases.Android.Tests/Debug/net10.0/Controls.TestCases.Android.Tests.dll
   NUnit3TestExecutor discovered 1 of 1 NUnit test cases using Current Discovery mode, Non-Explicit run
>>>>> 09/04/2026 15:45:23 FixtureSetup for Issue35157(Android)
>>>>> 09/04/2026 15:45:25 TargetBlankLinkWithDataImageDoesNotCrash Start
>>>>> 09/04/2026 15:45:34 TargetBlankLinkWithDataImageDoesNotCrash Stop
  Passed TargetBlankLinkWithDataImageDoesNotCrash [9 s]
NUnit Adapter 4.5.0.0: Test execution complete
Results File: /home/vsts/work/1/s/CustomAgentLogsTmp/UITests/TestResults/Issue35157.trx
Test Run Successful.
Total tests: 1
     Passed: 1
 Total time: 24.6046 Seconds
>>> TRX_RESULT_FILE: /home/vsts/work/1/s/CustomAgentLogsTmp/UITests/TestResults/Issue35157.trx

📁 Fix files reverted (1 files)

  • src/BlazorWebView/src/Maui/Android/BlazorWebChromeClient.cs

📋 Pre-Flight — Context & Validation

PR #38195 Pre-Flight

Scope

Problem

For a BlazorWebView link such as <a href="https://www.google.com" target="_blank"><img src="data:image/..."></a>, Android reports the image source in WebView.GetHitTestResult().Extra. The current implementation passes that data: URI to an ACTION_VIEW intent. Android has no matching activity and throws ActivityNotFoundException, crashing the app instead of opening the enclosing anchor URL.

Existing PR Approach

The PR changes src/BlazorWebView/src/Maui/Android/BlazorWebChromeClient.cs to:

  1. Detect HitTestResult.SrcImageAnchorType.
  2. Call RequestFocusNodeHref with a custom main-looper Handler to retrieve the enclosing anchor's URL asynchronously.
  3. Route both image-anchor and normal-link URLs through TryOpenInExternalBrowser.
  4. Reject data:, blob:, javascript:, and about: URLs and catch ActivityNotFoundException.

The alternative candidates must use a materially different root-cause mechanism, not merely relocate the same checks.

Diff Boundary

The PR changes six files:

  • Production: src/BlazorWebView/src/Maui/Android/BlazorWebChromeClient.cs (+59/-4)
  • Test host project: src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj
  • Test host page: src/Controls/tests/TestCases.HostApp/Issues/Issue35157.cs (new)
  • Test host startup: src/Controls/tests/TestCases.HostApp/MauiProgram.cs
  • Test host HTML: src/Controls/tests/TestCases.HostApp/wwwroot/index.html (new)
  • UI test: src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue35157.cs (new)

Only the production file is a gate-detected fix file and eligible for a try-fix implementation. The test additions remain in place to verify alternatives.

Bounded Validation

Run only:

pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -TestFilter "Issue35157"

This is the detected primary regression test and the only mandatory regression test supplied for STEP 5a. Do not run a full suite, category-wide suite, gate verification, or unrelated tests.

Attempt Limits

Each candidate receives one implementation/test pass and at most one focused correction/retest. It must perform the try-fix skill's inline expert self-review, capture all required artifacts, and restore using only:

pwsh .github/scripts/EstablishBrokenBaseline.ps1 -Restore

The repository contains unrelated pre-existing .github and eng worktree changes. They are out of scope and must remain untouched.

🔬 Code Review — Deep Analysis

Expert PR Evaluation — PR #38195

Verdict: NEEDS_DISCUSSION

Confidence: medium

Independent assessment

The Android production change addresses the crash at its source: SrcImageAnchorType no longer sends the nested image's data: URI directly to an ACTION_VIEW intent. Instead, it asks Android WebView for the focused anchor's href, routes both image-anchor and ordinary-link targets through one launch helper, rejects schemes that should not be dispatched externally, and converts a missing activity handler from an application crash into an unhandled-new-window result.

The implementation is localized to Android BlazorWebChromeClient behavior and introduces no static state or startup-path changes. The main-looper callback keeps Android WebView and activity operations on the UI thread. The trusted Gate establishes that the supplied regression scenario fails without the production fix and passes with it.

Actionable finding

⚠️ The UI test does not prove that external navigation occurred. In src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue35157.cs:23, the test taps the image, foregrounds the HostApp, and asserts a survival label that was already present before the tap. This detects the original process-crash failure, but a future implementation that simply suppresses image-anchor navigation would also pass. The test should establish an observable post-tap precondition showing that the external browser/navigation path was reached before it verifies that the HostApp survived.

The raw file:line finding is persisted in inline-findings.json.

Failure-mode probing

  • Ordinary text links: They continue through the same external-launch path, now with scheme filtering and ActivityNotFoundException handling.
  • Image anchors whose focused-node URL is absent or non-launchable: The callback does not dispatch an intent and the new-window request remains unhandled, avoiding the crash.
  • No activity can handle an otherwise launchable URL: ActivityNotFoundException is contained and reported as an unhandled launch rather than escaping through the WebChromeClient callback.
  • Lifecycle/static-state risk: No listener, subscription, or shared state is retained across handler reconnects; the callback and handler are per request.
  • Regression-test false green: If image-anchor intent dispatch stops entirely, the existing label remains visible and the current final assertion can still pass.

Recommendation

Keep the production fix, but harden the focused regression test in one consolidated candidate patch so it demonstrates that the external navigation was triggered rather than only that the HostApp remained alive.

🛠️ Try-Fix — Analysis & Comparison

STEP 5a Try-Fix Aggregate — PR #38195

Candidate 1 — Hit-Test Type Gating

  • Model: gpt-5.3-codex
  • Result: Blocked
  • Approach: Treat Android's hit-test classification as authoritative. Launch an external intent only for a real link-target hit and skip SrcImageAnchorType, preventing the nested image's data: payload from entering the intent path.
  • Difference from PR: The PR asynchronously recovers the enclosing anchor with RequestFocusNodeHref, filters schemes, and catches ActivityNotFoundException. Candidate 1 would avoid URL recovery and block image-anchor intent dispatch at the hit-test boundary.
  • Files changed: None.
  • Test: pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -TestFilter "Issue35157" was not executed.
  • Failure analysis: Mandatory baseline establishment failed because EstablishBrokenBaseline.ps1 rejected the pre-existing dirty .github and eng worktree. Skill constraints therefore prohibited implementation and testing. The required restore command ran and reported No baseline state found / Restored=False, which is expected because baseline state was never created and no candidate edits were made.
  • Inline self-review: 0 findings; there was no candidate diff.
  • Details: ../try-fix-1/content.md
  • Artifacts: attempt-1/

Candidate 2 — Actual New-Window Navigation Interception

  • Model: gpt-5.6-sol
  • Result: Blocked
  • Approach: Accept Android WebView's WebViewTransport from resultMsg, attach a short-lived WebView/WebViewClient, consume Chromium's first real new-window navigation request, and open that request URL externally. This would obtain the enclosing anchor's resolved href from the navigation pipeline rather than from touch metadata.
  • Prior approaches avoided: Unlike the PR, it would not use GetHitTestResult().Extra, SrcImageAnchorType, RequestFocusNodeHref, a URL-scheme blacklist, or a custom Handler. Unlike Candidate 1, it would not suppress image-anchor launches based on hit-test type.
  • Mechanism-level difference: The faulty value originates in hit testing, which identifies the touched image rather than its enclosing anchor. Candidate 2 would stop using hit testing for URL selection and let Chromium expose the actual _blank navigation target through the transported WebView.
  • Files changed: None.
  • Captured diff: Empty.
  • Test: pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -TestFilter "Issue35157" was not executed because it would only have exercised the unchanged PR implementation.
  • Failure analysis: Mandatory baseline establishment again failed with DIRTY WORKING DIRECTORY due to the same pre-existing .github and eng changes. No .github/.baseline-state.json or RevertedFiles allow-list was created, so implementation and testing were prohibited. The exact restore command ran and reported No 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/

Final Aggregate Status

The bounded maximum of two sequential candidates was reached:

Candidate Mechanism Result Empirical Test
1 (gpt-5.3-codex) Gate intent launch by hit-test type and skip image-anchor payloads Blocked Not run
2 (gpt-5.6-sol) Capture Chromium's actual target through WebViewTransport Blocked Not run
Both candidates are design-only and unvalidated. The mandatory try-fix baseline guard rejected unrelated pre-existing tracked changes before either candidate could modify the sole production target. No candidate code remains applied, both required restore commands completed with the expected verified no-state outcome, and no full or unrelated test suite was run.

📝 PR Finalize — Recommended Title & Description

Assessment: ✏️ Recommend updating — the description is detailed and accurate, but the title retains a [WIP] marker, omits the component separator, and does not follow the [Platform] Component: What changed format.

Recommended title

[Android] BlazorWebView: Fix crash when image links open a new window

Recommended description

### Root cause

When a `target="_blank"` anchor contains an image, Android WebView returns the nested image's `data:` URI through `HitTestResult.Extra`. `BlazorWebChromeClient.OnCreateWindow` then passes that non-launchable URI to an `ACTION_VIEW` intent. Because Android has no matching activity, `StartActivity` throws `ActivityNotFoundException` and crashes the app instead of opening the enclosing anchor URL.

### Description of Change

For `HitTestResult.SrcImageAnchorType`, `BlazorWebChromeClient` now uses `RequestFocusNodeHref` to retrieve the enclosing anchor's actual URL while preserving the existing path for ordinary text links. Both paths use a shared external-launch helper that:

- ignores empty URLs and the clearly non-launchable `data:`, `blob:`, `javascript:`, and `about:` schemes;
- opens launchable URLs with an Android `ACTION_VIEW` intent; and
- handles `ActivityNotFoundException` so a missing activity does not crash the app.

The PR also adds an Android HostApp page and UI regression test for the image-anchor scenario.

### Windows behavior

The scenario behaves differently on Windows because WebView2 receives new-window navigation through `NewWindowRequestedEventArgs.Uri` instead of Android's `HitTestResult.Extra`. Windows therefore 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 Android WebView's `HitTestResult` and `RequestFocusNodeHref` behavior. Windows uses WebView2, while iOS and Mac Catalyst use WKWebView, so those platforms follow different new-window navigation paths and do not exercise this Android-specific code.

### Platforms validated

- [x] iOS
- [x] Mac Catalyst
- [x] Android
- [x] Windows

### Issues Fixed

Fixes https://github.com/dotnet/maui/issues/35157

### Output recording

| 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-plus-reviewer

pr-plus-reviewer retains the submitted Android production fix and closes the expert reviewer's only actionable gap: the regression test now proves that tapping the image actually launches an external activity before checking that the HostApp survived. It passed the required focused Android validation in the prescribed candidate sandbox.

Comparative ranking

Rank Candidate Implementation status Regression evidence Assessment
1 pr-plus-reviewer Implemented in the required sandbox PASS — Issue35157, 1/1 test Best balance of correctness and evidence. Preserves the sound PR fix while preventing a no-op navigation implementation from producing a false-green test.
2 pr Submitted implementation PASS — trusted Gate fails without the fix and passes with it Production approach is localized and sound, but the final assertion observes a label that exists before the tap. It detects the original crash but does not independently establish that external navigation occurred.
3 try-fix-2 Design only; blocked before editing Not run Obtaining the URL from a transported WebView's real navigation avoids hit-test metadata, but no diff or empirical evidence exists. It also adds a temporary WebView, transport setup, interception, and lifecycle cleanup for a problem the submitted focused-node API solves more directly.
4 try-fix-1 Design only; blocked before editing Not run Skipping SrcImageAnchorType would avoid the crash by suppressing image-anchor launches rather than opening the enclosing link. The strengthened winning test is specifically designed to reject this false-success behavior.

Expert review reconciliation

The one expert-review pass found no blocking production-code defect. BlazorWebChromeClient.OnCreateWindow detects SrcImageAnchorType, resolves the enclosing anchor through RequestFocusNodeHref, dispatches launchable URLs through one helper, filters clearly non-launchable schemes, and contains ActivityNotFoundException. The change is Android-local, has no startup or shared-state impact, and disposes its per-request Handler.

The review did identify one moderate regression-coverage weakness on the submitted test line. The single consolidated reviewer patch resolves it without altering production behavior or broadening scope.

Validation and uncertainty

  • Trusted Gate for pr: PASS — test fails without the production fix and passes with it.
  • Required validation for pr-plus-reviewer: PASS — exact Android Issue35157 command, 1/1 test.
  • try-fix-1 and try-fix-2: BLOCKED by their baseline guard; neither produced code or ran the regression test.
  • No candidate failed an executed regression test. The two blocked design-only alternatives rank below both empirically passing implementations.

Because the winning test hardening is not present in the submitted PR HEAD, the submitted PR should receive the pr-plus-reviewer change before approval.

📱 UI Tests — WebView

Detected UI test categories: WebView

✅ Deep UI tests — 57 passed, 0 failed across 1 category on platform-pool agent (replaces in-process counts above).

🧪 UI Test Execution Results (deep, platform pool)

Category Tests Snapshot diffs
WebView 57/57 ✓ —
📎 Download drop-deep-uitests artifact (TRX + snapshot diffs)
🧭 Next Steps — reviewer changes required

I have addressed mentioned concerns following:

  • Test assertion gap — Added App.WaitForNoElement("Issue35157SurvivalLabel", ...) right after the tap, proving the browser actually opened before re-checking survival. A silent "tap does nothing" regression will now fail the test instead of passing unnoticed.
  • CI build failure (CA1416) — AddMauiBlazorWebView() in MauiProgram.cs wasn't fully scoped to #if ANDROID , breaking iOS/MacCatalyst builds. Fixed by wrapping the full block in the directive.

@vishnumenon2684

Copy link
Copy Markdown
Contributor

/azp run maui-pr-uitests , maui-pr-devicetests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI 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.

🟡 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

Comment on lines +24 to +28
var hitTestResult = view.GetHitTestResult();
if (hitTestResult?.Type == global::Android.Webkit.HitTestResult.SrcImageAnchorType)
{
var handler = new FocusNodeHrefHandler(view.Context);
view.RequestFocusNodeHref(handler.ObtainMessage());
@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Sep 11, 2026
@kubaflo
kubaflo changed the base branch from main to inflight/current September 11, 2026 14:15
@kubaflo
kubaflo merged commit 56a79ba into dotnet:inflight/current Sep 11, 2026
6 of 32 checks passed
@github-actions github-actions Bot added this to the .NET 10 SR11 milestone Sep 11, 2026

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AI Review Summary

@BagavathiPerumal — new AI review results are available based on commit 333f637.

Gate No Tests Confidence Low Platform Android


🗂️ 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.md was 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):

  1. Detect HitTestResult.SrcImageAnchorType.
  2. Use RequestFocusNodeHref with a main-looper Handler to retrieve the enclosing anchor's URL asynchronously.
  3. Route ordinary and recovered URLs through TryOpenInExternalBrowser.
  4. Reject data:, blob:, javascript:, and about: URLs and contain ActivityNotFoundException.

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 href is 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 SrcImageAnchorType launches and using a temporary WebViewTransport; 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 ⚠️ Unresolved 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 _blank launch; 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 --required was unavailable because GitHub CLI authentication is absent.
  • Anonymous evidence: The live PR head has a mixture of pending and cancelled maui-pr checks, 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: ActivityNotFoundException is 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.EvaluateJavascript to walk from document.activeElement to its nearest enclosing anchor and return that anchor's resolved href.
  • Prior approaches avoided: This does not use the PR's RequestFocusNodeHref/custom Handler mechanism, hit-test-type suppression, or a temporary WebViewTransport.
  • 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.ps1 rejected the unrelated pre-existing dirty .github and eng files. No baseline state or RevertedFiles allow-list was created, so the skill prohibited implementation. The exact restore command ran and reported No 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's PackageManager whether the ACTION_VIEW intent resolves to an installed activity, and decline an unresolvable launch rather than allowing ActivityNotFoundException to 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 .github and eng files. No baseline state or RevertedFiles allow-list was created, so implementation was prohibited. The exact restore command ran and reported No 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, then gpt-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.json is 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 cancelled maui-pr checks, not a completed pass.
  • pr-plus-reviewer: sandbox identity and immutable baseline verified; git diff --check passed; 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.

@MauiBot MauiBot added s/agent-changes-requested AI agent recommends changes - found a better alternative or issues and removed s/agent-approved AI agent recommends approval - PR fix is correct and optimal s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-review-in-progress AI review is currently running for this PR labels Sep 11, 2026
kubaflo pushed a commit that referenced this pull request Sep 11, 2026
… 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">|
@MauiBot MauiBot mentioned this pull request Sep 11, 2026
kubaflo pushed a commit that referenced this pull request Sep 15, 2026
… 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">|
kubaflo pushed a commit that referenced this pull request Sep 18, 2026
… 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">|
kubaflo pushed a commit that referenced this pull request Sep 21, 2026
… 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">|
kubaflo pushed a commit that referenced this pull request Sep 27, 2026
… 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">|
kubaflo pushed a commit that referenced this pull request Sep 27, 2026
… 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">|
kubaflo pushed a commit that referenced this pull request Oct 3, 2026
… 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">|
kubaflo pushed a commit that referenced this pull request Oct 3, 2026
… 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">|
kubaflo pushed a commit that referenced this pull request Oct 6, 2026
… 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">|
kubaflo pushed a commit that referenced this pull request Oct 6, 2026
… 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">|
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 12, 2026
@github-actions github-actions Bot modified the milestones: .NET 10 SR11, .NET 10 SR12 Oct 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-blazor Blazor Hybrid / Desktop, BlazorWebView community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

<a target="_blank"> with image child <img src="data:image"/> causes app crash on Android in MAUI Blazor Hybrid

5 participants