Skip to content

feat(webview): Implement CoreWebView2Environment and CoreWebView2Profile on Skia Win32 - #24062

Merged
Xiaoy312 merged 10 commits into
masterfrom
dev/xygu/20260812/win32-webview2-env-n-profile
Aug 14, 2026
Merged

Xiaoy312 merged 10 commits into
masterfrom
dev/xygu/20260812/win32-webview2-env-n-profile

Conversation

@Xiaoy312

Copy link
Copy Markdown
Contributor

GitHub Issue: tracked internally

PR Type:

✨ Feature

What changed? 🚀

CoreWebView2Environment and CoreWebView2Profile were whole-type [Uno.NotImplemented] stubs. They are now
implemented on the Skia Windows head:

Vertical Members
Environment statics GetAvailableBrowserVersionString(), GetAvailableBrowserVersionString(string), CompareBrowserVersionString(string, string)
Profile CoreWebView2.Profile; ClearBrowsingDataAsync() / (kinds) / (kinds, start, end), ProfileName, ProfilePath, IsInPrivateModeEnabled, DefaultDownloadFolderPath, PreferredColorScheme
Environment + diagnostics CoreWebView2.Environment; BrowserVersionString, UserDataFolder, FailureReportFolderPath, GetProcessInfos(); CoreWebView2.BrowserProcessId

Every other target keeps throwing exactly the NotImplementedException it threw before, with the same
type/member strings, so the aka.platform.uno/notimplemented#m= telemetry keys are unchanged.

Design

Two seams, because the members have two different lifetimes:

  • Statics must answer "is a browser installed?" before any WebView2 exists, so they cannot ride
    INativeWebView. They resolve through an owner-less ApiExtensibility extension
    (ICoreWebView2EnvironmentStaticsExtension). The existing WebView registration uses the typed-owner
    overload, which throws on a mismatched owner, so reusing it was not an option.
  • Instance members are bound to a live native view and resolve through three opt-in capability interfaces
    on INativeWebView, next to the existing ISupportsVirtualHostMapping / ISupportsWebResourceRequested.

The capabilities are split three ways rather than bundled because the split is the portability
documentation: data clearing has a real analogue on every head (WKWebsiteDataStore.removeData,
WebKitWebsiteDataManager, Android WebStorage), profile metadata maps partially, and multi-process
diagnostics is Chromium-only. A macOS implementer appends one interface to MacOSNativeWebView and writes one
method — nothing in Uno.UI changes.

The façades hold the owning CoreWebView2, never the native view, and re-resolve on every access:
_nativeWebView is assigned in OnOwnerApplyTemplate and reassigned on every re-template. The async path
re-resolves after its await too, because _nativeWebViewInitializedTcs is never reset, so
EnsureNativeWebViewAsync() stays completed even after re-templating into a template with no native view.

ClearBrowsingDataAsync throws when the native view is absent rather than following the graceful in-memory
fallback used three lines away by SetVirtualHostNameToFolderMapping. A host mapping that quietly buffers is
harmless; a data-clearing call that quietly resolves without clearing is a privacy defect.

