Allow Opt-out of using the WebView2CompositionControl for WPF BlazorWebView#34764
Closed
mobiletonster wants to merge 195 commits into
Closed
Allow Opt-out of using the WebView2CompositionControl for WPF BlazorWebView#34764mobiletonster wants to merge 195 commits into
mobiletonster wants to merge 195 commits into
Conversation
* Try fix building with iOS net11 * More net11 changes * Update iOS versions * Update net9 version * Fix version global IOS * Update version * Update XCode * Disable DotNetPrevious tests * Needs to be net10 * Ignore Windows tests * Run net10 targetframework
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
## Description This PR enables CoreCLR iOS and MacCatalyst device tests, mirroring the existing Android CoreCLR device tests implementation. ## Changes: - Added useCoreClr and /p:UseMonoRuntime=false when building with CoreCLR - Enabled device tests
## Description This PR fixes CoreCLR build.
# Conflicts: # eng/Versions.props # eng/common/core-templates/job/publish-build-assets.yml # eng/common/core-templates/post-build/post-build.yml # eng/common/core-templates/steps/install-microbuild.yml # eng/pipelines/ci-device-tests.yml # eng/pipelines/ci-official.yml # eng/pipelines/ci-uitests.yml # eng/pipelines/ci.yml # eng/pipelines/device-tests.yml # eng/pipelines/handlers.yml # eng/pipelines/ui-tests.yml
### Description of Change Bring latest from main to net11
### Description of Change This pull request expands the device test pipeline to add support for running CoreCLR Helix tests on iOS and MacCatalyst, in addition to Android. The changes update the build and test stages to include these new platforms and adjust build parameters accordingly. **Pipeline expansion for CoreCLR device tests:** * Updated the `devicetests_build_coreclr` stage to reflect that it now builds for iOS and MacCatalyst in addition to Android, as shown in its `displayName`. * Modified the build script invocation to always include iOS and MacCatalyst target frameworks for device tests, removing `/p:IncludeIosTargetFrameworks=false` and `/p:IncludeMacCatalystTargetFrameworks=false` so these platforms are now built. **New test stages for additional platforms:** * Added a new `devicetests_ios_coreclr` stage to run CoreCLR Helix device tests on iOS, including downloading build artifacts and sending tests to Helix with appropriate parameters. * Added a new `devicetests_catalyst_coreclr` stage to run CoreCLR Helix device tests on MacCatalyst, with similar steps as the iOS stage. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
### Description of Change Update sdk and workloads on net11
This pull request updates the following dependencies [marker]: <> (Begin:1ae85174-dfc1-4a00-b3c3-5a31c41fb9ce) ## From https://github.com/dotnet/macios - **Subscription**: [1ae85174-dfc1-4a00-b3c3-5a31c41fb9ce](https://maestro.dot.net/subscriptions?search=1ae85174-dfc1-4a00-b3c3-5a31c41fb9ce) - **Build**: [20260109.1](https://dev.azure.com/devdiv/DevDiv/_build/results?buildId=13067712) ([296608](https://maestro.dot.net/channel/8298/github:dotnet:macios/build/296608)) - **Date Produced**: January 9, 2026 2:38:42 PM UTC - **Commit**: [fbf9398e3af05523a8956bdc95b77a9e282953ea](dotnet/macios@fbf9398) - **Branch**: [net11.0](https://github.com/dotnet/macios/tree/net11.0) [DependencyUpdate]: <> (Begin) - **Dependency Updates**: - From [26.2.11231-ci.net11-0 to 26.2.11232-ci.net11-0][1] - Microsoft.iOS.Sdk.net11.0_26.2 - Microsoft.MacCatalyst.Sdk.net11.0_26.2 - Microsoft.macOS.Sdk.net11.0_26.2 - Microsoft.tvOS.Sdk.net11.0_26.2 [1]: dotnet/macios@aced0a1...fbf9398 [DependencyUpdate]: <> (End) [marker]: <> (End:1ae85174-dfc1-4a00-b3c3-5a31c41fb9ce) Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
# Conflicts: # eng/helix_xharness.proj
This pull request updates the following dependencies [marker]: <> (Begin:9a046932-c60c-436e-8fc7-8ea2f5902cb4) ## From https://github.com/dotnet/android - **Subscription**: [9a046932-c60c-436e-8fc7-8ea2f5902cb4](https://maestro.dot.net/subscriptions?search=9a046932-c60c-436e-8fc7-8ea2f5902cb4) - **Build**: [11.0.0-c1.net11.26058.1+azdo.13060433](https://dev.azure.com/devdiv/DevDiv/_build/results?buildId=13060433) ([296455](https://maestro.dot.net/channel/8298/github:dotnet:android/build/296455)) - **Date Produced**: January 8, 2026 7:05:28 PM UTC - **Commit**: [1878a87228622c90a16787016fcb2e01b8bc052b](dotnet/android@1878a87) - **Branch**: [main](https://github.com/dotnet/android/tree/main) [DependencyUpdate]: <> (Begin) - **Dependency Updates**: - From [36.1.99-ci.main.77 to 36.1.99-ci.main.83][1] - Microsoft.Android.Sdk.Windows [1]: dotnet/android@9297282...1878a87 [DependencyUpdate]: <> (End) [marker]: <> (End:9a046932-c60c-436e-8fc7-8ea2f5902cb4) Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
This pull request updates the following dependencies [marker]: <> (Begin:9a046932-c60c-436e-8fc7-8ea2f5902cb4) ## From https://github.com/dotnet/android - **Subscription**: [9a046932-c60c-436e-8fc7-8ea2f5902cb4](https://maestro.dot.net/subscriptions?search=9a046932-c60c-436e-8fc7-8ea2f5902cb4) - **Build**: [11.0.0-c1.net11.26062.1+azdo.13082281](https://dev.azure.com/devdiv/DevDiv/_build/results?buildId=13082281) ([296966](https://maestro.dot.net/channel/8298/github:dotnet:android/build/296966)) - **Date Produced**: January 12, 2026 11:52:56 PM UTC - **Commit**: [51a138deee3f08083a571f803d72dcb8bdb45f70](dotnet/android@51a138d) - **Branch**: [main](https://github.com/dotnet/android/tree/main) [DependencyUpdate]: <> (Begin) - **Dependency Updates**: - From [36.1.99-ci.main.83 to 36.1.99-ci.main.88][2] - Microsoft.Android.Sdk.Windows [2]: dotnet/android@1878a87...51a138d [DependencyUpdate]: <> (End) [marker]: <> (End:9a046932-c60c-436e-8fc7-8ea2f5902cb4) --------- Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Integration tests require ios-simulator-64_18.5 but Xcode 26.2 only includes iOS 26.2 by default. This adds a step to download the iOS 18.5 simulator runtime after the default simulator installation.
This pull request updates the following dependencies [marker]: <> (Begin:1ae85174-dfc1-4a00-b3c3-5a31c41fb9ce) ## From https://github.com/dotnet/macios - **Subscription**: [1ae85174-dfc1-4a00-b3c3-5a31c41fb9ce](https://maestro.dot.net/subscriptions?search=1ae85174-dfc1-4a00-b3c3-5a31c41fb9ce) - **Build**: [20260113.1](https://dev.azure.com/devdiv/DevDiv/_build/results?buildId=13087503) ([297127](https://maestro.dot.net/channel/8298/github:dotnet:macios/build/297127)) - **Date Produced**: January 13, 2026 5:18:33 PM UTC - **Commit**: [13be6a67ad7fb5968639d67a357bd04f892ed381](dotnet/macios@13be6a6) - **Branch**: [net11.0](https://github.com/dotnet/macios/tree/net11.0) [DependencyUpdate]: <> (Begin) - **Dependency Updates**: - From [26.2.11232-ci.net11-0 to 26.2.11233-ci.net11-0][1] - Microsoft.iOS.Sdk.net11.0_26.2 - Microsoft.MacCatalyst.Sdk.net11.0_26.2 - Microsoft.macOS.Sdk.net11.0_26.2 - Microsoft.tvOS.Sdk.net11.0_26.2 [1]: dotnet/macios@fbf9398...13be6a6 [DependencyUpdate]: <> (End) [marker]: <> (End:1ae85174-dfc1-4a00-b3c3-5a31c41fb9ce) Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
This pull request updates the following dependencies [marker]: <> (Begin:9a046932-c60c-436e-8fc7-8ea2f5902cb4) ## From https://github.com/dotnet/android - **Subscription**: [9a046932-c60c-436e-8fc7-8ea2f5902cb4](https://maestro.dot.net/subscriptions?search=9a046932-c60c-436e-8fc7-8ea2f5902cb4) - **Build**: [11.0.0-c1.net11.26063.1+azdo.13087794](https://dev.azure.com/devdiv/DevDiv/_build/results?buildId=13087794) ([297134](https://maestro.dot.net/channel/8298/github:dotnet:android/build/297134)) - **Date Produced**: January 13, 2026 5:43:47 PM UTC - **Commit**: [16bb23264f2e802dfdc85e5b4bd2f275115d99fe](dotnet/android@16bb232) - **Branch**: [main](https://github.com/dotnet/android/tree/main) [DependencyUpdate]: <> (Begin) - **Dependency Updates**: - From [36.1.99-ci.main.88 to 36.1.99-ci.main.89][1] - Microsoft.Android.Sdk.Windows [1]: dotnet/android@51a138d...16bb232 [DependencyUpdate]: <> (End) [marker]: <> (End:9a046932-c60c-436e-8fc7-8ea2f5902cb4) Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
- Update Android APK path from net11.0-android to net10.0-android in helix_xharness.proj - Remove quotes from HelixProjectArguments for iOS and MacCatalyst CoreCLR scenarios to fix MSBuild argument parsing
…device tests (dotnet#33474) - Add universal binary search logic in devices-shared.cake for iOS/macCatalyst - Add ARM64 agent demands for MAUI pool in ci-device-tests.yml and ci-uitests.yml - Update RuntimeIdentifiers to use CI/TF_BUILD environment variable checks
…otnet#34969) <!-- 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! ## Description Fixes dotnet#34910 `MKMapView.Overlays` returns `null` (not an empty array) when no overlays have been added to the map. The `OnMapClicked` handler in `MauiMKMapView.cs` iterated `.Overlays` without a null check, causing a `NullReferenceException` when tapping the map. This was introduced by the "Add Circle, Polygon, and Polyline click events" feature (dotnet#29101) on the net11.0 branch. ## Changes **Fix** (`MauiMKMapView.cs`): - Added null check for `mauiMkMapView.Overlays` before iterating, following the existing null guard pattern from `ClearMapElements()` at line 322. **Tests** (`MapTests.cs`): - ` Verifies `IMap.Clicked` does not throw when the map has no elementsClickedDoesNotThrowWithNoElements` - ` Verifies the `MapClicked` event fires correctly with proper location data when no map elements existClickedFiresEventWithNoElements` ## Root Cause The `OnMapClicked` static method (line 568) did: ```csharp foreach (var overlay in mauiMkMapView.Overlays) // NullRef when Overlays is null ``` `MKMapView.Overlays` is a native iOS property that returns `null` when no overlays exist (unlike .NET collections which typically return empty). The fix stores the value first and returns early if null: ```csharp var overlays = mauiMkMapView.Overlays; if (overlays is null) return; foreach (var overlay in overlays) ``` This matches the existing pattern in `ClearMapElements()`: ```csharp var elements = Overlays; if (elements == null) return; ``` Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Apr 20, 2026
…ethod (dotnet#34986) ## Problem PR dotnet#34958's fix for the HybridWebView IL3050 warning used a **local function** inside `AddControlsHandlers`. This worked with SDK `26166.111` but **fails with the newer SDK** `26203.107` (from dotnet#34852): ``` Unexpected warning: AppHostBuilderExtensions.<AddControlsHandlers>g__AddHybridWebViewHandler|2_0 has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. ``` The C# compiler emits local functions as `<EnclosingMethod>g__Name|N_M` — a compiler-generated method that newer ILC versions trace back to the caller, defeating the `[FeatureGuard]` suppression on `RuntimeFeature.IsHybridWebViewSupported`. ## Fix Move the local function to a **private static method** on the class. This creates a real method boundary in IL metadata that the `[FeatureGuard]` can properly suppress — the standard pattern documented in our [trim/AOT review rules](https://github.com/dotnet/maui/blob/main/.github/skills/code-review/references/review-rules.md#23-trim--nativeaot-safety). cc @simonrozsival — this builds on your dotnet#34958 fix, just moving from local function to class method for the newer ILC. ## Validation `dotnet build Controls.Core.csproj -f net11.0 -p:TreatWarningsAsErrors=true` — 0 errors --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Reset patterns: - global.json - NuGet.config - eng/Version.Details.xml - eng/Versions.props - eng/common/*
# Conflicts: # src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSLargeTitlePage.xaml.cs # src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs # src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt # src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt # src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt # src/Controls/src/SourceGen/AnalyzerReleases.Unshipped.md # src/Controls/src/Xaml/XmlName.cs # src/Controls/tests/ManualTests/Controls.ManualTests.csproj # src/Controls/tests/TestCases.Android.Tests/snapshots/android/DynamicTabSectionVisibility.png # src/Core/maps/src/Handlers/Map/MapHandler.Android.cs # src/Core/maps/src/Platform/iOS/MauiMKMapView.cs # src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt
Port MapElementId tracking from main (PR dotnet#30116) into net11.0's iOS MauiMKMapView. Tracks added map elements in _trackedMapElements so ClearMapElements can reset MapElementId even after the ObservableCollection is already empty. Also removes duplicate non-nullable PublicAPI entries for ShowInfoWindow and HideInfoWindow (keeping the nullable-annotated versions). Fixes failing ClearMapElementsResetsMapElementId and ClearResetsMapElementIdForAllElementTypes device tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
I detected changes in the main branch which have not been merged yet to net11.0. I'm a robot and am configured to help you automatically keep net11.0 up to date, so I've opened this PR. This PR merges commits made on main by the following committers: * TamilarasanSF4853 * PureWeen * JanKrivanek * kubaflo * mattleibow * Copilot * CathyZhu0110 * Vignesh-SF3580 * StephaneDelcroix * Oxymoron290 * mmitche * akoeplinger * sheiksyedm ## Instructions for merging from UI This PR will not be auto-merged. When pull request checks pass, complete this PR by creating a merge commit, *not* a squash or rebase commit. <img alt="merge button instructions" src="https://i.imgur.com/GepcNJV.png" width="300" /> If this repo does not allow creating merge commits from the GitHub UI, use command line instructions. ## Instructions for merging via command line Run these commands to merge this pull request from the command line. ``` sh git fetch git checkout main git pull --ff-only git checkout net11.0 git pull --ff-only git merge --no-ff main # If there are merge conflicts, resolve them and then run git merge --continue to complete the merge # Pushing the changes to the PR branch will re-trigger PR validation. git push https://github.com/dotnet/maui HEAD:merge/main-to-net11.0 ``` <details> <summary>or if you are using SSH</summary> ``` git push git@github.com:dotnet/maui HEAD:merge/main-to-net11.0 ``` </details> After PR checks are complete push the branch ``` git push ``` ## Instructions for resolving conflicts :warning: If there are merge conflicts, you will need to resolve them manually before merging. You can do this [using GitHub][resolve-github] or using the [command line][resolve-cli]. [resolve-github]: https://help.github.com/articles/resolving-a-merge-conflict-on-github/ [resolve-cli]: https://help.github.com/articles/resolving-a-merge-conflict-using-the-command-line/ ## Instructions for updating this pull request Contributors to this repo have permission update this pull request by pushing to the branch 'merge/main-to-net11.0'. This can be done to resolve conflicts or make other changes to this pull request before it is merged. The provided examples assume that the remote is named 'origin'. If you have a different remote name, please replace 'origin' with the name of your remote. ``` git fetch git checkout -b merge/main-to-net11.0 origin/net11.0 git pull https://github.com/dotnet/maui merge/main-to-net11.0 (make changes) git commit -m "Updated PR with my changes" git push https://github.com/dotnet/maui HEAD:merge/main-to-net11.0 ``` <details> <summary>or if you are using SSH</summary> ``` git fetch git checkout -b merge/main-to-net11.0 origin/net11.0 git pull git@github.com:dotnet/maui merge/main-to-net11.0 (make changes) git commit -m "Updated PR with my changes" git push git@github.com:dotnet/maui HEAD:merge/main-to-net11.0 ``` </details> Contact .NET Core Engineering (dotnet/dnceng) if you have questions or issues. Also, if this PR was generated incorrectly, help us fix it. See https://github.com/dotnet/arcade/blob/main/.github/workflows/scripts/inter-branch-merge.ps1.
…Android (dotnet#35094) > [!NOTE] > This PR was created with assistance from AI. Port of dotnet#35071 to the `net11.0` branch. ## Summary Add `_PrepareTrimConfiguration` to `_MauiPrepareForILLink`'s `BeforeTargets` so that `RuntimeHostConfigurationOption` items (like `IsHybridWebViewSupported`) are added before the runtime's internal target snapshots them into `_TrimmerFeatureSettings`. ## Problem dotnet/runtime PR #124801 moved the `RuntimeHostConfigurationOption` → `_TrimmerFeatureSettings` conversion from `PrepareForILLink` into an earlier internal target (`_PrepareTrimConfiguration`). MAUI's `_MauiPrepareForILLink` hooks `BeforeTargets="PrepareForILLink"`, which now fires *after* the snapshot. As a result, ILC never receives `--feature` flags for MAUI's feature switches on Android NativeAOT, causing spurious IL3050 warnings for `HybridWebViewHandler`. This is the branch (`net11.0`, SDK `11.0.100-preview.3.26203.107`) where the bug manifests — the .NET 11 SDK has `_PrepareTrimConfiguration`. ## Fix Remove `PrepareForILLink` from `BeforeTargets` (redundant — it's a transitive dependent of `_PrepareTrimConfiguration`) and add `_PrepareTrimConfiguration` instead. This ensures MAUI's `RuntimeHostConfigurationOption` items are present when the snapshot runs. **Temporary workaround** using the internal target name. The runtime fix (dotnet/runtime#127253) renames this to the public `PrepareTrimConfiguration`. Once that flows, update to `BeforeTargets="PrepareTrimConfiguration"`. Workaround for dotnet/runtime#127017 cc @sbomer @simonrozsival Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Allows opting out of the WebView2CompositionControl (introduced in net10.0 to fix WPF airspace issues) in favor of the standard WebView2 control when airspace layering is not required and lower rendering overhead is preferred. - Add UseCompositionControl dependency property (default: true) to BlazorWebView, preserving existing behavior by default - Type _webview and the WebView property as IWebView2, the interface implemented by both WebView2 and WebView2CompositionControl - CreateWebViewTemplate() selects the correct control type at init time; the property-changed callback swaps the template if set before the control is added to the visual tree - Throw InvalidOperationException if UseCompositionControl is changed after the underlying WebView2 has already been created - Update WebView2WebViewManager and BlazorWebViewInitializedEventArgs shared source to use IWebView2 for the WPF type alias - Update PublicAPI.Shipped.txt to reflect the IWebView2 return types and new UseCompositionControl public API
…Unshipped.txt I misunderstood how this was used. This should correct it.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Enhanced error reporting when WebView2 template child is missing or of the wrong type. Updated public API to return IWebView2 instead of WebView2CompositionControl for greater abstraction.
c612109 to
543def2
Compare
Collaborator
|
|
Collaborator
|
|
Contributor
|
/review -b feature/refactor-copilot-yml |
Collaborator
|
|
Author
|
Should we just close this PR? We have a similar PR up that targets the correct branch: I think we are safe to close this one. |
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.
Description of Change
This change introduces an opt‑out mechanism for using
WebView2CompositionControlin WPF BlazorWebView scenarios. WhileWebView2CompositionControlresolves the WPF airspace issue, it introduces measurable rendering overhead that negatively impacts Razor component performance.For apps that do not require XAML‑over‑WebView layering, developers can now disable the composition control and fall back to the standard
WebView2, resulting in significantly improved performance on WPF.This feature also addresses feedback from the original
WebView2CompositionControlintroduction(PR #31777: #31777)
and community requests asking for an opt‑in/opt‑out toggle
(Issue #28063: #28063).
Issues Fixed / Related
WebView2CompositionControlrequest and discussion:Allow use of new WebView2CompositionControl for WPF BlazorWebView #28063
Use the WebView2CompositionControl in Blazor WPF #31777
This PR enables opting out of
WebView2CompositionControl(added in .NET 10.0 to address WPF airspace issues) in favor of the standardWebView2when airspace layering is unnecessary and lower rendering overhead is preferred.Summary of Changes
UseCompositionControldependency property (default:true) onBlazorWebView, preserving existing behavior._webviewand theWebViewproperty to useIWebView2, implemented by bothWebView2andWebView2CompositionControl.CreateWebViewTemplate()now selects the correct control type at initialization; the property‑changed callback updates the template if changed before the control is added to the visual tree.InvalidOperationExceptionifUseCompositionControlis modified after the underlying WebView has been created.WebView2WebViewManagerandBlazorWebViewInitializedEventArgsshared source to use the WPFIWebView2alias.IWebView2return types and theUseCompositionControlpublic API surface.Notes
This is not a bug fix; it is a feature/performance enhancement.