Skip to content

Fix FlexLayout measuring items wider than their arranged size - #36416

Merged
kubaflo merged 4 commits into
dotnet:inflight/currentfrom
Kas-code:fix-27520-flexlayout-measure-width
Jul 9, 2026
Merged

kubaflo merged 4 commits into
dotnet:inflight/currentfrom
Kas-code:fix-27520-flexlayout-measure-width

Conversation

@Kas-code

@Kas-code Kas-code commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

FlexLayout's SelfSizing callback measured items using GetConstraints(), which returns the flex container's full size and ignores the item's own margins. The flex engine then arranges the item at the stretched cross-axis size (container minus margins), which is narrower. Wrapping content (e.g. Label text with LineBreakMode=WordWrap) wraps against a width the item never receives, and since the arrange pass never re-measures, the overflow line is cut off.

The engine already passes the correct available size into the callback (the ref w/h parameters); clamp the measure constraints with those values when they are known.

Fixes #27520

Manual testing: See the test file I added in 27520. I have manually tested over 100 repetitions of re-clicking the button to generate new labels and not been able to reproduce the isssue. Previously, around 1 in every 5 re-draws would reproduce the issue.

FlexLayout's SelfSizing callback measured items using GetConstraints(),
which returns the flex container's full size and ignores the item's own
margins. The flex engine then arranges the item at the stretched
cross-axis size (container minus margins), which is narrower. Wrapping
content (e.g. Label text with LineBreakMode=WordWrap) wraps against a
width the item never receives, and since the arrange pass never
re-measures, the overflow line is cut off.

The engine already passes the correct available size into the callback
(the ref w/h parameters); clamp the measure constraints with those
values when they are known.

Fixes dotnet#27520

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Kas-code
Kas-code had a problem deploying to copilot-pat-pool July 6, 2026 21:20 — with GitHub Actions Failure
@github-actions

github-actions Bot commented Jul 6, 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 -- 36416

Or

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

@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Jul 6, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hey there @@Kas-code! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hey there @Kas-code! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@Kas-code

Kas-code commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

@dotnet-policy-service agree

@jfversluis

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Jul 7, 2026

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Expert Review — 1 findings

See inline comments for details.

// size, which can be wider than the frame the item will actually receive;
// text measured against the wider constraint wraps at a width it will
// never have at arrange time, and the last line ends up cut off.
if (!float.IsNaN(w) && w > 0 && w < sizeConstraints.Width)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🔍 AI-Generated Review (multi-model)

[major] Layout Measure-Arrange Correctness — w/h are not always the final arranged size. In the main axis they can be the pre-flex basis (for example a Row child with WidthRequest=100 and Grow=1 in a 300-wide FlexLayout), and layout_items later adds the grow space to arrange it at 300. Clamping the measure constraint to 100 makes wrapping content compute its cross-axis size for the wrong width, leaving the row too tall (or stale when shrink applies). Please only apply this clamp to the cross axis when stretch has already produced the final frame size, or add coverage for grow/shrink main-axis cases.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch — the main-axis value at the time the SelfSizing callback runs is indeed the pre-flex basis (the explicit size, or 0), and layout_items distributes grow/shrink space after the callback returns. So a child with WidthRequest=100 and Grow=1 in a 300-wide Row would have been measured at 100 but arranged at 300.

Fixed by making the clamp direction-aware: it now applies only to the cross axis (width for Column/ColumnReverse, height for Row/RowReverse), which is the axis the reported bug (#27520) is about. The main axis keeps the previous GetConstraints() behavior. Also added a regression test for the grow scenario you described (GrowingItemMainAxisMeasureConstraintIsNotClampedToBasis_Issue27520) — it fails against the previous revision of this PR.

One note on scoping: I didn't gate the cross-axis clamp on the alignment being Stretch. For non-stretch alignments the item is arranged at its own measured size, so the engine-provided cross-axis value (container minus the item's margins) is still a valid upper bound for the measure constraint — and tighter than the full container size used before. Wrap mode is unaffected, since the cross-axis value is NaN at that point and the clamp is skipped.

@MauiBot MauiBot added s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) labels Jul 7, 2026
MauiBot

This comment was marked as outdated.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Jul 7, 2026

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

Could you please check the suggestions?

@Kas-code

Kas-code commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

I have made the suggested change and re-tested. Fix is still working.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Jul 7, 2026
MauiBot

This comment was marked as outdated.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Jul 7, 2026
@Kas-code

Kas-code commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

@kubaflo thanks for reviewing. I'm not sure if the last AI review came back with any suggested changes. Anything more for me to do on this or is it all good now?

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Jul 8, 2026
An item can never be arranged larger than its container minus its own
margins; grow and shrink only redistribute space within those bounds.
Previously only the cross axis was clamped (to the engine-provided
stretch size), so in Direction=Row an item with horizontal margins was
still measured at the full container width from GetConstraints() and
then shrunk before arrange, letting wrapping content wrap against a
width it never receives.

Subtract the item's margins from both container-derived constraints
before applying the cross-axis clamp. Adds the reviewer's regression
test for the Row shrink case.
@github-actions github-actions Bot added the s/agent-ready-for-rerun AI review has a new PR-author comment or commit and is ready for rerun label Jul 8, 2026
@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added s/agent-review-in-progress AI review is currently running for this PR and removed s/agent-ready-for-rerun AI review has a new PR-author comment or commit and is ready for rerun labels Jul 8, 2026

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Expert Review — 2 findings

See inline comments for details.

// margins first...
if (!double.IsPositiveInfinity(sizeConstraints.Width))
{
sizeConstraints.Width = Math.Max(0, sizeConstraints.Width - (it.MarginLeft + it.MarginRight));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🔍 AI-Generated Review (multi-model)

[major] Layout Measure-Arrange Correctness — child.Measure(...) already subtracts the child margin for normal controls via VisualElement.MeasureOverride → LayoutExtensions.ComputeDesiredSize before it calls the handler. Pre-subtracting it.MarginLeft + it.MarginRight here means a real Label/Button with Margin=10 in a 400-wide FlexLayout is measured by its handler at 360 instead of the 380 width it will occupy after FlexLayout applies margins. That makes wrapping content wrap too early/leave blank space. The fix should clamp FlexLayout against the space the child will occupy without also pre-subtracting the margin before calling Measure, or otherwise avoid double-applying the same margin for handler-backed controls.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The premise here isn't quite right: with Margin=10 in a 400-wide FlexLayout, the child does not occupy 380 — it occupies 360. FlexLayout passes the engine-computed frame (already reduced to 380 by the engine's margin handling) directly to child.Arrange, and Arrange bounds are margin-inclusive by convention, so ComputeFrame subtracts the margin again — the content frame comes out at 360. That double application at arrange is long-standing FlexLayout behavior (the engine also offsets the position by the margin, which is why flex children have always sat at 2× their margin offset), and changing it would visibly shift every existing FlexLayout layout, so this PR doesn't touch it.