Reviewer notes — things not visible in the diff

  • The sync generator could not be run locally. dotnet restore on
    build/filters/Uno.UI-top-projects-for-sync-gen.slnf fails with NETSDK1147, because the wasm-tools
    workload is not installed on the dev machine. The Generated/ edits were instead
    verified against the generator's own rules — type guard flipped to #if false || false || false || false || false || false, each removed member replaced in place by // Skipping already declared property {Name}
    or // Skipping already declared method {fully-qualified signature}, all // Forced skipping of method
    lines untouched — and cross-checked against CoreWebView2Settings.cs, which the generator authored in the
    same shape. The new comments sit alongside pre-existing generator-authored ones in the same files with
    identical formatting. winappsdk-sync-check is the real gate here.

  • Same cause: Uno.UI.netcoremobile was not compile-verified locally. Everything else was, on both
    TFM bands with analyzers enabled: Uno.UI.Skia, Uno.UI.Reference, Uno.UI.Wasm,
    Uno.UI.Runtime.Skia.Win32, Uno.UI.RuntimeTests and SamplesApp all build clean at net9.0 and net10.0.
    The new Uno.UI files are unguarded (matching CoreWebView2Settings.cs) and reference only generated enums
    that exist on all six platform slots, so the mobile variant should be safe too — but CI is the check.

    Note the net9.0 split: WebView2Aot is only referenced from net10.0, so the Win32 statics registration is
    behind #if NET10_0_OR_GREATER and the whole feature stays NotImplemented on net9.0. That guard becomes
    vacuously true once net9 is dropped (feature/breakingchanges already has NetPrevious=net10.0), and can
    be removed then.

  • ProfileName is always empty on Windows. Not a marshalling bug: ProfilePath correctly returns
    …\LocalState\WebView2\EBWebView\Default and DefaultDownloadFolderPath returns the user's Downloads
    folder. It is empty because the controller is created without ICoreWebView2ControllerOptions, so no profile
    name is ever requested. The test asserts the true contract and the doc explains it; making it non-empty means
    passing controller options, which changes on-disk profile layout and deserves its own decision.

  • CompareBrowserVersionString(null, …) throws ArgumentNullException where the WebView2 stack throws
    ArgumentException. ArgumentNullException derives from ArgumentException, so a catch (ArgumentException)
    written against Windows still works — the parity direction that matters holds. The explicit guard also avoids
    handing a null pointer to a native export whose null behaviour is unverified.

  • The type-level [Uno.NotImplemented] attribute is gone from CoreWebView2Environment,
    CoreWebView2Profile and CoreWebView2ProcessInfo, which changes IDE/analyzer surfacing for them. Members
    that remain unimplemented keep their per-member attributes. This is the correct outcome of the types no
    longer being wholly unimplemented, but it is a visible change.

  • When_ClearBrowsingDataAsync_Completes(1) destroys real state in the app's own WebView2 user-data
    folder. It is scoped to LocalState so it is acceptable, but unlike the PreferredColorScheme test there is
    no finally that can restore it.

  • Exception-type parity is derived, not observed end-to-end. Verified: Marshal.GetExceptionForHR(0x80070002)
    is FileNotFoundException; DirectN's ThrowOnError does not use the CLR mapping (it builds a
    Win32Exception); WebView2RuntimeNotFoundException exists only in the WebView2 .NET wrapper and has no
    WinAppSDK/WinRT counterpart, so it is not the parity target. What was not done is running a WinAppSDK app
    to observe it directly. Relatedly, the 0x80070002 observation comes from pointing at a folder with no
    browser; a machine with no runtime installed at all was not available to test.

  • Behaviour change worth noting: the loader probe moved out of Win32NativeAotWebView's static
    constructor into Win32WebView2Loader.Ensure(). The instance path is unchanged, but the new static path
    surfaces a direct DllNotFoundException rather than one wrapped in a TypeInitializationException.

Scope deliberately left out

  • GetAvailableBrowserVersionString(string, CoreWebView2EnvironmentOptions) — CoreWebView2EnvironmentOptions
    is an unbacked stub whose getters throw, so the options cannot be honoured and ignoring them would return a
    wrong answer. Unblocks once that type gets real backing fields, which is also the right time to retire the
    FeatureConfiguration.WebView2.* injection point.
  • CoreWebView2CookieManager / CoreWebView2Cookie. Verified independent of this work:
    ICoreWebView2Profile2.ClearBrowsingData takes only (kinds, handler) and does the work inside the browser
    process, so ClearBrowsingDataAsync(Cookies) never touches the cookie manager. What is therefore still not
    possible: reading cookies, and targeted delete by name/domain/path. Adding it later is one more capability
    interface — no reshaping.
  • CreateAsync / CreateWithOptionsAsync, Profile.CookieManager / .Delete() /
    .IsGeneralAutofillEnabled / .IsPasswordAutosaveEnabled / .PreferredTrackingPreventionLevel, and the
    BrowserProcessExited / ProcessInfosChanged / NewBrowserVersionAvailable / Deleted events.

Pre-existing issues found while working here (not fixed in this PR)

  • get_Source, get_DocumentTitle, get_Uri, get_WebMessageAsJson and the .Request.cs accessors in
    Win32NativeAotWebView all leak caller-owned PWSTRs via a bare .ToString().
  • ExecuteScriptAsync lacks RunContinuationsAsynchronously, the same hazard this PR guards against in
    ClearBrowsingDataAsync.
  • Given_WebView2's SkiaWin32 exclusion predates the WebView2Aot backend. This PR demonstrates a live
    WebView2 runs fine under the runtime-test harness on Skia Win32, so that exclusion now looks stale.

PR Checklist ✅

  • 🧪 Added Runtime tests and a manual test sample
  • 📚 Docs have been added/updated
  • 🖼️ Validated PR Screenshots Compare Test Run results.
  • ❗ Contains NO breaking changes
  • 👀 Reviewed 2 other open pull requests

Xiaoy312 and others added 6 commits August 12, 2026 16:20
…PI surface

Replaces the generated NotImplemented stubs for CoreWebView2Environment,
CoreWebView2Profile and CoreWebView2ProcessInfo with hand-written partials, and
adds CoreWebView2.Environment, .Profile and .BrowserProcessId.

The members split across two seams because they have different lifetimes. The
statics answer "which browser is installed" and must work before any WebView
exists, so they resolve through an owner-less ApiExtensibility extension. The
instance members describe a live WebView, so they resolve through opt-in
capability interfaces on INativeWebView, alongside the existing
ISupportsVirtualHostMapping / ISupportsWebResourceRequested.

The capabilities are split three ways rather than bundled, because that split is
the portability documentation: data clearing has a real analogue on every head
(WKWebsiteDataStore, WebKitWebsiteDataManager, Android WebStorage), profile
metadata maps partially, and multi-process diagnostics is Chromium-only. A
second head implements one interface without touching Uno.UI.

The facades hold the owning CoreWebView2 rather than the native view, and
re-resolve on every access: _nativeWebView is assigned in OnOwnerApplyTemplate
and reassigned on every re-template, so a captured reference would go stale.
For the same reason the async path re-resolves after its await, since
EnsureNativeWebViewAsync stays completed across re-templating.

Behavior on every platform is unchanged: with nothing registered, each member
throws the same NotImplementedException as the deleted stubs, with the same
type/member strings so the telemetry key is preserved. ClearBrowsingDataAsync
deliberately throws rather than following the graceful in-memory fallback used
by SetVirtualHostNameToFolderMapping - a host mapping that quietly buffers is
harmless, a data-clearing call that quietly does nothing is a privacy defect.

GetAvailableBrowserVersionString(string, CoreWebView2EnvironmentOptions) stays
NotImplemented: CoreWebView2EnvironmentOptions is itself an unbacked stub whose
getters throw, so the options could not be honored, and ignoring them would
return a confidently wrong answer.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
… Win32

Backs the new API surface on the WebView2Aot backend: the statics through the
WebView2Loader.dll exports, and the instance members through ICoreWebView2Profile2
and ICoreWebView2Environment11.

The loader probe moves out of Win32NativeAotWebView's static constructor into
Win32WebView2Loader.Ensure(), because the statics must be able to load it with no
WebView ever created. It uses an explicit lock rather than a static constructor
or Lazy: a type initializer caches its failure, so the first DllNotFoundException
would be wrapped in a TypeInitializationException and replayed for the rest of
the process instead of reporting the real error on each attempt.

Win32CoreWebView2EnvironmentStaticsExtension deliberately holds no reference to
Win32NativeAotWebView, so a missing runtime stays a per-call failure rather than
becoming a startup crash for every Win32 app.

Failed HRESULTs from the two statics go through Marshal.ThrowExceptionForHR
rather than DirectN's ThrowOnError. The exception type is part of the contract
here, since these members are how an app detects a missing runtime: the CLR
mapping turns ERROR_FILE_NOT_FOUND into FileNotFoundException, which is what the
WinRT surface Uno mirrors produces. ThrowOnError raises a Win32Exception, which
would silently break a `catch (FileNotFoundException)` written against Windows.
(The WebView2 .NET wrapper used by WinForms/WPF instead raises its own
WebView2RuntimeNotFoundException, but that type is not part of the WinAppSDK
surface and has no Uno counterpart.)

The interfaces are hard-cast: the core WebView is already obtained as
ICoreWebView2_22, which is newer than every interface used here, so any runtime
able to create the WebView at all satisfies them and a version-fallback ladder
would be dead code.

ClearBrowsingDataAsync completes on a TaskCompletionSource created with
RunContinuationsAsynchronously, because the native handler runs while the
WebView2 message loop is being pumped and continuations after clearing routinely
call straight back into the WebView.

The registration is guarded to net10.0 and later: WebView2Aot is only referenced
from net10.0, and on net9.0 the WebView runs on the Microsoft.Web.WebView2
backend, where these members stay NotImplemented.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…rofile

Given_WebView2 cannot host these: its class-level PlatformCondition excludes
SkiaWin32 and is evaluated in a separate IsIgnored call that is OR'd with the
method-level ones, so no method attribute can opt back in.

Given_CoreWebView2Environment needs no WebView in the tree, which is the point:
these members must answer before one exists. Given_CoreWebView2Profile loads a
real WebView2 and resets WindowContent in a finally.

Several assertions are deliberately weaker than they look:

- ClearBrowsingDataAsync has no cheap positive observable, so the honest ceiling
  is "completes without throwing, within a bounded time". The bound turns a
  native hang into one failed test rather than a stalled run. Note that the
  AllProfile case destroys state in the app's own WebView2 user-data folder and,
  unlike PreferredColorScheme, cannot be restored in a finally.
- GetProcessInfos asserts neither a count nor a set of kinds: renderer, GPU and
  utility processes appear asynchronously, and only the browser process is
  guaranteed once the controller exists.
- ProfileName is asserted non-null rather than non-empty. It is genuinely empty
  on Windows because the controller is created without ICoreWebView2ControllerOptions,
  so no profile name is requested even though ProfilePath resolves to "Default".
- PreferredColorScheme is persisted on-disk profile state shared across the run
  and across restarts, so the original is restored in a finally.

The missing-folder test pins FileNotFoundException, since that type is how an app
detects a missing runtime and is what the WinRT surface Uno mirrors produces.

Restricted to SkiaWin32 rather than also NativeWinUI: the Inconclusive guard
treats a null or empty version as "runtime not installed", so adding the WinAppSDK
head before its null-vs-throw behavior is confirmed would make the parity test
pass vacuously on exactly the head it was added for.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Covers the statics, the environment and profile of a live WebView2, and the
three ClearBrowsingDataAsync overloads, in two sections so the static half is
usable with no WebView2 present.

Deliberately not gated to non-Windows, unlike WebView2_EnvironmentOptions: these
APIs do exist natively on WinAppSDK, and running the same page on both heads is
the whole parity value. It therefore has to survive targets where every call
throws, so nothing is called from the constructor - every call sits behind a
Click handler that reports the exception type and message.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Lists the newly supported surface and what other targets do, including two
behaviors that are surprising without explanation: ProfileName is always empty
on Windows, and the support is specific to the default WebView2 backend on
net10.0 and later.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The note added in 36869f446e conflated two independent things. The statics are
registered in Win32Host under a plain TFM guard, while the backend is chosen
per-control in Win32NativeWebViewProvider.CreateNativeWebView - nothing connects
them. So on net10.0 the statics work whatever UNO_WEBVIEW2_BACKEND says, and only
Environment, Profile and BrowserProcessId depend on the backend, because only
Win32NativeAotWebView carries the capability interfaces.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI lite review requested due to automatic review settings August 13, 2026 14:03
@github-actions github-actions Bot added area/automation Categorizes an issue or PR as relevant to project automation kind/documentation labels Aug 13, 2026

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.

Pull request overview

This PR implements a subset of CoreWebView2Environment and CoreWebView2Profile for the Skia Win32 head by introducing capability-based seams: environment statics resolve via ApiExtensibility, while instance members resolve via opt-in interfaces on the native WebView implementation.

Changes:

  • Added capability interfaces and new façade implementations for CoreWebView2Environment, CoreWebView2Profile, and CoreWebView2ProcessInfo.
  • Implemented Win32 (NET10+) loader + environment statics extension and wired registration in Win32Host.
  • Added SkiaWin32 runtime tests and a manual SamplesApp page, plus documentation updates.

PR metadata note: The PR description says “GitHub Issue: tracked internally”. If this is intended to merge, it should reference a real GitHub issue link (or include the “No related issue…” note per repo conventions).

Reviewed changes

Copilot reviewed 19 out of 23 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/Uno.UI/UI/Xaml/Controls/WebView/Native/ISupportsWebViewProfile.cs New native capability surface for profile metadata + settings.
src/Uno.UI/UI/Xaml/Controls/WebView/Native/ISupportsWebViewEnvironmentInfo.cs New native capability surface for environment/process diagnostics.
src/Uno.UI/UI/Xaml/Controls/WebView/Native/ISupportsBrowsingDataClearing.cs New native capability surface for profile data clearing.
src/Uno.UI/UI/Xaml/Controls/WebView/Core/ICoreWebView2EnvironmentStaticsExtension.cs New ApiExtensibility contract for environment statics.
src/Uno.UI/UI/Xaml/Controls/WebView/Core/CoreWebView2Profile.cs New CoreWebView2Profile façade delegating to capabilities.
src/Uno.UI/UI/Xaml/Controls/WebView/Core/CoreWebView2ProcessInfo.cs New CoreWebView2ProcessInfo snapshot type.
src/Uno.UI/UI/Xaml/Controls/WebView/Core/CoreWebView2Environment.cs New CoreWebView2Environment façade + statics via extension.
src/Uno.UI/UI/Xaml/Controls/WebView/Core/CoreWebView2.Properties.cs Exposes Environment, Profile, and BrowserProcessId on CoreWebView2.
src/Uno.UI/UI/Xaml/Controls/WebView/Core/CoreWebView2.cs Adds capability resolution helpers and clearer failure semantics.
src/Uno.UI/Generated/3.0.0.0/Microsoft.Web.WebView2.Core/CoreWebView2Profile.cs Generator-sync updates to avoid duplicate declarations.
src/Uno.UI/Generated/3.0.0.0/Microsoft.Web.WebView2.Core/CoreWebView2ProcessInfo.cs Generator-sync updates to avoid duplicate declarations.
src/Uno.UI/Generated/3.0.0.0/Microsoft.Web.WebView2.Core/CoreWebView2Environment.cs Generator-sync updates to avoid duplicate declarations.
src/Uno.UI/Generated/3.0.0.0/Microsoft.Web.WebView2.Core/CoreWebView2.cs Generator-sync updates to avoid duplicate declarations.
src/Uno.UI.RuntimeTests/Tests/Microsoft_Web_WebView2_Core/Given_CoreWebView2Profile.cs SkiaWin32 runtime tests for profile/environment/process + data clearing.
src/Uno.UI.RuntimeTests/Tests/Microsoft_Web_WebView2_Core/Given_CoreWebView2Environment.cs SkiaWin32 runtime tests for environment statics.
src/Uno.UI.Runtime.Skia.Win32/UI/Xaml/Controls/WebView/Win32WebView2Loader.cs Centralizes WebView2Loader probing/loading on NET10+.
src/Uno.UI.Runtime.Skia.Win32/UI/Xaml/Controls/WebView/Win32NativeAotWebView.Profile.cs Implements capability interfaces using WebView2 AOT COM APIs.
src/Uno.UI.Runtime.Skia.Win32/UI/Xaml/Controls/WebView/Win32NativeAotWebView.cs Moves loader initialization into shared loader helper.
src/Uno.UI.Runtime.Skia.Win32/UI/Xaml/Controls/WebView/Win32CoreWebView2EnvironmentStaticsExtension.cs Implements statics extension for browser version/compare.
src/Uno.UI.Runtime.Skia.Win32/Hosting/Win32Host.cs Registers the statics extension on NET10+.
src/SamplesApp/SamplesApp.Samples/Microsoft_UI_Xaml_Controls/WebView2Tests/WebView2_EnvironmentAndProfile.xaml.cs Manual test page to exercise new API surface.
src/SamplesApp/SamplesApp.Samples/Microsoft_UI_Xaml_Controls/WebView2Tests/WebView2_EnvironmentAndProfile.xaml UI for the manual test page (buttons + output + WebView2).
doc/articles/controls/WebView.md Docs describing Windows/NET10 availability and usage.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 227414 has failed on Uno.UI - docs.

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 227413 has failed on Uno.UI - CI.

Copilot AI review requested due to automatic review settings August 13, 2026 15:11
@Xiaoy312

Copy link
Copy Markdown
Contributor Author

Review round addressed in 6824a04, d65ae9c and 2ea3c48. Per-comment replies are inline; the summary:

