Skip to content

WebView2 on Skia: WebResourceRequested responses and the APIs BlazorWebView depends on are not implemented #25395

Open

Description

@morning4coffe-dev

Current behavior 🐛

On Skia, several CoreWebView2 members that WebView2-based libraries depend on are [NotImplemented("__SKIA__")] stubs (checked on current master, src/Uno.UI/Generated/3.0.0.0/Microsoft.Web.WebView2.Core/):

  • CoreWebView2Environment.CreateWithOptionsAsync(...) throws NotImplementedException.
  • CoreWebView2Environment.CreateWebResourceResponse(...) throws.
  • CoreWebView2.AddScriptToExecuteOnDocumentCreatedAsync(...) throws.
  • CoreWebView2.PostWebMessageAsString(...) is a no-op (raises "not implemented" through TryRaiseNotImplemented).
  • CoreWebView2.DOMContentLoaded is never raised.
  • On macOS, WebResourceRequested can change navigation headers, but a handler cannot supply a response body, so requests cannot be served from managed code (observed with a decompile of Uno.UI 7.0.0-dev.763; not re-checked against master).

MAUI's stock BlazorWebView handler (Microsoft.AspNetCore.Components.WebView.Maui 10.0.101, WinUI handler) uses these members, so it cannot run on Skia: the handler faults silently (its _webviewReadyTask faults with NotImplementedException and nothing awaits it) and the Razor component never starts.

Expected behavior 🎯

Either the members work on Skia, or they fail with a documented, explicit exception, so WebView2-based libraries (MAUI BlazorWebView and others using WebResourceRequested, document-created scripts or web messages) can run or fail clearly.