Given that, the measure path in this PR is symmetric with arrange, not double-subtracting: Measure(400 − 20 = 380) → ComputeDesiredSize subtracts the margin → the handler measures at 360, which is exactly the content width it is arranged into. Without the pre-subtraction the handler would measure at 380 but be arranged into 360 — which is the bug this PR fixes.

I've added a handler-backed regression test (HandlerBackedItemWithMarginIsMeasuredAtArrangedWidth_Issue27520, Column + Row) that exercises the real ComputeDesiredSize path with a mocked IViewHandler and asserts the handler's measure width equals the arranged Frame.Width (360 == 360), and a comment at the fix site documenting the measure/arrange symmetry.

public double MeasuredWidthConstraint { get; private set; } = double.NaN;
public double MeasuredHeightConstraint { get; private set; } = double.NaN;

protected override Size MeasureOverride(double widthConstraint, double heightConstraint)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🔍 AI-Generated Review (multi-model)

[major] Regression Prevention and Test Coverage — This test double overrides MeasureOverride, so it bypasses the production path where VisualElement.MeasureOverride calls LayoutExtensions.ComputeDesiredSize and subtracts view.Margin before invoking the handler. As a result, the new margin tests pass even though handler-backed controls such as Label/Button now have their margin subtracted once in FlexLayout and once again in ComputeDesiredSize. Please add at least one regression using a handler-backed control or mock IViewHandler.GetDesiredSize so the test exercises the real margin-subtraction path.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point — added. HandlerBackedItemWithMarginIsMeasuredAtArrangedWidth_Issue27520 is a [Theory] over Column and Row using a plain View with a mocked IViewHandler (Substitute.For), so measurement flows through the production VisualElement.MeasureOverride → LayoutExtensions.ComputeDesiredSize path, including its margin subtraction. It asserts the width the handler is asked to measure at equals the Frame.Width the view is arranged into (360 for a 400 container with Margin=10: 400 − flex item margin 20 − ComputeDesiredSize margin 20, matching arrange's engine frame 380 − ComputeFrame margin 20). There's no double-subtraction discrepancy for handler-backed controls — measure and arrange agree, which this test now locks in.

The earlier margin tests overrode MeasureOverride directly, bypassing
LayoutExtensions.ComputeDesiredSize, so they did not prove the fix is
correct for handler-backed controls. This test uses a plain View with a
mocked IViewHandler, exercising the production path where the margin is
subtracted from the constraint before the handler measures.

The two margin subtractions are symmetric, not double-applied: at
measure the constraint is container minus the flex item margin, and
ComputeDesiredSize subtracts the margin again before the platform
measures; at arrange the engine frame already excludes the margin and
ComputeFrame subtracts it once more from the bounds. The platform
control is measured at exactly the content width it is arranged into
(400 - 20 - 20 = 360 both ways). Also documents this symmetry at the
constraint-tightening site.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AI Review Summary

@Kas-code — new AI review results are available based on this last commit: 906d852. To request a fresh review after new comments or commits, comment /review rerun.

Gate Passed Confidence Low Platform Android


🗂️ Review Sessions — click to expand
🚦 Gate — Test Before & After Fix

Gate Result: ✅ PASSED

Platform: ANDROID · Base: main · Merge base: 19741e9a

Test Without Fix (expect FAIL) With Fix (expect PASS)
🧪 FlexLayoutTests FlexLayoutTests ✅ FAIL — 145s ✅ PASS — 119s
🔴 Without fix — 🧪 FlexLayoutTests: FAIL ✅ · 145s
  Determining projects to restore...
  Restored /home/vsts/work/1/s/src/TestUtils/src/TestUtils/TestUtils.csproj (in 3.83 sec).
  Restored /home/vsts/work/1/s/src/Graphics/src/Graphics/Graphics.csproj (in 192 ms).
  Restored /home/vsts/work/1/s/src/Essentials/src/Essentials.csproj (in 2.62 sec).
  Restored /home/vsts/work/1/s/src/Core/src/Core.csproj (in 809 ms).
  Restored /home/vsts/work/1/s/src/Core/maps/src/Maps.csproj (in 9.49 sec).
  Restored /home/vsts/work/1/s/src/Controls/src/Xaml/Controls.Xaml.csproj (in 52 ms).
  Restored /home/vsts/work/1/s/src/Controls/src/Core/Controls.Core.csproj (in 26 ms).
  Restored /home/vsts/work/1/s/src/Controls/Maps/src/Controls.Maps.csproj (in 26 ms).
  Restored /home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj (in 1.25 sec).
  1 of 10 projects are up-to-date for restore.
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14599224
  Graphics -> /home/vsts/work/1/s/artifacts/bin/Graphics/Debug/net10.0/Microsoft.Maui.Graphics.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14599224
  Essentials -> /home/vsts/work/1/s/artifacts/bin/Essentials/Debug/net10.0/Microsoft.Maui.Essentials.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14599224
  Core -> /home/vsts/work/1/s/artifacts/bin/Core/Debug/net10.0/Microsoft.Maui.dll
  Controls.BindingSourceGen -> /home/vsts/work/1/s/artifacts/bin/Controls.BindingSourceGen/Debug/netstandard2.0/Microsoft.Maui.Controls.BindingSourceGen.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14599224
  Maps -> /home/vsts/work/1/s/artifacts/bin/Maps/Debug/net10.0/Microsoft.Maui.Maps.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14599224
  Controls.Core -> /home/vsts/work/1/s/artifacts/bin/Controls.Core/Debug/net10.0/Microsoft.Maui.Controls.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14599224
  Controls.Xaml -> /home/vsts/work/1/s/artifacts/bin/Controls.Xaml/Debug/net10.0/Microsoft.Maui.Controls.Xaml.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14599224
  Controls.Maps -> /home/vsts/work/1/s/artifacts/bin/Controls.Maps/Debug/net10.0/Microsoft.Maui.Controls.Maps.dll
  TestUtils -> /home/vsts/work/1/s/artifacts/bin/TestUtils/Debug/netstandard2.0/Microsoft.Maui.TestUtils.dll
  Controls.Core.UnitTests -> /home/vsts/work/1/s/artifacts/bin/Controls.Core.UnitTests/Debug/net10.0/Microsoft.Maui.Controls.Core.UnitTests.dll
Test run for /home/vsts/work/1/s/artifacts/bin/Controls.Core.UnitTests/Debug/net10.0/Microsoft.Maui.Controls.Core.UnitTests.dll (.NETCoreApp,Version=v10.0)
VSTest version 18.0.1 (x64)

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.8.2+699d445a1a (64-bit .NET 10.0.0)
[xUnit.net 00:00:00.24]   Discovering: Microsoft.Maui.Controls.Core.UnitTests
[xUnit.net 00:00:02.30]   Discovered:  Microsoft.Maui.Controls.Core.UnitTests
[xUnit.net 00:00:02.34]   Starting:    Microsoft.Maui.Controls.Core.UnitTests
[xUnit.net 00:00:02.55]       Assert.Equal() Failure: Values differ
[xUnit.net 00:00:02.55]       Expected: 380
[xUnit.net 00:00:02.55]       Actual:   400
[xUnit.net 00:00:02.55]       Stack Trace:
[xUnit.net 00:00:02.55]         /_/src/Controls/tests/Core.UnitTests/Layouts/FlexLayoutTests.cs(467,0): at Microsoft.Maui.Controls.Core.UnitTests.Layouts.FlexLayoutTests.StretchedItemWithMarginIsMeasuredAtArrangedHeight_Issue27520()
[xUnit.net 00:00:02.55]            at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
[xUnit.net 00:00:02.55]            at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
[xUnit.net 00:00:02.54]     StretchedItemWithMarginIsMeasuredAtArrangedHeight_Issue27520 [FAIL]
[xUnit.net 00:00:02.68]       Assert.Equal() Failure: Values differ
[xUnit.net 00:00:02.68]     StretchedItemWithMarginIsMeasuredAtArrangedWidth_Issue27520 [FAIL]
[xUnit.net 00:00:02.68]       Expected: 380
[xUnit.net 00:00:02.68]       Actual:   400
[xUnit.net 00:00:02.68]       Stack Trace:
[xUnit.net 00:00:02.68]         /_/src/Controls/tests/Core.UnitTests/Layouts/FlexLayoutTests.cs(442,0): at Microsoft.Maui.Controls.Core.UnitTests.Layouts.FlexLayoutTests.StretchedItemWithMarginIsMeasuredAtArrangedWidth_Issue27520()
[xUnit.net 00:00:02.68]            at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
[xUnit.net 00:00:02.68]            at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
  Passed GrowItemsPreserveNaturalSizeAndDistributeFreeSpaceEqually_Issue34464 [92 ms]
  Passed FlexLayoutRecognizesVisibilityChange [13 ms]
  Failed StretchedItemWithMarginIsMeasuredAtArrangedHeight_Issue27520 [4 ms]
  Error Message:
   Assert.Equal() Failure: Values differ
Expected: 380
Actual:   400
  Stack Trace:
     at Microsoft.Maui.Controls.Core.UnitTests.Layouts.FlexLayoutTests.StretchedItemWithMarginIsMeasuredAtArrangedHeight_Issue27520() in /_/src/Controls/tests/Core.UnitTests/Layouts/FlexLayoutTests.cs:line 467
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
  Passed UnconstrainedWidthChildrenHaveWidth [135 ms]
  Passed UnconstrainedMeasureHonorsFlexDirection(widthConstraint: Infinity, heightConstraint: 400, flexDirection: RowReverse) [2 ms]
  Passed UnconstrainedMeasureHonorsFlexDirection(widthConstraint: 400, heightConstraint: Infinity, flexDirection: ColumnReverse) [< 1 ms]
  Passed UnconstrainedMeasureHonorsFlexDirection(widthConstraint: Infinity, heightConstraint: 400, flexDirection: Row) [< 1 ms]
  Passed UnconstrainedMeasureHonorsFlexDirection(widthConstraint: 400, heightConstraint: Infinity, flexDirection: Column) [< 1 ms]
  Failed StretchedItemWithMarginIsMeasuredAtArrangedWidth_Issue27520 [< 1 ms]
  Error Message:
   Assert.Equal() Failure: Values differ
Expected: 380
Actual:   400
  Stack Trace:
     at Microsoft.Maui.Controls.Core.UnitTests.Layouts.FlexLayoutTests.StretchedItemWithMarginIsMeasuredAtArrangedWidth_Issue27520() in /_/src/Controls/tests/Core.UnitTests/Layouts/FlexLayoutTests.cs:line 442
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
[xUnit.net 00:00:02.71]       Assert.Equal() Failure: Values differ
[xUnit.net 00:00:02.71]       Expected: 380
[xUnit.net 00:00:02.71]       Actual:   400
[xUnit.net 00:00:02.71]       Stack Trace:
[xUnit.net 00:00:02.71]         /_/src/Controls/tests/Core.UnitTests/Layouts/FlexLayoutTests.cs(532,0): at Microsoft.Maui.Controls.Core.UnitTests.Layouts.FlexLayoutTests.ShrunkRowItemWithMarginIsMeasuredAtArrangedWidth_Issue27520()
[xUnit.net 00:00:02.71]            at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
[xUnit.net 00:00:02.71]            at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
  Passed FlexLayoutPaddingShouldBeAppliedCorrectly_ColumnDirection [3 ms]
  Passed ArrangeOnlyPassUsesUpdatedWidthRequest [4 ms]
  Passed FlexLayoutMeasuresImagesUnconstrained [2 ms]
  Passed UnconstrainedHeightChildrenHaveHeight [< 1 ms]
  Passed ArrangeOnlyPassFallsBackToDesiredSizeWhenWidthRequestCleared [< 1 ms]
  Passed GrowingItemMainAxisMeasureConstraintIsNotClampedToBasis_Issue27520 [2 ms]
  Failed ShrunkRowItemWithMarginIsMeasuredAtArrangedWidth_Issue27520 [2 ms]
  Error Message:
   Assert.Equal() Failure: Values differ
Expected: 380
Actual:   400
  Stack Trace:
     at Microsoft.Maui.Controls.Core.UnitTests.Layouts.FlexLayoutTests.ShrunkRowItemWithMarginIsMeasuredAtArrangedWidth_Issue27520() in /_/src/Controls/tests/Core.UnitTests/Layouts/FlexLayoutTests.cs:line 532
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
  Passed FlexLayoutPaddingShouldBeAppliedCorrectly_RowDirection [2 ms]
  Passed ArrangeOnlyPassUsesDesiredSizeWhenNoWidthRequest [< 1 ms]
[xUnit.net 00:00:02.72]   Finished:    Microsoft.Maui.Controls.Core.UnitTests
[xUnit.net 00:00:02.71]     ShrunkRowItemWithMarginIsMeasuredAtArrangedWidth_Issue27520 [FAIL]
  Passed ArrangeOnlyPassUsesUpdatedHeightRequest [< 1 ms]

Test Run Failed.
Total tests: 19
     Passed: 16
     Failed: 3
 Total time: 3.5803 Seconds

🟢 With fix — 🧪 FlexLayoutTests: PASS ✅ · 119s
  Determining projects to restore...
  All projects are up-to-date for restore.
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14599224
  Graphics -> /home/vsts/work/1/s/artifacts/bin/Graphics/Debug/net10.0/Microsoft.Maui.Graphics.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14599224
  Essentials -> /home/vsts/work/1/s/artifacts/bin/Essentials/Debug/net10.0/Microsoft.Maui.Essentials.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14599224
  Core -> /home/vsts/work/1/s/artifacts/bin/Core/Debug/net10.0/Microsoft.Maui.dll
  Controls.BindingSourceGen -> /home/vsts/work/1/s/artifacts/bin/Controls.BindingSourceGen/Debug/netstandard2.0/Microsoft.Maui.Controls.BindingSourceGen.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14599224
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14599224
  Controls.Core -> /home/vsts/work/1/s/artifacts/bin/Controls.Core/Debug/net10.0/Microsoft.Maui.Controls.dll
  Maps -> /home/vsts/work/1/s/artifacts/bin/Maps/Debug/net10.0/Microsoft.Maui.Maps.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14599224
  Controls.Xaml -> /home/vsts/work/1/s/artifacts/bin/Controls.Xaml/Debug/net10.0/Microsoft.Maui.Controls.Xaml.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14599224
  Controls.Maps -> /home/vsts/work/1/s/artifacts/bin/Controls.Maps/Debug/net10.0/Microsoft.Maui.Controls.Maps.dll
  TestUtils -> /home/vsts/work/1/s/artifacts/bin/TestUtils/Debug/netstandard2.0/Microsoft.Maui.TestUtils.dll
  Controls.Core.UnitTests -> /home/vsts/work/1/s/artifacts/bin/Controls.Core.UnitTests/Debug/net10.0/Microsoft.Maui.Controls.Core.UnitTests.dll
Test run for /home/vsts/work/1/s/artifacts/bin/Controls.Core.UnitTests/Debug/net10.0/Microsoft.Maui.Controls.Core.UnitTests.dll (.NETCoreApp,Version=v10.0)
VSTest version 18.0.1 (x64)

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:00.01] xUnit.net VSTest Adapter v2.8.2+699d445a1a (64-bit .NET 10.0.0)
[xUnit.net 00:00:00.45]   Discovering: Microsoft.Maui.Controls.Core.UnitTests
[xUnit.net 00:00:02.42]   Discovered:  Microsoft.Maui.Controls.Core.UnitTests
[xUnit.net 00:00:02.45]   Starting:    Microsoft.Maui.Controls.Core.UnitTests
  Passed GrowItemsPreserveNaturalSizeAndDistributeFreeSpaceEqually_Issue34464 [101 ms]
  Passed FlexLayoutRecognizesVisibilityChange [24 ms]
  Passed StretchedItemWithMarginIsMeasuredAtArrangedHeight_Issue27520 [4 ms]
  Passed UnconstrainedWidthChildrenHaveWidth [127 ms]
  Passed UnconstrainedMeasureHonorsFlexDirection(widthConstraint: Infinity, heightConstraint: 400, flexDirection: RowReverse) [2 ms]
  Passed UnconstrainedMeasureHonorsFlexDirection(widthConstraint: 400, heightConstraint: Infinity, flexDirection: ColumnReverse) [< 1 ms]
  Passed UnconstrainedMeasureHonorsFlexDirection(widthConstraint: Infinity, heightConstraint: 400, flexDirection: Row) [< 1 ms]
  Passed UnconstrainedMeasureHonorsFlexDirection(widthConstraint: 400, heightConstraint: Infinity, flexDirection: Column) [< 1 ms]
  Passed StretchedItemWithMarginIsMeasuredAtArrangedWidth_Issue27520 [< 1 ms]
  Passed FlexLayoutPaddingShouldBeAppliedCorrectly_ColumnDirection [1 ms]
  Passed ArrangeOnlyPassUsesUpdatedWidthRequest [3 ms]
  Passed FlexLayoutMeasuresImagesUnconstrained [1 ms]
  Passed UnconstrainedHeightChildrenHaveHeight [< 1 ms]
  Passed ArrangeOnlyPassFallsBackToDesiredSizeWhenWidthRequestCleared [2 ms]
  Passed GrowingItemMainAxisMeasureConstraintIsNotClampedToBasis_Issue27520 [< 1 ms]
  Passed ShrunkRowItemWithMarginIsMeasuredAtArrangedWidth_Issue27520 [< 1 ms]
  Passed FlexLayoutPaddingShouldBeAppliedCorrectly_RowDirection [2 ms]
  Passed ArrangeOnlyPassUsesDesiredSizeWhenNoWidthRequest [< 1 ms]