Applied

  • #nullable enable / restore scoped around the two new cached fields in CoreWebView2.Properties.cs, rather than flipping the file (which would annotate the ten public events declared there).
  • GetAvailableBrowserVersionString(string? browserExecutableFolder) — the parameter was stricter than the WinRT contract it mirrors, so a nullable-enabled app passing the documented null warned against Uno and not against WinAppSDK.
  • The "not initialized" InvalidOperationException now says "Await the WebView2 control's EnsureCoreWebView2Async()".
  • When_GetAvailableBrowserVersionString_Missing_Folder_Throws uses Assert.Throws<FileNotFoundException>, which removes both the nullable local and the broad catch.
  • The CI failure: both red builds failed on one markdownlint rule, MD028/no-blanks-blockquote at doc/articles/controls/WebView.md:255 — two adjacent > [!NOTE] blocks separated by a blank line. Merged into one alert. Verified locally with the pipeline's own config (markdownlint -c build/.markdownlint.json), including a negative check that the config does flag the pre-fix shape.

Declined, with reasons in the inline replies

  • The five reports on src/Uno.UI/Generated/** — those files are sync-generator output; #if false || false || … is one term per platform slot and WinAppSDK Sync Generator Check diffs against exactly that shape.
  • Three "generic catch clause" reports where the broad catch is the point: the test helper that must report inconclusive for any of the several exception types meaning "no WebView2 available", and the two sample handlers whose purpose is to display whatever exception each target throws. NotImplementedException derives from SystemException, so the suggested filters would suppress the primary case each one exists to show.

Runtime validation — Skia Win32 / net10.0, SamplesApp.Skia.Generic (Release), Given_CoreWebView2Environment + Given_CoreWebView2Profile: 17/17 passed, after the changes above. This also settles the review question about an empty browserExecutableFolder: the loader treats "" the same as a null pointer, so the [DataRow("")] case passes unchanged and no normalization is needed.

On the GitHub Issue: line — this work is tracked in a private tracker, so the line stays generic on purpose: the repo's public-artifact rule requires that a public spec or PR never depend on a private issue, board, or doc as normative context, and that the dependency direction stays one-way (private trackers may reference this PR, not the reverse). Naming or linking the private item here is what that rule prohibits, so there is nothing to substitute for "tracked internally" short of opening a public duplicate.

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.

Pull request overview

Copilot reviewed 19 out of 23 changed files in this pull request and generated no new comments.

Suppressed comments (3)

src/Uno.UI/UI/Xaml/Controls/WebView/Core/CoreWebView2Environment.cs:65

  • GetAvailableBrowserVersionString(string?) documents that null or empty uses the installed browser, but this implementation forwards an empty string to the platform extension unchanged. If the native loader treats "" differently than null (common for Win32 APIs), this would break the documented contract and the tests that pass "".
	public static string GetAvailableBrowserVersionString(string? browserExecutableFolder)
		=> Statics("GetAvailableBrowserVersionString(string browserExecutableFolder)")
			.GetAvailableBrowserVersionString(browserExecutableFolder);

src/Uno.UI.RuntimeTests/Tests/Microsoft_Web_WebView2_Core/Given_CoreWebView2Environment.cs:77

  • This helper uses Assert.Inconclusive when WebView2 runtime/loader is missing. That means these tests can silently stop validating the feature (e.g., on CI images that regress WebView2 installation/deployment). Consider making the runtime a hard requirement for SkiaWin32 test runs (fail with a clear message) or gate execution via test infrastructure so missing prerequisites are surfaced explicitly.
		// Outside the catch, so the AssertInconclusiveException is not swallowed.
		if (failure is not null)
		{
			Assert.Inconclusive($"The WebView2 Runtime is unavailable: {failure.GetType().FullName}: {failure.Message}");
		}

src/Uno.UI.RuntimeTests/Tests/Microsoft_Web_WebView2_Core/Given_CoreWebView2Profile.cs:143

  • This test invokes ClearBrowsingDataAsync against the app's real WebView2 user-data folder and does not restore any state afterward. That can make later WebView2 tests (or subsequent manual runs) non-deterministic because it deletes persisted profile data. Prefer isolating these tests to a dedicated per-test user data folder, or add cleanup that restores any state your test setup depends on.
			0 => profile.ClearBrowsingDataAsync(),
			1 => profile.ClearBrowsingDataAsync(CoreWebView2BrowsingDataKinds.AllProfile),
			_ => profile.ClearBrowsingDataAsync(
				CoreWebView2BrowsingDataKinds.Cookies,
				DateTimeOffset.UtcNow.AddHours(-1),

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 227437 has failed on Uno.UI - CI.

The Win32 WebView2 constructor blocks the UI thread in a nested pump while
the environment and controller are created. On a cold CI agent that stall
consumes the whole 1s WaitForLoaded default, so the first tests of the class
timed out waiting on the Border before reaching any assertion.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings August 13, 2026 18:29

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.

Pull request overview

Copilot reviewed 19 out of 23 changed files in this pull request and generated no new comments.

Suppressed comments (6)

src/Uno.UI.RuntimeTests/Tests/Microsoft_Web_WebView2_Core/Given_CoreWebView2Environment.cs:86

  • Add the matching #endif for the NET10_0_OR_GREATER guard so this test file is excluded from net9.0 builds where the feature intentionally stays NotImplemented.
}

src/Uno.UI.RuntimeTests/Tests/Microsoft_Web_WebView2_Core/Given_CoreWebView2Profile.cs:171

  • Add the matching #endif for the NET10_0_OR_GREATER guard so this test file is excluded from net9.0 builds where Profile/Environment intentionally remain NotImplemented.
}

src/Uno.UI.RuntimeTests/Tests/Microsoft_Web_WebView2_Core/Given_CoreWebView2Environment.cs:1

  • These tests exercise the WebView2Aot-backed environment statics, which are only registered on Skia Win32 for net10.0+ (see Win32Host registration). Without a NET10_0_OR_GREATER guard, this test class will run under net9.0 and hit NotImplemented behavior (or fail outright).

This issue also appears on line 86 of the same file.

using System;

src/Uno.UI.RuntimeTests/Tests/Microsoft_Web_WebView2_Core/Given_CoreWebView2Environment.cs:71

  • RequireBrowserVersion catches all exceptions and marks the test inconclusive, which would also hide real regressions (e.g., unexpected ArgumentException/COM failures) as “runtime unavailable”. Narrow the inconclusive path to the specific “runtime missing / not implemented” exception types and let other exceptions fail the test.
		catch (Exception ex)
		{
			// Deliberately broad: a missing runtime is FileNotFoundException, a missing loader DllNotFoundException,
			// and a target without the extension NotImplementedException. All of them mean inconclusive, not failed.
			failure = ex;

src/Uno.UI.RuntimeTests/Tests/Microsoft_Web_WebView2_Core/Given_CoreWebView2Profile.cs:1

  • Like the environment statics, CoreWebView2.Profile / .Environment and data clearing are only implemented on Skia Win32 for net10.0+. This test class will run under net9.0 (SkiaPreviousAndCurrent) and throw NotImplemented from the new capability layer instead of producing assertions.

This issue also appears on line 171 of the same file.

using System;

src/Uno.UI.RuntimeTests/Tests/Microsoft_Web_WebView2_Core/Given_CoreWebView2Profile.cs:77

  • The comment above says ProfileName is expected to be empty (not "Default"), but the assertion only checks non-null, which doesn’t actually validate the stated contract. Consider asserting string.Empty so regressions (e.g., accidentally returning "Default") are caught.
		// Empty, not "Default": the controller is created without ICoreWebView2ControllerOptions, so no
		// profile name is ever requested even though the profile directory resolves to "Default".
		Assert.IsNotNull(profile.ProfileName);
		Assert.IsTrue(Path.IsPathRooted(profile.ProfilePath), $"'{profile.ProfilePath}' is not rooted.");

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@mergify

mergify Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@Xiaoy312
Xiaoy312 merged commit 8a411e9 into master Aug 14, 2026
55 checks passed
@Xiaoy312
Xiaoy312 deleted the dev/xygu/20260812/win32-webview2-env-n-profile branch August 14, 2026 16:19
@ajpinedam

Copy link
Copy Markdown
Contributor

@Mergifyio backport release/stable/6.7

@mergify

mergify Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

backport release/stable/6.7

✅ Backports have been created

Details

kazo0 added a commit that referenced this pull request Aug 28, 2026
…6.7/pr-24062

feat(webview): Implement CoreWebView2Environment and CoreWebView2Profile on Skia Win32 (backport #24062)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/automation Categorizes an issue or PR as relevant to project automation kind/documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants