Repository navigation
feat(webview2): Serve virtual hosts on macOS and iOS - #25598
Draft
morning4coffe-dev wants to merge 1 commit into
Draft
morning4coffe-dev wants to merge 1 commit into
morning4coffe-dev wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #25395. Stacked on #25594 (and through it #25593 and #25592): the base branch is
dev/doti/webview2-bridge-core, so only this PR's own commit is in the diff. This PR will be retargeted tomasteronce those merge. Work in progress, opened as a draft to show the approach.WKWebView cannot intercept
httpsrequests, so the virtual host (https://0.0.0.1/, what MAUI'sBlazorWebViewuses) is served through a custom scheme (uno-app) with aWKURLSchemeHandler, and URLs are translated back tohttpsat the Uno boundary using the shared layer from #25594. Replaces the loopbackHttpListenerworkaround.What it does
WKWebViewConfigurationat creation (macOS: inUNOWebView.m, with callbacks into managed code; iOS: C#).startURLSchemeTaskraisesWebResourceRequestedand completes only when the deferral completes, then answers fromWebResourceResponseSnapshot(status, reason, headers, body); a stopped task is guarded.ISupportsCustomSchemeVirtualHostson both views, soSource,Navigate,NavigationStarting,NavigationCompleted,NewWindowRequested, the request URI,WebMessageReceived.Sourceand theWebResourceRequestedfilters show thehttpsform.WKUserScript),PostWebMessageAsString/Json,DOMContentLoadedand thechrome.webviewpage object through the shared bridge, so scripts and messages work on macOS and iOS.httpsnavigations keep the existing header-onlyWebResourceRequestedbehavior.Verification
Given_WebView2_VirtualHosttests cover a page and its subresources served with an async deferral, response status and headers, a stopped task while a deferral is pending,chrome.webview.postMessagewith aSourceunder the virtual host, andPostWebMessage*reaching a page listener; the existing document-script andDOMContentLoadedordering tests pass too.CustomSchemeResourceHandlerwere added; the macOS ICU libraries must be on the library path to start the unit-test host (DYLD_LIBRARY_PATH=~/.nuget/packages/uno.icu-macos/<version>/runtimes/osx/native), independent of this change.Uno.UI.Runtime.AppleUIKitbuilds fornet10.0-ios26.0. Not run on a simulator or device.Not done / open
uno-app://0.0.0.1/is a secure context in WKWebView (isSecureContext,crypto.subtle, storage) has not been checked; Blazor may need it.ResourceContextis heuristic (documented in the code).BlazorWebView: not yet run.0.0.0.0/8rule are the open questions on fix: Apply Opacity to SKCanvasElement content #25394/WebView2 on Skia: WebResourceRequested responses and the APIs BlazorWebView depends on are not implemented #25395.