[xUnit.net 00:00:02.83]   Finished:    Microsoft.Maui.Controls.Core.UnitTests
  Passed ArrangeOnlyPassUsesUpdatedHeightRequest [< 1 ms]

Test Run Successful.
Total tests: 19
     Passed: 19
 Total time: 3.6210 Seconds

📁 Fix files reverted (1 files)
  • src/Controls/src/Core/Layout/FlexLayout.cs

📱 UI Tests — Label,Layout

Detected UI test categories: Label,Layout

[!WARNING]
No UI test results were produced for the detected categories. The platform-pool run
returned no results — most often because the PR build failed (see the Gate section) or
the deep UI test stage was skipped. Fix the build/gate issues and comment /review rerun
to get UI test results.


📋 Pre-Flight — Context & Validation

Issue: #27520 - LineBreakMode="WordWrap" sometimes cuts off the last word
PR: #36416 - Fix FlexLayout measuring items wider than their arranged size
Platforms Affected: Android, iOS (shared FlexLayout code)
Files Changed: 1 implementation, 1 test

Key Findings

  • Issue #27520 reports wrapped Label/FormattedText content inside FlexLayout sometimes losing the last word/line on Android and iOS because text wraps against a wider measured width than the width ultimately arranged.
  • PR #36416 changes src/Controls/src/Core/Layout/FlexLayout.cs so non-image child measurement constraints are tightened by margins and cross-axis final callback dimensions, then adds unit regression tests in FlexLayoutTests.cs for stretched column, stretched row, row grow, and row shrink with margins.
  • Prior inline review concerns were addressed in the current diff: main-axis grow is no longer clamped to pre-flex basis, and row main-axis shrink with margins is now covered.
  • gh authentication is unavailable in this environment; PR/issue metadata was gathered from public GitHub API and local checked-out diff.

