Repository navigation
Conversation
Retain Windows-owned wrappers for the existing reconnect mapper, detach their old native children, and clear the child backing reference and clip. Keep generic and external-container teardown unchanged. Strengthen reconnect coverage and add native-release and container-removal controls. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3fbc658d-03e3-43ae-af5c-f3584e3b45d7
Keep the regression tests unchanged and revert only the two product files to the pinned net11 baseline. This temporary control must fail the original three Windows reconnect cases before the product fix is restored. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3fbc658d-03e3-43ae-af5c-f3584e3b45d7
The hosted product-only negative control reproduced all three original wrapper identity assertions and both new lifecycle failures. Restore the exact green product/tree for the final hosted native control. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3fbc658d-03e3-43ae-af5c-f3584e3b45d7
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 39577Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 39577" |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 Changes recommended
A retained wrapper can remain collapsed when a Label changes from hidden to visible while its handler is disconnected.
1 open issue
What changed in this PR
Restores Windows wrapper identity and visual-tree position when handlers reconnect, addressing the Label lifecycle failures discovered during #39536 and preserving the contract introduced by #37392.
Changes:
- Retains Windows wrappers during disconnect while detaching their old native children.
- Clears stale child references and composition clips safely.
- Strengthens reconnect assertions and adds native-child collection and wrapper-removal tests.
| File | Description |
|---|---|
src/Core/src/Platform/Windows/WrapperView.cs |
Clears child references and safely removes composition clips. |
src/Core/src/Handlers/View/ViewHandler.cs |
Preserves Windows wrappers across handler disconnects. |
src/Controls/tests/DeviceTests/Elements/Label/LabelTests.Windows.cs |
Extends reconnect, detachment, and collection coverage. |
Review effort: Balanced
| if (HasContainer && ContainerView is Platform.WrapperView wrapper) | ||
| { | ||
| HasContainer = false; | ||
| // Keep the wrapper's visual-tree slot for ReconnectContainer, not the disconnected native view. | ||
| wrapper.Child = null; |
| { | ||
| HasContainer = false; | ||
| // Keep the wrapper's visual-tree slot for ReconnectContainer, not the disconnected native view. | ||
| wrapper.Child = null; |
There was a problem hiding this comment.
[major] Handler Mapper and Property Patterns - Restore opacity on the retained wrapper when reconnecting. On Windows, attach a visible Button with a non-null Clip and Opacity = 0, disconnect its handler, set Opacity = 1 while disconnected, then reconnect the same handler with SetVirtualView. The clip keeps HasContainer true, so MapContainerView replaces the child without requesting an opacity refresh. SetVirtualView enters Connecting for the new native view, causing the inherited MapOpacity to skip the default value 1; MapVisibility also skips Visible. The retained wrapper therefore stays at opacity 0 and the Button remains invisible. Replay opacity through the mapper for retained wrappers and add this disconnected zero-to-one transition using a non-Label control: the current Label tests cannot catch it because LabelHandler overrides MapOpacity without the default-value skip.
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
/review expert-review |
This comment has been minimized.
This comment has been minimized.
PR Test Gate |

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!
Description of Change
Fix the three pre-existing Windows Label wrapper-reconnect failures on net11.0, independently of #39536's GC fixture change. Base:
7b0ea7800db3f3faccbaecb665d32b7c61eaf932. Validated head:17b66a97f4aef6dfc513086c6e3b2aef6876a136.Root cause: generic
ViewHandler.OnDisconnectingtears down every container before the old platform view is nulled. On Windows this disposes/removes the existing wrapper and reparents the old native child into the external parent. The newly created native child has no connection to that visual-tree slot. This contradicts the existing WindowsReconnectContainercontract and the three correct identity/parent-preservation tests added by #37392.Fix: preserve a Windows
WrapperViewas the visual-tree placeholder, while detaching its old native child. Existing mapper replay connects the new unparented child to that same wrapper, without re-entering virtualSetupContaineror rebuilding an external layout. Non-Windows and external/non-wrapper container teardown remains unchanged.Also correct
WrapperView.Child = null: it previously removed the child/callbacks but retained the old_childreference. Clear that backing reference, remove the old child's composition clip before replacement, and make clip disposal tolerate an empty wrapper. Normal container removal remains supported.The existing three reconnect tests retain their identity, parent, hit-testing, sizing/alignment and connection assertions, with additional old-child detachment checks. Two new native cases verify that the old native child collects while the handler and attached wrapper stay alive, and that reconnecting without a container restores the new native view to the wrapper's original slot.
Scope: three files, 98 insertions / 12 deletions. No public API, dependency, pipeline, MSIX shutdown flag, Android HybridWebView, GC helper/fixture, retry, sleep, skip or tolerance changes. Open and recently merged PRs, including main/inflight/net11 lifecycle history, were checked for an equivalent fix; none was found.
Hosted native causal proof — Windows unpackaged, actual Label category XML
Assert.Samefailures62be5373d836a95aAssert.Samefailures return17b66a97The baseline failures also occur in original device build 1644557. The relevant lifecycle/test sources are unchanged between that exact base and this PR's pinned base. Each new arm is one full Windows execution, not a stress/flake-elimination claim.
The negative control changes only the two product files back to the pinned base; the test source is unchanged. Both new lifecycle cases also fail for their intended cleanup assertions: the old child remains parented to a Grid, and the removed wrapper still exposes its old TextBlock. The restored commit's entire tree is identical to the first green candidate. Normal revert/restore commits retain this provenance; no rebase, amendment or force-push was used.
Final hosted build 1645933 additionally produced real packaged Controls XML: Label has 44 passed / 0 failed / 2 existing skips, including all three original and both new cases. Full packaged Controls and full unpackaged Controls each have 976 passed / 0 failed / 33 skipped execution records. Full unpackaged Core has 2,033 passed / 0 failed / 111 skipped. XML declarations, physical records and assembly errors were reconciled; these results are not inferred from launcher exit zero.
Commands and results
DOTNETdenotes the private copy of pinned SDK11.0.100-rtm.26514.118(product11.0.100); no global SDK/workload configuration was changed.Eis the session evidence directory. Each actual queue request contains onlyresources.repositories.self(branch and exact commit) andstagesToSkipfor the seven non-Windows stages. Default-pipeline previews verified net11 targeting; actual timelines confirmed those seven stages completed/skipped. Only the Windows build/run stages executed. No pipeline source or template-parameter override was introduced.Limits: the full restored pipeline is not green. Four other packaged apps (Core, Essentials, Graphics and BlazorWebView) fail before test execution with
Add-AppxPackage0x80073D02/ WebExperience resources in use and no XML. Their coverage is not claimed; the separate MSIX deployment port is not included. The first candidate also had packaged pre-test deployment failures, so its green coverage is unpackaged only. No local Windows/Mac desktop automation, XCTest or screen takeover was used. Other platforms were not exercised for this Windows-specific correction.pr-finalizefound no blocking code findings and checked the title/description against the final diff and evidence.Issues Fixed
Resolves the three pre-existing Windows Label reconnect failures discovered while investigating #39536. Restores the Windows wrapper-reconnect contract from #37392; this is not a change to either PR's GC or input-transparency scope. No separate issue was filed.