Skip to content

[release/11.0.1xx-preview7] Reset WinUI Label line height to default - #37062

Closed
kubaflo wants to merge 12 commits into
release/11.0.1xx-preview7from
kubaflo/update-preview7-winui-label-baselines
Closed

[release/11.0.1xx-preview7] Reset WinUI Label line height to default#37062
kubaflo wants to merge 12 commits into
release/11.0.1xx-preview7from
kubaflo/update-preview7-winui-label-baselines

Conversation

@kubaflo

@kubaflo kubaflo commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

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

The ordered Label feature tests set LineHeight=3, then later option navigations replace the view model with the default LineHeight=-1. WinUI's UpdateLineHeight assigned a local TextBlock.LineHeight for positive values but ignored the default negative value, so the reused native TextBlock retained the old three-line-height setting. Recreating the page produced a fresh TextBlock with the correct default line height, causing 17 deterministic before/after screenshot mismatches.

This change:

  • clears the WinUI TextBlock.LineHeightProperty when Label.LineHeight returns to its default negative value, restoring style/native-default precedence;
  • adds a Windows device regression test covering the 3 to -1 transition;
  • removes the disproven WinUI mapper-order experiment; and
  • updates all 24 affected WinUI Label baselines from the correct default-line-height state. The final seven captures were byte-identical across all four retries in exact UI build 1538857.

Validation

  • Exact build 1538707 disproved the mapper-order experiment: Android and iOS Label suites passed, while WinUI failed the same 17 post-LineHeight tests before and after retry.
  • Exact head 5a702384e1 passed main build 1538856; Android, iOS, and MacCatalyst Label runs had no failed individual results in UI build 1538857; and Windows device run 42375462 passed LineHeight Resets To Default twice. The device pipeline was red only for two unrelated Android Entry tests already covered by [release/11.0.1xx-preview7] Preserve Android Entry text during handler reuse #37052.
  • WinUI run 42376752 proved the original 17 failures fixed and left seven deterministic visual shifts. Every remaining actual capture was byte-identical across four retries, and each replacement now compares at zero RMS against that exact capture.
  • Current head cd9f74f764 requires fresh exact-head /azp run proof for all WinUI Label tests and the Windows device regression test.

Issues Fixed

Contributes to stabilizing the .NET 11 Preview 7 UI-test branch.

Refresh the 17 deterministic Label baselines produced by the current
Preview 7 test host. The same failures reproduce with the blessed SDK.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 9be49656-7117-4235-9d96-404779ab6b16
Copilot AI review requested due to automatic review settings August 3, 2026 20:40
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool August 3, 2026 20:40 — with GitHub Actions Inactive

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.

Copilot wasn't able to review any files in this pull request.

@kubaflo

kubaflo commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

/azp run

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 37062

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 37062"

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@kubaflo
kubaflo temporarily deployed to copilot-pat-pool August 3, 2026 20:40 — with GitHub Actions Inactive
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@PureWeen

PureWeen commented Aug 3, 2026

Copy link
Copy Markdown
Member

I don’t think updating these shared baselines fixes the underlying failure. Each affected Label test compares the same baseline both before and after App.Tap(MainLabel). The target-branch evidence shows the pre-recreation screenshot passed while the post-recreation screenshot failed, so replacing the baseline with the post-recreation output is likely to move the failure to the first assertion rather than make both states match.

Suggested change: keep the existing baselines and preserve the page, navigation stack, toolbar, and surrounding layout. Put MainLabel in a stable host and recreate only that Label when tapped. Before removing the old Label, clear its binding context/detach its FormattedString; then insert a fresh Label with the same bindings, AutomationId, gesture handler, and name-scope behavior. This still exercises initial mapper application on a newly created handler without introducing page-level layout or toolbar changes.