How to reproduce it (as minimally and precisely as possible) 🔬

  1. New MAUI app with a BlazorWebView (a RootComponents entry and a simple .razor component), run through a Uno Skia desktop head (for example with https://github.com/unoplatform/uno.maui.renderer).
  2. Run on macOS.
  3. The component never renders; no exception is logged.

Workaround 🛠️

A subclass handler that serves the app's static files over a loopback HttpListener and uses only the members Uno implements. It exposes local files to other local processes, so it is a diagnostic, not a recommendation.

Renderer 🎨

Skia

Affected platforms 📱💻🖥️

Skia Desktop (macOS verified; the stubs are __SKIA__-wide)

Suggested direction

  • macOS: a custom-scheme handler (for example WKURLSchemeHandler) so WebResourceRequested can supply a response.
  • Implement CreateWebResourceResponse, AddScriptToExecuteOnDocumentCreatedAsync, PostWebMessageAsString and DOMContentLoaded on Skia, or throw explicit documented exceptions where they stay unsupported.
  • Make CreateWithOptionsAsync return a usable environment, or document the Skia path.

Design and plan

Replaces the loopback HttpListener workaround above. Split into small PRs (the earlier all-in-one #23754 is reference only). All are drafts.

Spec

A stock MAUI BlazorWebView needs, from Microsoft.UI.Xaml.Controls.WebView2 / CoreWebView2:

  1. CoreWebView2Environment.CreateWithOptionsAsync / CreateAsync, CreateWebResourceResponse, CoreWebView2EnvironmentOptions, EnsureCoreWebView2Async(environment[, options]). MAUI only uses the environment to build responses, then calls the parameterless EnsureCoreWebView2Async().
  2. AddWebResourceRequestedFilter("*", All) + WebResourceRequested with Response set for https://0.0.0.1/, possibly after awaits (a real deferral).
  3. AddScriptToExecuteOnDocumentCreatedAsync (defines window.external over chrome.webview), DOMContentLoaded, WebMessageReceived with Source under the virtual host, PostWebMessageAsString/Json.

Win32 forwards to the real WebView2. Other targets need a host-side implementation.

Per platform

Target Approach
Win32 forward to real WebView2 (managed response accepted)
macOS, iOS WKWebView cannot intercept https: WKURLSchemeHandler for a custom scheme (uno-app), URLs translated back to https:// at the Uno boundary
Android ShouldInterceptRequest already sees https://; accept any response, real deferral, scripts injected into intercepted HTML (no AndroidX.WebKit yet)
Linux X11 WebKitGTK custom URI scheme, same translation as Apple. Not started
WASM iframe cannot intercept; would need a service worker. Deferred: throw a clear NotSupportedException

0.0.0.0/8 is treated as a virtual host by default (shared layer in #25594).

PRs

PR Base Content State
#25593 master detached CoreWebView2Environment, options, CreateWebResourceResponse 19 unit tests; macOS runtime tests pass
#25592 master document scripts, PostWebMessage*, DOMContentLoaded, Source 11 unit tests; desktop/Android/iOS build; Win32 runtime tests compiled, not run
#25594 dev/doti/webview2-stack (merge of the two above) shared bridge, virtual host map, response snapshot 121 unit tests
#25598 #25594 macOS + iOS scheme handler macOS runtime tests on real WKWebView pass (21 passed, 5 Win32-only skipped); iOS builds only
#25599 #25594 Android responses, deferral, script injection builds, 159 unit tests; no runtime run (emulator would not start)

Not verified yet

  • Win32, X11, WASM, iOS simulator, Android runtime.
  • uno-app:// as a secure context in WKWebView.
  • End to end with a stock MAUI BlazorWebView (e.g. MarvelousMAUI photo grid) without the loopback handler.
  • Remaining work: Linux X11 scheme, the e2e check, retargeting the stacked PRs to master as the base PRs merge.

Open maintainer questions are in the comment above (virtual 0.0.0.0/8 default, scheme name, AndroidX.WebKit dependency, WebKitGTK version floor, NotSupportedException vs silent no-op).

Activity

  1. added
    kind/bug
    on Oct 13, 2026
  2. morning4coffe-dev commented on Oct 20, 2026

    @morning4coffe-dev
    MemberAuthor

    Splitting the older draft #23754 into smaller PRs so these gaps can be reviewed and landed one at a time. Draft PRs open:

    1. feat(webview2): Create detached CoreWebView2Environment #25593 CoreWebView2Environment.CreateAsync/CreateWithOptionsAsync (detached environment), CreateWebResourceResponse (managed response), CoreWebView2EnvironmentOptions as data, EnsureCoreWebView2Async(environment); Win32 accepts a managed response.
    2. feat(webview2): Add document scripts and messaging #25592 AddScriptToExecuteOnDocumentCreatedAsync, PostWebMessageAsString/Json, DOMContentLoaded, WebMessageReceivedEventArgs.Source: the API surface through new internal capability interfaces, forwarded to the real WebView2 on Win32.

    Next, as separate PRs (not started yet): a shared chrome.webview bridge and virtual-host layer for hosts without a native one, then one PR per platform: Android (ShouldInterceptRequest responses with deferrals), macOS and iOS (a WKURLSchemeHandler with URL rewriting from the virtual host), Linux X11 (WebKitGTK custom scheme).

    Design questions for the maintainers, for the WebKit hosts (macOS, iOS, Linux), where https cannot be intercepted:

    • Is it acceptable to treat the non-routable 0.0.0.0/8 range (what Blazor's WebView uses) as a virtual host by default, and rewrite those URLs to a custom scheme internally (so Source/Uri still report the https URL)? Which scheme name would you prefer?
    • Is an AndroidX.WebKit dependency acceptable for addDocumentStartJavaScript/addWebMessageListener? (Otherwise the script would be injected into intercepted HTML.)
    • Should unsupported members throw a documented NotSupportedException instead of silently doing nothing, as MAUI only catches FileNotFoundException and the failure is otherwise silent?
    • What is the WebKitGTK version floor? webkit_uri_scheme_request_finish_with_response needs 2.36.

    The browser (iframe) host cannot intercept requests; that would need a service worker and is out of scope for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

kind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions