Skip to content

[release/11.0.1xx-preview7] Fix Label UI test page recreation - #37043

Closed
kubaflo wants to merge 2 commits into
release/11.0.1xx-preview7from
kubaflo/fix-preview7-label-page-recreation
Closed

[release/11.0.1xx-preview7] Fix Label UI test page recreation#37043
kubaflo wants to merge 2 commits into
release/11.0.1xx-preview7from
kubaflo/fix-preview7-label-page-recreation

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 Label feature-matrix tests verify both subsequent property updates and initial mapper application by tapping the label and taking a second screenshot. The tap handler was re-running InitializeComponent() on the existing ContentPage, which left the Windows page layout shifted. The first screenshot passed, while the second screenshot failed and caused 17 cascading Label visual failures.

Recreate the LabelControlMainPage through the navigation stack instead. Clearing the old binding context still detaches the existing FormattedString, while the replacement page gets a clean name scope, toolbar, content tree, and handler lifecycle.

CI Evidence

In maui-pr-uitests build 1537359, VerifyLabelWithTextAndFontColor passed its first screenshot and failed the second screenshot after MainLabel_Tapped (LabelFeatureTests.cs:590). The resulting vertical layout shift then affected the remaining Label visual tests.

Testing

The existing Label feature-matrix UI tests cover this path by comparing screenshots before and after page 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 16:29
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool August 3, 2026 16:29 — with GitHub Actions Inactive
@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 -- 37043

Or

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

@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.

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 adjusts the Label feature-matrix HostApp page’s “recreate page” tap handler to rebuild LabelControlMainPage via the navigation stack (insert + pop) instead of re-running InitializeComponent() on the existing page instance, addressing layout shifts that can cascade into multiple Label visual test failures.

Changes:

  • Change the label tap handler to asynchronously replace the current page by inserting a new instance before it and popping the current page.
  • Preserve the existing BindingContext = null step to detach the old FormattedString before the page is replaced.

@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).

MainLabel_Tapped could be re-entered if the label was tapped again before the
first PopAsync completed, inserting multiple pages and popping the wrong one.
Add a per-instance guard so the page recreation runs at most once.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d00747b7-96f3-4e7a-8dfb-e3a48db04b2d
Copilot AI review requested due to automatic review settings August 3, 2026 17:01

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

@PureWeen PureWeen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adversarial review: no actionable findings

Three independent reviewers with adversarial consensus plus the MAUI domain specialist found no high-confidence correctness issues. The page replacement preserves the shared view-model state, returns the navigation stack to one page, rebuilds the XAML name scope/toolbar/query identifiers, detaches the old FormattedString through BindingContext = null, and leaves the popped page eligible for cleanup. The change is confined to the UI-test HostApp and does not alter shipping framework behavior.

The existing ordered Label screenshot tests exercise the recreation path before and after mapper application; their screenshot retry path covers the asynchronous pop transition. The earlier repeated-tap concern is resolved by the per-instance guard, with no unresolved prior review findings.

Discarded concerns: async void navigation failure handling and dedicated double-tap guard coverage were considered, but neither had a concrete new failure scenario in this test-only flow.

@kubaflo

kubaflo commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

/azp run maui-pr-uitests

@azure-pipelines

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

@kubaflo

kubaflo commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

CI verification found this change does not fix the intended failure yet, so please do not merge this revision. At current head c48d038493, WinUI Label in UI build 1537882 still failed the same 17 screenshot tests as preview7 build 1537359; 16/17 produced pixel-identical current images across the two builds (the remaining image differed by only 19 pixels). The evidence points to deterministic stale Windows baselines or the pending Preview 7 SDK pin alignment rather than page recreation. I am checking #37046 before replacing/closing this approach.

@kubaflo

kubaflo commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Closing this approach: the current head left the same 17 WinUI Label failures unchanged versus the preview7 base, and its Android Label shard introduced three deterministic formatted-text truncation snapshot failures on both attempts. The page-recreation change is therefore ineffective and adds regressions. PR #37046 remains the clean blessed-SDK comparison for deciding whether the WinUI baselines need updating.

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