This remains entirely test-host-only and preserves the intended invariant that rendering is identical before and after recreation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 9be49656-7117-4235-9d96-404779ab6b16
Copilot AI review requested due to automatic review settings August 3, 2026 22:27
@kubaflo kubaflo changed the title [release/11.0.1xx-preview7] Update WinUI Label snapshots [release/11.0.1xx-preview7] Stabilize Label UI test recreation Aug 3, 2026
@kubaflo

kubaflo commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Implemented the review feedback at abfbd0321b: all 17 baseline changes are reverted, the page/navigation/toolbar stay intact, and only MainLabel is recreated inside the existing stable host after detaching the old binding context and FormattedString. The replacement reuses the same style, bindings, automation ID, and gesture behavior.

@kubaflo

kubaflo commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

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 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (3)

src/Controls/tests/TestCases.HostApp/FeatureMatrix/Label/LabelControlPage.xaml.cs:28

  • _mainLabel = (Label)MainLabelHost.Children[0]; assumes the host has at least one child and that the first child is a Label. If the XAML changes (or is reordered), this will throw (IndexOutOfRange/InvalidCast) and fail the feature matrix page initialization. Consider validating count/type and producing a clearer failure.
		InitializeComponent();
		_mainLabel = (Label)MainLabelHost.Children[0];
		_viewModel = viewModel;

src/Controls/tests/TestCases.HostApp/FeatureMatrix/Label/LabelControlPage.xaml.cs:56

  • CreateMainLabel sets BindingContext = _viewModel on the new Label. After the first tap, the Label has a local BindingContext, so later BindingContext = _viewModel = new LabelViewModel(); in NavigateToOptionsPage_Clicked will no longer propagate to the recreated label (it will keep the old VM). Rely on inherited BindingContext instead, or explicitly update _mainLabel.BindingContext when the page BindingContext changes.
		var label = new Label
		{
			Style = style,
			BindingContext = _viewModel,
		};