Code Review Summary

Verdict: NEEDS_DISCUSSION
Confidence: low
Errors: 0 | Warnings: 0 | Suggestions: 1

Key code review findings:

  • ℹ src/Controls/tests/Core.UnitTests/Layouts/FlexLayoutTests.cs:410 / :505 — Consider adding a handler-backed margin regression because current tests validate the outer IView.Measure constraint path rather than a normal Label handler path.
  • Failure modes probed: margined stretched Column/Row children, Row grow with WidthRequest, Row shrink with horizontal margins, Image special case, infinity/zero constraints, and arrange-only behavior.
  • Blast radius: every non-nested FlexLayout child measurement; hot path but no added allocations, no startup path, no static state.

Fix Candidates

# Source Approach Test Result Files Changed Notes
PR PR #36416 Tighten finite FlexLayout child measure constraints by the child margins, then clamp only the cross-axis callback dimension when known. ✅ PASSED (Gate) FlexLayout.cs, FlexLayoutTests.cs Original PR; gate already verified fail-without-fix/pass-with-fix.

🔬 Code Review — Deep Analysis

Code Review — PR #36416

Independent Assessment

What this changes: FlexLayout now tightens child measure constraints by the child’s margins before measuring, and only clamps the known w/h callback value on the cross axis to avoid main-axis grow/shrink basis regressions.
Inferred motivation: Prevent wrapping content from measuring against a size larger than the one it receives during arrange.

Reconciliation with PR Narrative

Author claims: Fixes Label word-wrap clipping where FlexLayout measured against full container size while arranging with margins applied.
Agreement/disagreement: The implementation matches that claim. It also incorporates prior feedback for main-axis grow and row shrink cases.

Prior Review Reconciliation

Prior ❌ Error Finding Source Status Evidence
Main-axis w/h clamp could use pre-flex basis and break grow/shrink MauiBot [major] inline review ✅ Fixed Current code only applies w/h clamp on cross axis (FlexLayout.cs:553-563) and adds GrowingItemMainAxisMeasureConstraintIsNotClampedToBasis_Issue27520.
Row main-axis shrink with horizontal margins still measured too wide jfversluis inline review ✅ Fixed Current code first subtracts margins from both finite constraints (FlexLayout.cs:538-546) and adds ShrunkRowItemWithMarginIsMeasuredAtArrangedWidth_Issue27520.

Blast Radius Assessment

  • Runs for all instances: yes — every non-nested FlexLayout child measurement.
  • Startup impact: no.
  • Static/shared state: no.
  • Hot path: yes — layout measure; added work is scalar arithmetic/comparisons with no allocations beyond existing code.

CI Status

  • Required-check result: undetermined/pending.
  • Classification: undetermined.
  • Action taken: gh pr checks --required failed because gh is unauthenticated. Public GitHub check-runs show combined status pending and Build Analysis in progress for head a55888a. Invoked azdo-build-investigator; ci-analysis was unavailable in this environment. Confidence capped low. Local targeted validation: dotnet test ... --filter FullyQualifiedName~FlexLayoutTests --no-restore passed, 19/19.

Findings

No ❌ Error or ⚠️ Warning findings.

💡 Suggestion — Add one handler-backed margin regression

The new tests in FlexLayoutTests.cs:410 and FlexLayoutTests.cs:505 override MeasureOverride, so they validate FlexLayout’s outer IView.Measure constraint but not the normal VisualElement -> ComputeDesiredSize -> Handler.GetDesiredSize margin path. The current fix appears correct, but a mock handler-backed view would more directly cover the reported Label/wrapping production path.

Failure-Mode Probing

  • Margined stretched Column child: finite width constraint becomes container minus margins, then cross-axis w can further clamp; measure and flex frame stay consistent.
  • Row grow with WidthRequest: main-axis w is not used for clamping, so grow can still expand beyond basis.
  • Row shrink with horizontal margins: margin tightening now bounds width even when the main-axis w clamp is intentionally skipped.
  • Images: existing Image special case still resets constraints to infinity after the new tightening.
  • Infinite constraints: positive infinity is preserved; zero measure-hack conversion remains unchanged.
  • Arrange-only pass: unchanged; no new measure occurs outside measure mode.

Verdict: NEEDS_DISCUSSION

Confidence: low
Summary: The code is targeted and I found no blocking correctness issue. However, required CI could not be verified and public status is still pending, so this cannot be LGTM under the skill rules.


🛠️ Fix — Analysis & Comparison

Fix Candidates

# Source Approach Test Result Files Changed Notes
1 try-fix Move margin subtraction into FlexExtensions.GetConstraints() so all self-sizing callers get margin-aware constraints. ✅ PASS FlexExtensions.cs Passes targeted tests, but broadens helper semantics and affects legacy FlexLayout callers; not demonstrably better than PR.
2 try-fix Keep callback-local margin tightening and allow main-axis callback clamping only when grow/shrink cannot later change that axis. ✅ PASS FlexLayout.cs Passes targeted tests, but more complex than PR and relies on grow/shrink stability assumptions.
PR PR #36416 Tighten finite FlexLayout child measure constraints by margins, then clamp only known cross-axis callback dimensions. ✅ PASSED (Gate) FlexLayout.cs, FlexLayoutTests.cs Original PR; gate already verified fail-without-fix/pass-with-fix. Narrowest passing fix.

Cross-Pollination

Model Round New Ideas? Details
gpt-5.5 1 Yes Helper-level margin-aware constraints; tested as Candidate 1 and passed, but blast radius is broader.
gpt-5.5 1 Yes Flex-aware main-axis clamp for non-flexing items; tested as Candidate 2 and passed, but complexity/risk is higher.
maui-expert-reviewer 2 No Only remaining distinct approach would be a broader two-pass Flex engine remeasure/relayout. It is not preferable because it adds a second measure/layout pass in a hot path and increases oscillation risk.

Exhausted: Yes
Selected Fix: PR #36416 — It passes the gate and targeted regression tests while remaining more localized and easier to reason about than both passing alternatives. Candidate 1 is broader; Candidate 2 is more complex; the expert reviewer rejected a third engine-level approach as higher-risk.


🏁 Report — Final Recommendation

Comparative Candidate Report — PR #36416

Candidate ranking

Rank Candidate Regression result Assessment
1 pr-plus-reviewer ✅ Passed gate by inheritance from PR; adds reviewer-requested coverage hardening Best balance. Keeps the narrow PR implementation that passed the gate, avoids broader helper semantics, and incorporates the expert reviewer's actionable feedback by covering the handler-backed margin path.
2 pr ✅ Gate passed Narrowest submitted code fix and easier to reason about than the try-fix alternatives, but expert review found the tests do not exercise the normal handler-backed ComputeDesiredSize margin path.
3 try-fix-1 ✅ PASS Moves margin subtraction into FlexExtensions.GetConstraints(). This passed targeted tests but broadens helper semantics to every caller, including legacy/shared FlexLayout paths, without clear evidence that broader behavior is needed.
4 try-fix-2 ✅ PASS Keeps the fix localized but introduces flex-aware main-axis clamping for non-growing/non-shrinking items. It passed targeted tests, but the additional grow/shrink/basis assumptions are more complex and not necessary for the reported issue.

No candidate from STEP 5a was recorded as failing regression tests, so the mandatory failed-test demotion rule does not change the ranking. If a future handler-backed regression proves the expert reviewer's double-margin concern as a functional failure in the submitted implementation, pr and both margin-subtracting try-fix candidates should be re-ranked below any candidate that passes that production-path test.

Key comparison points

Correctness: pr and pr-plus-reviewer directly target the observed mismatch between measure constraints and final FlexLayout frame size. try-fix-1 solves the same mismatch at a helper level, increasing blast radius. try-fix-2 tries to improve main-axis tightness but depends on interpreting flex stability from Grow == 0 && Shrink == 0, which is riskier around basis/wrap behavior.

Test quality: The submitted PR tests cover the gate and important grow/shrink edge cases, but expert review correctly identified that the new constraint-recording test doubles bypass the usual handler-backed ComputeDesiredSize path. pr-plus-reviewer wins because it includes the same fix plus the missing production-path coverage.

Maintainability / blast radius: The PR-track implementation is localized to FlexLayout.SelfSizing. try-fix-1 changes shared helper semantics; try-fix-2 adds more conditional behavior in a hot layout path. The localized PR approach is preferable unless handler-backed coverage proves a code change is required.

Winner

Winning candidate: pr-plus-reviewer

pr-plus-reviewer preserves the narrow gate-passing PR fix while incorporating the expert reviewer's actionable feedback through handler-backed regression coverage. It is lower risk than both try-fix alternatives and stronger than the raw PR because it closes the test representativeness gap called out by expert review.


🧭 Next Steps — review latest findings

No alternative fix was selected for this run. Review the session findings and CI results before merging.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Jul 8, 2026
@kubaflo

kubaflo commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

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

@kubaflo

This comment has been minimized.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Tests Failure Analysis

@Kas-code — test-failure review results are available based on commit 906d852.
To request a fresh review after new comments, commits, or CI runs, comment /review tests.

Overall Not ready Failures 45 Baseline 2 on base Platform multi-platform

Test Failure Review: Not ready - click to expand

Overall verdict: Not ready

9 failures are deterministic regressions (green on the most recent base build, red on this PR), including 3 WinUI Shell navigation tests (ValidateOnNavigationToMethod, Issue59172Test, Issue59172RecoveryTest) with no ci-scan coverage. The remaining 36 unattributed failures are predominantly ci-scan-documented flakes demoted from regressions. Device tests passed cleanly with 0 failures across all 7 Helix jobs.

Coverage: 162 checks · 150 passing · 12 failing · 0 pending · 0 inaccessible · 1 unmapped · 22 unexplained build legs · 0 unaccounted failing checks · 2 aborted failing checks · 0 canceled-build checks · 0 device-test unverified · 36 unattributed · 9 regressed-vs-base. Deterministic ceiling: Not ready — 9 legs regressed vs base; 36 unattributed failures; 22 unexplained build legs; 2 aborted failing checks; 1 unmapped failing check.

Failure Verdict On base? Evidence
ValidateOnNavigationToMethod Likely PR-caused regressed deterministicAttribution = regressed-vs-base; leg green on base build 1499834, red on PR; 2 occurrences; System.TimeoutException: Timed out waiting for element in maui-pr-uitests WinUI UITests Controls Shell; no ci-scan match
Issue59172Test Likely PR-caused regressed deterministicAttribution = regressed-vs-base; 2 occurrences; System.TimeoutException: Timed out waiting for element; WinUI UITests Controls Shell; no ci-scan match
Issue59172RecoveryTest Likely PR-caused regressed deterministicAttribution = regressed-vs-base; 2 occurrences; System.TimeoutException: Timed out waiting for element; WinUI UITests Controls Shell; no ci-scan match
Publish the winui_ui_tests_controls test results - build error Likely PR-caused regressed deterministicAttribution = regressed-vs-base; ##[error]There are one or more test failures detected in result files; downstream of WinUI Shell test failures
PublishTestResults - build error (x3) Likely PR-caused regressed deterministicAttribution = regressed-vs-base; ##[error]No test result files matching; downstream of Provision JDK failure blocking 3 test run legs
Publish Logs - build error (x2) Likely PR-caused regressed deterministicAttribution = regressed-vs-base; ##[error]Path does not exist: .../artifacts/log/; downstream infrastructure failure
publish artifacts - build error Likely PR-caused regressed deterministicAttribution = regressed-vs-base; ##[error]File upload failed even after retry; macOS UI test artifact upload
maui-pr-uitests (macOS UITests Controls CollectionView) Needs human investigation — Aborted check (CANCELLED); no reliable result; job log
maui-pr-uitests (macOS UITests Controls Shell) Needs human investigation — Aborted check (CANCELLED); no reliable result; job log
Build Analysis Needs human investigation — Unmapped check; no inspectable AzDO build; Build Analysis docs
Provision JDK - MSB3073 (x2) Needs human investigation no indeterminate; ci-scan demoted from REGRESSED (#36196 recurring build-break/leg); brew install --cask microsoft-openjdk@17 exited with code 1; 2 occurrences on macOS
to find package 'platform-tools;35.0.2' (x2) Needs human investigation yes indeterminate; Android SDK provisioning noise; ci-scan #36381 recurring/leg; legBaselineResult = succeeded-on-base suppressed as env/infra (non-deterministic); avdmanager exited with an error status
LayoutShouldBeCorrectOnFirstNavigation (x2) Needs human investigation no indeterminate; VisualTestFailedException + System.TimeoutException; ci-scan #36381 recurring/leg; base outcome inconclusive
ShellPages_FlowDirectionRTL + NavEvents_ShellItemChanged_NavigatingEvent_SourceIsShellItemChanged + NavEvents_ShellItemChanged_NavigatedEvent_CurrentIsPage2PreviousIsMain + NavEvents_GoToAsyncAbsoluteRoute_NavigatingEvent_SourceIsShellItemChanged + NavEvents_GoToAsyncAbsoluteRoute_NavigatedEvent_SourceIsShellItemChanged (x5) Needs human investigation no indeterminate; ci-scan demoted from REGRESSED (#36419 recurring); System.TimeoutException / VisualTestFailedException in macOS UITests Controls Shell/Navigation
VerifyEditor* / EditorNoOverlapAfterRotateTo* (x22 tests) Needs human investigation no indeterminate; ci-scan demoted from REGRESSED (#35958 recurring/leg); System.TimeoutException / NullReferenceException in Android API-30 Editor UITests
Publish the android_ui_tests_controls_30 test results - build error + Publish the mac_ui_tests_controls test results - build error (x3) Needs human investigation no indeterminate; ##[error]There are one or more test failures detected in result files; base outcome inconclusive

Recommended action

Investigate the 3 WinUI Shell navigation tests (ValidateOnNavigationToMethod, Issue59172Test, Issue59172RecoveryTest) that are deterministic regressions with no ci-scan coverage; determine whether the FlexLayout measuring change affects Shell navigation layout on Windows. If they appear to be transient timeouts unrelated to the FlexLayout fix, request a re-run of maui-pr-uitests (WinUI UITests Controls Shell).

Evidence details

PR scope: 2 files changed (1 test file); area: Layout (FlexLayout). No platform labels set. Head: 906d852.

maui-pr build: 1500294 (failed, 16 failed timeline records). Base build: 1499266 (succeeded — 0 baseline failures; matching failures here are not pre-existing on maui-pr).

maui-pr-uitests build: 1500295 (failed, 30 failed timeline records). Base build: 1499834 (failed — 12 baseline failures; only the first 8 of 34 failed logs were inspected, so the baseline list may be incomplete).

maui-pr-devicetests build: 1500296 (succeeded). All 7 Helix jobs confirmed 0 failed work items: Android CoreCLR (890c279a), iOS Mono x2 (9c33317d, d572d2a2), Android Mono (413272b5), MacCatalyst Mono x2 (4af3d850, fadf889f), Windows (cc64ac52).

WinUI Shell regressions detail: ValidateOnNavigationToMethod, Issue59172Test, and Issue59172RecoveryTest each fail with System.TimeoutException : Timed out waiting for element in the WinUI UITests Controls Shell job. These test names do not appear in the 12-failure baseline extracted from base build 1499834. No ci-scan issue covers them for the main branch family.

ci-scan demotions (30 total): 22 Editor tests demoted by ci-scan #35958 (recurring/leg, Android API-30); 5 Shell/NavEvents tests demoted by #36419 (recurring, macOS); JDK provision demoted by #36196 (build-break/leg); Android SDK provision / LayoutShouldBeCorrectOnFirstNavigation demoted by #36381.

Aborted checks: macOS UITests Controls CollectionView and macOS UITests Controls Shell were CANCELLED; their logs should be reviewed to determine whether cancellation was infrastructure-driven or caused by a PR-related hang.

Unmapped check: Build Analysis has no accessible AzDO build; its details URL links to general Arcade documentation.

AzDO auth: Not authenticated; no test-run-level data available. Baseline for maui-pr-uitests is partial (8 of 34 failed logs inspected); baseline list may be incomplete.

@kubaflo
kubaflo changed the base branch from main to inflight/current July 9, 2026 11:32
@kubaflo
kubaflo merged commit d3b9f27 into dotnet:inflight/current Jul 9, 2026
150 of 162 checks passed
@github-actions github-actions Bot added this to the .NET 10 SR9 milestone Jul 9, 2026
kubaflo pushed a commit that referenced this pull request Jul 10, 2026
FlexLayout's SelfSizing callback measured items using GetConstraints(),
which returns the flex container's full size and ignores the item's own
margins. The flex engine then arranges the item at the stretched
cross-axis size (container minus margins), which is narrower. Wrapping
content (e.g. Label text with LineBreakMode=WordWrap) wraps against a
width the item never receives, and since the arrange pass never
re-measures, the overflow line is cut off.

The engine already passes the correct available size into the callback
(the ref w/h parameters); clamp the measure constraints with those
values when they are known.

Fixes #27520

Manual testing: See the test file I added in 27520. I have manually
tested over 100 repetitions of re-clicking the button to generate new
labels and not been able to reproduce the isssue. Previously, around 1
in every 5 re-draws would reproduce the issue.

---------
@kubaflo

kubaflo commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Tests Failure Analysis

🔍 AI-generated preview — improved Tests Failure Analysis based on commit 906d852.
Manual preview of the multi-build base-branch regression diff (#36533) — not an automated workflow run.

Overall Not ready Failures 48 Regressed vs base 4 Baseline 3 on base

Test Failure Review: Not ready - click to expand

Overall verdict: Not ready — but read the regressions with a grain of salt. Base sampling correctly targeted this PR's own base branch, inflight/current (a servicing branch — the multi-build diff works there too). Of 48 distinct failures, 4 legs regressed (green on every sampled base build, red here) — but none of them are FlexLayout tests, the area this PR changes. So they're either a side effect worth checking or flakes the base sampling didn't catch; 2 more failures are dismissed as pre-existing infra flakiness.

  • ✗ PR-related — navigation / issue-recovery legs (~4 legs): ValidateOnNavigationToMethod, Issue59172Test, Issue59172RecoveryTest, and a publish artifacts - build error are green on all recent inflight/current base builds and red here — but none touch FlexLayout measuring, so confirm whether the measure change has a side effect or these are newly-surfaced flakes.
  • ● Unrelated — provisioning / log-publish infra (~2 legs): Provision JDK - MSB3073 and Publish Logs - build error flake on the base branch too, so not this PR.
  • ℹ Uncertain — unexplained legs + 2 aborted checks (~23 legs): failed legs with no extractable test name (RunOniOS_MauiDebug ARM64, Controls Shell, Blazor macOS, …) plus two cancelled macOS UITest checks — can't be attributed either way.

Coverage: 163 checks · 151 passing · 12 failing · 0 pending · 1 unmapped · 23 unexplained build legs · 2 aborted · 0 device-test unverified · 44 unattributed · 4 regressed-vs-base. Deterministic ceiling: Not ready — 4 legs regressed vs base.

Builds (this PR): maui-pr 1500294 · maui-pr-uitests 1500295 · maui-pr-devicetests 1500296 (succeeded). Base sampling (inflight/current, ~5 recent builds per definition): maui-pr 1504787 · maui-pr-uitests 1504788 · maui-pr-devicetests 1504789.

Scope: community ✨ · FlexLayout. Base branch: inflight/current.

Recommended action

Confirm the 4 regressed-vs-base failure(s) flagged above are resolved before merging; the remaining failures reproduce on the base branch and are not caused by this PR.

kubaflo pushed a commit that referenced this pull request Jul 15, 2026
FlexLayout's SelfSizing callback measured items using GetConstraints(),
which returns the flex container's full size and ignores the item's own
margins. The flex engine then arranges the item at the stretched
cross-axis size (container minus margins), which is narrower. Wrapping
content (e.g. Label text with LineBreakMode=WordWrap) wraps against a
width the item never receives, and since the arrange pass never
re-measures, the overflow line is cut off.

The engine already passes the correct available size into the callback
(the ref w/h parameters); clamp the measure constraints with those
values when they are known.

Fixes #27520

Manual testing: See the test file I added in 27520. I have manually
tested over 100 repetitions of re-clicking the button to generate new
labels and not been able to reproduce the isssue. Previously, around 1
in every 5 re-draws would reproduce the issue.

---------
kubaflo pushed a commit that referenced this pull request Jul 22, 2026
FlexLayout's SelfSizing callback measured items using GetConstraints(),
which returns the flex container's full size and ignores the item's own
margins. The flex engine then arranges the item at the stretched
cross-axis size (container minus margins), which is narrower. Wrapping
content (e.g. Label text with LineBreakMode=WordWrap) wraps against a
width the item never receives, and since the arrange pass never
re-measures, the overflow line is cut off.

The engine already passes the correct available size into the callback
(the ref w/h parameters); clamp the measure constraints with those
values when they are known.

Fixes #27520

Manual testing: See the test file I added in 27520. I have manually
tested over 100 repetitions of re-clicking the button to generate new
labels and not been able to reproduce the isssue. Previously, around 1
in every 5 re-draws would reproduce the issue.

---------
kubaflo pushed a commit that referenced this pull request Jul 28, 2026
FlexLayout's SelfSizing callback measured items using GetConstraints(),
which returns the flex container's full size and ignores the item's own
margins. The flex engine then arranges the item at the stretched
cross-axis size (container minus margins), which is narrower. Wrapping
content (e.g. Label text with LineBreakMode=WordWrap) wraps against a
width the item never receives, and since the arrange pass never
re-measures, the overflow line is cut off.

The engine already passes the correct available size into the callback
(the ref w/h parameters); clamp the measure constraints with those
values when they are known.

Fixes #27520

Manual testing: See the test file I added in 27520. I have manually
tested over 100 repetitions of re-clicking the button to generate new
labels and not been able to reproduce the isssue. Previously, around 1
in every 5 re-draws would reproduce the issue.

---------
kubaflo pushed a commit that referenced this pull request Jul 29, 2026
FlexLayout's SelfSizing callback measured items using GetConstraints(),
which returns the flex container's full size and ignores the item's own
margins. The flex engine then arranges the item at the stretched
cross-axis size (container minus margins), which is narrower. Wrapping
content (e.g. Label text with LineBreakMode=WordWrap) wraps against a
width the item never receives, and since the arrange pass never
re-measures, the overflow line is cut off.

The engine already passes the correct available size into the callback
(the ref w/h parameters); clamp the measure constraints with those
values when they are known.

Fixes #27520

Manual testing: See the test file I added in 27520. I have manually
tested over 100 repetitions of re-clicking the button to generate new
labels and not been able to reproduce the isssue. Previously, around 1
in every 5 re-draws would reproduce the issue.

---------
kubaflo pushed a commit that referenced this pull request Aug 7, 2026
FlexLayout's SelfSizing callback measured items using GetConstraints(),
which returns the flex container's full size and ignores the item's own
margins. The flex engine then arranges the item at the stretched
cross-axis size (container minus margins), which is narrower. Wrapping
content (e.g. Label text with LineBreakMode=WordWrap) wraps against a
width the item never receives, and since the arrange pass never
re-measures, the overflow line is cut off.

The engine already passes the correct available size into the callback
(the ref w/h parameters); clamp the measure constraints with those
values when they are known.

Fixes #27520

Manual testing: See the test file I added in 27520. I have manually
tested over 100 repetitions of re-clicking the button to generate new
labels and not been able to reproduce the isssue. Previously, around 1
in every 5 re-draws would reproduce the issue.

---------
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 12, 2026
@github-actions github-actions Bot modified the milestones: .NET 10 SR9, .NET 10 SR11 Sep 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

community ✨ Community Contribution s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LineBreakMode="WordWrap" sometimes cuts off the last word

4 participants