src/Controls/tests/TestCases.HostApp/FeatureMatrix/Label/LabelControlPage.xaml.cs:39

  • PR title/description say this is a baseline-only update (“Update WinUI Label snapshots”), but this PR also changes the HostApp Label feature-matrix page behavior (recreating the main Label instance on tap and refactoring bindings into a Style). If the intent is baseline-only, these functional changes should be moved to a separate PR; otherwise, please update the description to mention the behavioral change so future archaeology doesn’t miss it.
	void MainLabel_Tapped(object sender, TappedEventArgs e)
	{
		var oldLabel = _mainLabel;
		var style = oldLabel.Style ?? throw new InvalidOperationException("MainLabel style is required.");

Let recreated labels inherit the page BindingContext so reopening options can replace the active view model.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 9be49656-7117-4235-9d96-404779ab6b16
Copilot AI review requested due to automatic review settings August 3, 2026 22:48
@kubaflo

kubaflo commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up d6faea8 removes the recreated Label local BindingContext, so it continues inheriting the page context when the Options flow replaces the view model. The HostApp builds successfully.

@kubaflo

kubaflo commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 9be49656-7117-4235-9d96-404779ab6b16
Copilot AI review requested due to automatic review settings August 4, 2026 07:27
@kubaflo kubaflo changed the title [release/11.0.1xx-preview7] Recreate WinUI Label handler in place [release/11.0.1xx-preview7] Restore consistent WinUI Label mapping Aug 4, 2026
@kubaflo

kubaflo commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Head f86235a579 replaces the disproven handler-only workaround. Exact build 1538629 showed the workaround still left all 17 second screenshots mismatched and also correlated with broad Android/iOS/Mac Label failures after named elements were added to a page that re-runs InitializeComponent(). The new head restores the original test host, restores WinUI formatting-before-Text mapping, and installs the stable 24 px line-box captures. Merge proof requires all 94 WinUI Label tests—not only the 17 updated baselines—to pass both initial and post-recreation rendering.

@kubaflo

kubaflo commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

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 1 out of 18 changed files in this pull request and generated no new comments.

Suppressed comments (1)

src/Core/src/Handlers/Label/LabelHandler.cs:22

  • The comment says WinUI must apply “text formatting” before Text, but in this mapper TextColor and TextDecorations are intentionally applied after Text. That makes the comment misleading; suggest clarifying that only line-metric-affecting properties (font/alignment/character spacing/line height) must run before Text.
			// WinUI must apply text formatting before Text. Otherwise, a TextBlock
			// connected without text retains different line metrics when text is added later.

Clear the TextBlock LineHeight dependency property when Label.LineHeight returns to its default value, and cover the transition with a Windows device test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 9be49656-7117-4235-9d96-404779ab6b16
Copilot AI review requested due to automatic review settings August 4, 2026 09:04
@kubaflo kubaflo changed the title [release/11.0.1xx-preview7] Restore consistent WinUI Label mapping [release/11.0.1xx-preview7] Reset WinUI Label line height to default Aug 4, 2026
@kubaflo

kubaflo commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Head 5a702384e1 replaces the disproven mapper-order change with the root fix. Ordered test 10 leaves a local WinUI TextBlock.LineHeight from Label.LineHeight=3; later view models reset to -1, but the mapper previously ignored that value. The reused control therefore stayed at the old line height while the recreated control used the default. This head clears the dependency property on reset and adds a Windows device regression test. Merge proof still requires all 94 WinUI Label tests on this exact head.

@kubaflo

kubaflo commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

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 2 out of 19 changed files in this pull request and generated no new comments.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 9be49656-7117-4235-9d96-404779ab6b16
Copilot AI review requested due to automatic review settings August 4, 2026 11:35
@kubaflo

kubaflo commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@kubaflo

kubaflo commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Head cd9f74f764 adds the final seven WinUI Label baselines from exact UI build 1538857 / run 42376752. For every test, all four retry captures were byte-identical; the measured RMS differences exactly matched the reported 1.29%-6.57% failures, and each checked-in replacement now compares at zero. The prior 17 failures passed on the root-fix head. Fresh /azp run is queued to prove the complete exact head before merge.

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 2 out of 26 changed files in this pull request and generated no new comments.

@kubaflo

kubaflo commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

@PureWeen current head cd9f74f764 is proven and ready to merge.

Exact-head evidence:

  • All three builds use synthetic merge 4231dc4e9e, whose second parent is cd9f74f764.
  • UI build 1539077: WinUI Label run 42382584 has 91 passed, 3 not executed, 0 failed; MacCatalyst Label run 42384542 has 84 passed, 5 not executed, 0 failed. The Android and iOS Label shards also completed successfully.
  • Device build 1539078: both packaged and unpackaged LineHeight Resets To Default results passed in Windows run 42381766.

The remaining red legs are platform-isolated from this Windows-only diff: the two known Android long-Entry failures fixed by #37052, an iOS EntriesScrollingPageTest failure, and an iOS simulator boot timeout in integration tests.

@kubaflo kubaflo closed this Aug 4, 2026
PureWeen pushed a commit that referenced this pull request Aug 4, 2026
<!-- 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 of Change

Bundles independently valid Preview 7 test and test-infrastructure
stabilizations into one merge path. Changes are cherry-picked or
extracted from their source PRs without modifying MAUI runtime or
product behavior.

The aggregate currently covers:

- exact DragEvents label polling and shared Appium text-wait behavior;
- waiting for the iOS Entry keyboard before its snapshot;
- adaptive ListView and CollectionView screenshot stabilization;
- RefreshView gesture retry and SwipeView callback-result waiting;
- stable initial SafeArea layout measurement;
- deterministic iOS Picker-to-Entry keyboard transition handling;
- a bounded Android screenshot tolerance for stable post-rotation
antialiasing variance;
- independent iOS and MacCatalyst Graphics image-scaling device
coverage;
- a bounded UIKit cleanup wait for the CarouselView leak assertion;
- Android-only scoping for the Android modal-animation leak regression
test;
- an exact detached-page transition with a synchronous alert-request
return signal; and
- resilient Windows test-machine resolution setup, with focused Pester
coverage for each fallback and failure path.

Eligible UI tests, device tests, unit tests, test infrastructure, and
screenshot baselines can all be included here when they are
independently valid without a corresponding product-code change.

### Source PRs

The standalone source PRs below are closed in favor of this aggregate.
For #37057, only the independently valid test subset is included; its
product-code rewrite remains excluded.

| PR | Included test-side fix |
|---|---|
| #37044 | Windows screen-resolution test infrastructure and Pester
coverage |
| #37045 | DragEvents exact-text waits and Appium helper |
| #37053 | iOS Entry keyboard readiness |
| #37055 | ListView screenshot retry window |
| #37057 | Graphics image-scaling device tests that pass without the
runtime rewrite |
| #37058 | RefreshView pull-to-refresh retry |
| #37059 | SwipeView result-label wait |
| #37066 | SafeArea initial-layout retry |
| #37069 | Picker keyboard transition stabilization |
| #37074 | Empty CollectionView footer screenshot retry/tolerance |
| #37086 | iOS/MacCatalyst CarouselView leak-test cleanup wait |
| #37088 | Detached-page alert request synchronization |
| #37091 | Android modal-animation leak-test platform scope |
| #37092 | Android Issue22306 post-rotation screenshot tolerance |

### Scope exclusions

Mixed runtime/test fixes are included only when their test-side changes
pass independently against the unmodified product code. The current
device tests in #37052, the four nonpositive-size cases in #37057, and
the device test plus screenshots in #37062 remain excluded because they
expose or describe behavior that requires those PRs' functional fixes.
#37070 has no test-side changes. Closed ineffective or unsafe fixes are
also excluded.

### Validation

- All 25 directly reusable source commits were cherry-picked in their
original order.
- The #37057 device-test subset was extracted into one additional
test-only commit after proving it against the unmodified product
implementation.
- Every directly cherry-picked aggregate file matches the corresponding
included source PR head.
- The aggregate diff contains no MAUI runtime or product files.
- Targeted Release builds pass for `UITest.Appium`,
`Controls.TestCases.iOS.Tests`, `Controls.TestCases.Mac.Tests`, and
`Controls.TestCases.Android.Tests`.
- The focused screen-resolution Pester suite passes 14/14.
- Exact local xUnit XML reports 46/46 Graphics device tests passing on
both iOS 26 and MacCatalyst, including all 13 extracted cases.
- The Graphics deadlock regression now asserts the bounded five-second
completion result before awaiting the scaling task.
- The CarouselView category passes 6 consecutive MacCatalyst runs at 4/4
each and passes 4/4 on iOS 26 with the final 100 ms cleanup wait.
- The Android modal-animation leak test passes in both discovered
Android variants, while the iOS device-test assembly excludes that
Android-specific regression test.
- The Issue22306 Android failure's three retries were byte-for-byte
identical at a 1.85% visual difference, below the new Android-only 2%
tolerance.
- The unloaded-page alert probe now signals immediately after
`DisplayAlertAsync` returns, avoiding a teardown-order dependency on the
detached page task.
- Rebased the aggregate onto release head `dee83edd121`; the resulting
diff remains limited to tests and test infrastructure.
- The Pester workflow now triggers when
`eng/scripts/Set-ScreenResolution.ps1` changes.
- A standalone `/azp run` was posted for aggregate head `83da465424b`;
exact merge `bad9e4e9a57` builds `1539860`, `1539861`, and `1539862` are
required before merge.

### Issues Fixed

Contributes to stabilizing the .NET 11 Preview 7 test branch.

---------

Co-authored-by: Vally Fixture <vally-fixture@example.invalid>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: kubaflo <34349119+kubaflo@users.noreply.github.com>
Copilot-Session: 9be49656-7117-4235-9d96-404779ab6b16
Copilot-Session: d00747b7-96f3-4e7a-8dfb-e3a48db04b2d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants