You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Reduce FlexLayout per-pass allocations and redundant work - #40852
↑ Current focused Controls Flex tests pass 41/41 and Core Flex tests pass 61/61. ↑ The netstandard2.0 Core build passes with PublicApiType=Validate. ↑ Reentrant layout test validates the per-pass buffer lease; Opus 5.5 review found no issues in the wrapper. ↑ Benchmark comparison shows lower allocations in all eight cases. ↓ Benchmarks predate the modern-target range-check helper in this revision; timings are single-machine and show one multimodal case. ↓ No device or UI tests were run.
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!
Target Branch
This PR is for
Initial base
New features, API changes, or .NET 12 work (including .NET 12 fixes)
main
.NET 11 servicing fixes
net11, for review
Older servicing, release integration, infrastructure, or documentation
For .NET 11 fixes, only a maintainer retargets the approved PR to the active
inflight lane and merges it after CI validates that final base. Do not merge
individual fixes directly into net11; agents must not retarget or merge.
Description of Change
This is a .NET 12 layout performance change. It reduces per-pass work and allocations in the measured Controls FlexLayout scenarios. There are no public API changes.
1. Remove the unconstrained-measure hack (PrepareMeasureHack / RestoreValues)
Before layout, FlexLayout.Layout() set Shrink and AlignSelf on each child's flex item. It then immediately called EnsureFlexItemPropertiesUpdated(), which wrote the real attached values back over the same items, so the hack never had any effect.
It cost an extra loop and closure/list allocation on every unconstrained pass.
The two related entries are removed from maui-sc.aotprofile.txt.
2. Stable child ordering and reusable storage in Flex.cs
The old code ordered children with LINQ OrderBy, allocating on every pass when any child had a non-zero Order.
The new code packs each child into a long key, ((long)Order << 32) | (uint)index, then sorts keys with Array.Sort. This orders first by Order, then by insertion index, preserving stable order for equal values, including negative and extreme int values. If children are already in non-decreasing Order, sorting is skipped.
OrderedKeysBuffer encapsulates the backing array and active _count. It retains capacity when child count stays the same or shrinks, and grows only when count exceeds capacity. Sorting and index access use the active count, preventing spare capacity from being treated as valid keys.
Each layout pass leases the buffer from its Item and returns it in cleanup(item). A child's SelfSizing callback can re-enter layout; leasing prevents the nested pass from overwriting the outer pass's keys.
3. Skip redundant per-pass refresh of attached flex properties
For BindableObject children, attached-property change handlers (Order, Grow, Shrink, AlignSelf, Basis) already keep the Flex.Item in sync. EnsureFlexItemPropertiesUpdated no longer re-runs InitFlexProperties for them on every pass.
Children that aren't BindableObject still get the full refresh. UpdateItemProperties (margin, visibility, and similar) still runs for every child.
4. Standalone benchmark
Adds FlexLayoutPassBenchmarker to Core.Benchmarks using BenchmarkDotNet MemoryDiagnoser. It repeats measure and arrange passes on a wrapping FlexLayout with fixed-size children, with and without FlexLayout.Order. There are no performance assertions in unit tests.
Revisions compared: baseline Flex.cs and FlexLayout.cs from main at 62130d92cd20df7195efa051b0912679781c206b; measured after source revision 1179bf8bd1a38c14a5c6d95f500dd03cc93e2ca2. Current PR head is 65721113b9557f803cb39b17606b7df69b372691; it adds documented packed-key encoding and ArgumentOutOfRangeException guard helpers on .NET 8+ (with the equivalent existing check for netstandard), plus removes a baseline-passing characterization test. Those latest changes were not part of the timing run.
Layout:Wrap = FlexWrap.Wrap, 400 wide, fixed 20×20 children. Reordered children set Order = (Items - i) % 3.
Methods:MeasureAndArrange measures at 400×∞ then arranges; UnconstrainedMeasure measures at ∞×∞.
Timing: baseline 11:13:43–11:17:01 CET; after 11:17:18–11:21:16 CET, 2026-11-30. These runs used the coordinated timing lease; no overlapping benchmark is known.
Method
Items
Reordered
Before mean ± StdDev
After mean ± StdDev
Mean Δ
Before alloc
After alloc
Alloc Δ
MeasureAndArrange
10
false
1,410.4 ± 41.1 ns
935.9 ± 7.4 ns
−33.6%
248 B
120 B
−51.6%
MeasureAndArrange
10
true
1,613.2 ± 47.7 ns
1,058.4 ± 19.4 ns
−34.4%
1,352 B
120 B
−91.1%
MeasureAndArrange
100
false
14,951.0 ± 242.4 ns
9,837.6 ± 172.0 ns
−34.2%
584 B
456 B
−21.9%
MeasureAndArrange
100
true
17,913.0 ± 490.2 ns
11,284.5 ± 508.5 ns
−37.0%
4,568 B
456 B
−90.0%
UnconstrainedMeasure
10
false
733.2 ± 12.3 ns
462.2 ± 16.7 ns
−37.0%
560 B
456 B
−18.6%
UnconstrainedMeasure
10
true
838.8 ± 13.4 ns
502.3 ± 11.0 ns
−40.1%
1,112 B
456 B
−59.0%
UnconstrainedMeasure
100
false
7,293.2 ± 226.3 ns
4,704.6 ± 153.9 ns
−35.5%
3,320 B
3,216 B
−3.1%
UnconstrainedMeasure
100
true
8,306.1 ± 96.3 ns
5,242.0 ± 76.8 ns
−36.9%
5,312 B
3,216 B
−39.5%
Per-operation allocations for reordered children matched the non-reordered cases at the same child count in this warm, repeated-pass benchmark. Since the latest GetItemIndex guard change was not benchmarked, treat these figures as measurements of revision 1179bf8bd1, not exact current-head performance.
$S is the session's persistent files directory. Full logs, result files, source hashes and timing metadata are retained there under bench3-{baseline,final} and bench3-metadata.txt.
Limitations: Each revision was measured once, sequentially and in-process on one desktop machine, with repeated iterations within each run. BenchmarkDotNet could not raise process priority on either run (permission denied). The after run for 100-child unconstrained measure without reordering was flagged as multimodal (mValue = 2.88), and the reordered 100-child measure-and-arrange case had a 508.5 ns standard deviation. Timing reductions are indicative rather than a cross-device guarantee. No Android/iOS device measurements were run. The obsolete Compatibility FlexLayout keeps its own copy of the hack and is untouched.
Review
A read-only review with Claude Opus 5.5 (long context) found no significant issues, examining hack removal, stable ordering, buffer leasing/reentrancy, attached-property synchronization and item lifecycle.
Earlier coordination raised two points, both addressed: per-pass buffer leasing prevents reentrant corruption, and stale aotprofile entries were removed.
A follow-up Opus 5.5 review found no issues in capacity/count handling, key decoding, ownership or reentrant leasing.
Inline review follow-ups clarified why packed keys use 64 bits, documented the original-index encoding, and replaced the manual range guard with .NET 8+ ArgumentOutOfRangeException.ThrowIf... helpers; netstandard retains its equivalent check.
dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj -p:IncludeAndroidTargetFrameworks=false -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false --filter "FullyQualifiedName~FlexLayoutTests|FullyQualifiedName~FlexOrderTests|FullyQualifiedName~FlexLayoutMarginTests": 41/41 passed at current head.
The same project with --filter "FullyQualifiedName~FlexLayoutTests" on main's Flex.cs and FlexLayout.cs: 28/28 passed.
dotnet test src/Core/tests/UnitTests/Core.UnitTests.csproj -p:IncludeAndroidTargetFrameworks=false -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false --filter "FullyQualifiedName~Flex": 61/61 passed.
Let the MAUI agent address review feedback and fix remaining issues on this PR. Maintainers still decide whether it is merged. For PRs from forks, keep "Allow edits by maintainers" on so the agent can push to your branch; otherwise it opens a follow-up PR that keeps your commits.
- Remove FlexLayout's unconstrained-measure hack (PrepareMeasureHack/RestoreValues).
EnsureFlexItemPropertiesUpdated always overwrote the values it set before layout,
so it had no effect besides extra work and a per-pass allocation.
- Order children with packed (Order, index) keys sorted in a reusable buffer leased
per layout pass instead of LINQ OrderBy, and skip sorting when children are already
in non-decreasing Order. Stable for equal Order values; reentrant-safe.
- Skip the per-pass InitFlexProperties refresh for bindable children whose flex item
is kept in sync by the attached-property change handlers.
- Remove stale aotprofile entries, add focused tests and a FlexLayout pass benchmark.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Flex-property synchronization is not notification- and reentrancy-safe, allowing PropertyChanged subscribers to measure stale values or leave layout ordering inconsistent with the attached property.
The reason will be displayed to describe this comment to others. Learn more.
[major] Logic and Correctness - Removing this refresh can leave attached values and Flex.Item permanently inconsistent. BindableObject.OnBindablePropertySet raises public PropertyChanged before the attached-property callback, and ClearValue invokes its callback synchronously. With two default-order children, have the first child's Order subscriber clear OrderProperty when GetOrder returns 1, then call SetOrder(child, 1). The nested clear stores Item.Order=0, but the outer callback subsequently stores 1. GetOrder returns 0 while subsequent measure/arrange passes still put that child last; the previous per-pass refresh repaired this mismatch. Retain the refresh or make synchronization notification- and reentrancy-safe. Add tests for measuring and clearing attached properties inside PropertyChanged; the added reset and MeasureOverride-reentrancy tests cover neither notification path.
[major] Behavioral Change Disclosure - Existing apps measuring synchronously from PropertyChanged also observe changed behavior on every platform: setting Grow from 0 to 1 on the first of two 10-wide children and measuring a 100-wide row inside the notification previously produced widths 90 and 10, but now produces 10 and 10 because the callback has not yet synchronized the item. Preserve the prior behavior; if this timing change is intentional, disclose it and provide an explicit opt-in/opt-out retaining the existing behavior. Neither is supplied.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Removing the per-pass refresh allows layout during PropertyChanged notifications to use stale Flex.Item values and can leave child ordering permanently out of sync after reentrant property changes.
Test child-count changes and buffer resizing in ordering
src/Core/src/Layouts/Flex.cs:269
The ordering tests all keep the child count fixed, leaving the new active-count/capacity behavior untested. Add a unit test that warms the buffer with reordered children, removes children while retaining a nontrivial order, measures again, then adds enough children to exceed the previous capacity and verifies their positions. This should exercise both spare-capacity reuse and resizing; the current order-change and reentrancy tests cannot catch stale keys being treated as active after a count change.
@kubaflo — AI-selected UI tests and device tests (GPT-6.2 Sol + MAI Code 2) for commit 65721113.
🧪 Test selection — click to expand
Suite
Result
Selected
Build
UI tests
❌ not queued
1 of 77 categories
—
Device tests
❌ not queued
1 of 105 units
—
🧪 UI tests — Layout on Android, iOS, MacCatalyst, Windows
❌ Could not queue maui-pr-uitests: This PR has merge conflicts with main, so there is no test-merge commit to build. Resolve the conflicts, then comment /review run-tests again.
GPT-6.2 Sol: Run Layout UI tests on all four platforms for the shared FlexLayout measure and child-ordering changes. MAI Code 2: Shared FlexLayout engine and property synchronization changes; runs Layout UI tests on all platforms.
🧪 Running — 1 category on Android, iOS, MacCatalyst, Windows
Platform
Categories
Android
Layout
iOS
Layout
MacCatalyst
Layout
Windows
Layout
🧪 Device tests — Controls.FlexLayout on Android, iOS, MacCatalyst, Windows
❌ Could not queue maui-pr-devicetests: This PR has merge conflicts with main, so there is no test-merge commit to build. Resolve the conflicts, then comment /review run-tests again.
GPT-6.2 Sol: Run Controls.FlexLayout device tests on all four platforms to exercise the shared FlexLayout implementation. MAI Code 2: Shared FlexLayout engine and Controls property changes; runs FlexLayout device tests on all platforms.
🧪 Running — 1 category on Android, iOS, MacCatalyst, Windows
Each skipped platform and project is listed as a maui-pr-devicetests (skipped) … status on this commit. Use /azp run maui-pr-devicetests for the full suite.
🤖 Why these tests — AI rationale (GPT-6.2 Sol + MAI Code 2)
UI tests
Each model chose independently; every test that runs was selected by at least one of them.
Platform
GPT-6.2 Sol
MAI Code 2
Android
Layout
Layout
iOS
Layout
Layout
MacCatalyst
Layout
Layout
Windows
Layout
Layout
GPT-6.2 Sol — Run Layout UI tests on all four platforms for the shared FlexLayout measure and child-ordering changes.
FlexLayout.cs changes flex child property refresh and unconstrained measure; Flex.cs changes child ordering on all four platforms.
No layout base or platform pipeline changes; the AOT profile only drops entries for removed methods.
MAI Code 2 — Shared FlexLayout engine and property synchronization changes; runs Layout UI tests on all platforms.
FlexLayout.cs and the shared Flex.cs engine change FlexLayout measure, ordering, and property propagation on every platform.
Select the Layout UI category because the inventory has no FlexLayout-specific UI category.
Leave other UI categories out; the diff does not change general handlers, startup, resources, or shared test infrastructure.
Device tests
Each model chose independently; every test that runs was selected by at least one of them.
Platform
GPT-6.2 Sol
MAI Code 2
Android
Controls.FlexLayout
Controls.FlexLayout
iOS
Controls.FlexLayout
Controls.FlexLayout
MacCatalyst
Controls.FlexLayout
Controls.FlexLayout
Windows
Controls.FlexLayout
Controls.FlexLayout
GPT-6.2 Sol — Run Controls.FlexLayout device tests on all four platforms to exercise the shared FlexLayout implementation.
Controls.FlexLayout includes tagged tests for nested stack layouts and a button with an image in a wrapping FlexLayout.
Flex.cs is FlexLayout-specific; no generic layout handler changed, so broader Controls.Layout and Core.Layout runs are not needed.
MAI Code 2 — Shared FlexLayout engine and Controls property changes; runs FlexLayout device tests on all platforms.
FlexLayout.cs and Flex.cs are shared code affecting FlexLayout behavior across all device platforms.
Controls.FlexLayout directly covers ordering, sizing, margins, and reentrant layout behavior changed by the PR.
Leave broader Controls/Core suites out because the changes are confined to FlexLayout rather than base layout or handler infrastructure.
Generated by /review run-tests. A targeted run is a fast signal, not full-suite certification.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Synchronous measurement from a PropertyChanged subscriber can observe stale Flex item values, returning the old ordering after the bindable Order property has already changed.
)
<!-- copilot-assessment:v1 -->
### Agent assessment
Self-reported assessment, not an independent review.
Assessed revision: `54f080994407a59cd73d16f38f8136277f2cf9fc`
| Dimension | Assessment | Rationale |
|---|---|---|
| Change confidence | 8.5/10 | ↑ Layouts and Flex unit tests pass
154/154 locally.<br>↑ Two Claude Opus 5.5 code reviews found no
significant issues.<br>↓ No device or UI tests run.<br>↓ No perf
benchmark run to confirm the per-pass saving is kept.<br>↓ CI not yet
inspected. |
| Diagnosis confidence | 9.5/10 | ↑ 3 new tests fail on main and pass
against the pre-#40852 FlexLayout.cs (62130d9).<br>↑ Source order in
BindableObject confirms PropertyChanged is raised before the property
callback, and ClearValue is not queued. |
| Evidence fit | 8/10 | ↑ Matches the concern in review thread
r4738447796 on #40852.<br>↓ Found by code review; no user-reported
symptom yet. |
<!-- /copilot-assessment -->
<!-- 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!
<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->
### Target Branch
| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |
- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).
For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.
### Description of Change
This fixes a regression from #40852 that was raised in review thread
#40852 (comment). The
base is `main` because #40852 is only on `main`.
#40852 stopped re-reading `Order`, `Grow`, `Shrink`, `Basis` and
`AlignSelf` for bindable children on every layout pass. Instead, the
attached-property `propertyChanged` callbacks copied `newValue` into the
`Flex.Item`. However, `BindableObject` raises the public
`PropertyChanged` event before it runs the property's own callback. So:
- **Cleared value lost:** If a `PropertyChanged` subscriber calls
`ClearValue`, the cleared value is stored first, and then the outer
callback writes the stale value back. Layout never corrects it. This
doesn't happen with `SetValue`, because nested `SetValue` calls are
queued and `ClearValue` calls are not.
- **Old value measured:** A measure run synchronously from a
`PropertyChanged` subscriber sees the old value.
**Fix**
- `Flex.Item` gets an internal `NeedsFlexPropertiesUpdate` flag. It is
set in both the `propertyChanging` and `propertyChanged` callbacks of
the five attached properties.
- `EnsureFlexItemPropertiesUpdated` re-reads those five values from the
`BindableObject` only for items marked as changed. Unchanged items are
skipped, which keeps the per-pass saving from #40852.
- Nested `FlexLayout`s are laid out as part of the root pass, because
their own `Layout()` returns early. The root pass now refreshes changed
flex properties for their children too. It does not refresh margin, size
or visibility for nested children, which matches previous behavior.
**Tests** (`Controls.Core.UnitTests`, `FlexLayoutTests`)
- `OrderClearedFromPropertyChangedHandlerIsApplied`,
`FlexPropertiesClearedFromPropertyChangedHandlerAreApplied` and
`MeasureFromPropertyChangedHandlerSeesNewOrder` fail on `main` and pass
with this fix. They also pass against the pre-#40852 `FlexLayout.cs`
(62130d9).
- `FlexPropertyChangesInNestedFlexLayoutAreApplied` guards the nested
refresh that this lazy approach needs. It passes on `main` and on the
baseline.
**Validation**
- `dotnet test
src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj
-p:IncludeAndroidTargetFrameworks=false
-p:IncludeIosTargetFrameworks=false
-p:IncludeMacCatalystTargetFrameworks=false
-p:IncludeMacOSTargetFrameworks=false --filter
"FullyQualifiedName~Layouts|FullyQualifiedName~Flex"`: passed, 154/154.
- Not run: device tests, UI tests, perf benchmark.
### Issues Fixed
Fixes a regression introduced by #40852 (review thread
#40852 (comment)). No
separate issue is filed.
### Let AI finish this PR
- [ ] **Let the MAUI agent address review feedback and fix remaining
issues on this PR.** Maintainers still decide whether it is merged. For
PRs from forks, keep "Allow edits by maintainers" on so the agent can
push to your branch; otherwise it opens a follow-up PR that keeps your
commits.
<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->
---------
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
65721113b9557f803cb39b17606b7df69b372691↑ The netstandard2.0 Core build passes with PublicApiType=Validate.
↑ Reentrant layout test validates the per-pass buffer lease; Opus 5.5 review found no issues in the wrapper.
↑ Benchmark comparison shows lower allocations in all eight cases.
↓ Benchmarks predate the modern-target range-check helper in this revision; timings are single-machine and show one multimodal case.
↓ No device or UI tests were run.
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!
Target Branch
mainnet11, for reviewFor .NET 11 fixes, only a maintainer retargets the approved PR to the active
inflight lane and merges it after CI validates that final base. Do not merge
individual fixes directly into
net11; agents must not retarget or merge.Description of Change
This is a .NET 12 layout performance change. It reduces per-pass work and allocations in the measured Controls
FlexLayoutscenarios. There are no public API changes.1. Remove the unconstrained-measure hack (
PrepareMeasureHack/RestoreValues)FlexLayout.Layout()setShrinkandAlignSelfon each child's flex item. It then immediately calledEnsureFlexItemPropertiesUpdated(), which wrote the real attached values back over the same items, so the hack never had any effect.maui-sc.aotprofile.txt.2. Stable child ordering and reusable storage in
Flex.csOrderBy, allocating on every pass when any child had a non-zeroOrder.longkey,((long)Order << 32) | (uint)index, then sorts keys withArray.Sort. This orders first byOrder, then by insertion index, preserving stable order for equal values, including negative and extremeintvalues. If children are already in non-decreasingOrder, sorting is skipped.OrderedKeysBufferencapsulates the backing array and active_count. It retains capacity when child count stays the same or shrinks, and grows only when count exceeds capacity. Sorting and index access use the active count, preventing spare capacity from being treated as valid keys.Itemand returns it incleanup(item). A child'sSelfSizingcallback can re-enter layout; leasing prevents the nested pass from overwriting the outer pass's keys.3. Skip redundant per-pass refresh of attached flex properties
BindableObjectchildren, attached-property change handlers (Order,Grow,Shrink,AlignSelf,Basis) already keep theFlex.Itemin sync.EnsureFlexItemPropertiesUpdatedno longer re-runsInitFlexPropertiesfor them on every pass.BindableObjectstill get the full refresh.UpdateItemProperties(margin, visibility, and similar) still runs for every child.4. Standalone benchmark
FlexLayoutPassBenchmarkertoCore.Benchmarksusing BenchmarkDotNetMemoryDiagnoser. It repeats measure and arrange passes on a wrapping FlexLayout with fixed-size children, with and withoutFlexLayout.Order. There are no performance assertions in unit tests.Measured impact
InProcessEmitToolchain, Release.Flex.csandFlexLayout.csfrommainat62130d92cd20df7195efa051b0912679781c206b; measured after source revision1179bf8bd1a38c14a5c6d95f500dd03cc93e2ca2. Current PR head is65721113b9557f803cb39b17606b7df69b372691; it adds documented packed-key encoding andArgumentOutOfRangeExceptionguard helpers on .NET 8+ (with the equivalent existing check for netstandard), plus removes a baseline-passing characterization test. Those latest changes were not part of the timing run.Wrap = FlexWrap.Wrap, 400 wide, fixed 20×20 children. Reordered children setOrder = (Items - i) % 3.MeasureAndArrangemeasures at 400×∞ then arranges;UnconstrainedMeasuremeasures at ∞×∞.Per-operation allocations for reordered children matched the non-reordered cases at the same child count in this warm, repeated-pass benchmark. Since the latest
GetItemIndexguard change was not benchmarked, treat these figures as measurements of revision1179bf8bd1, not exact current-head performance.$Sis the session's persistent files directory. Full logs, result files, source hashes and timing metadata are retained there underbench3-{baseline,final}andbench3-metadata.txt.Limitations: Each revision was measured once, sequentially and in-process on one desktop machine, with repeated iterations within each run. BenchmarkDotNet could not raise process priority on either run (permission denied). The after run for 100-child unconstrained measure without reordering was flagged as multimodal (
mValue = 2.88), and the reordered 100-child measure-and-arrange case had a 508.5 ns standard deviation. Timing reductions are indicative rather than a cross-device guarantee. No Android/iOS device measurements were run. The obsolete CompatibilityFlexLayoutkeeps its own copy of the hack and is untouched.Review
ArgumentOutOfRangeException.ThrowIf...helpers; netstandard retains its equivalent check.Tests added (
FlexLayoutTests)OrderChangesAfterLayoutAreAppliedAndRevertWhenResetEqualOrderValuesKeepInsertionOrderFlexPropertyChangesAfterLayoutAreAppliedCoreViewFlexPropertyChangesAfterLayoutAreAppliedReentrantLayoutWithOrderChangesDoesNotCorruptOuterPassOrderValidation
dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj -p:IncludeAndroidTargetFrameworks=false -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false --filter "FullyQualifiedName~FlexLayoutTests|FullyQualifiedName~FlexOrderTests|FullyQualifiedName~FlexLayoutMarginTests": 41/41 passed at current head.--filter "FullyQualifiedName~FlexLayoutTests"onmain'sFlex.csandFlexLayout.cs: 28/28 passed.dotnet test src/Core/tests/UnitTests/Core.UnitTests.csproj -p:IncludeAndroidTargetFrameworks=false -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false --filter "FullyQualifiedName~Flex": 61/61 passed.dotnet build src/Core/src/Core.csproj -f netstandard2.0 --no-restore -p:PublicApiType=Validate -p:IncludeAndroidTargetFrameworks=false -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false: succeeded.git diff --check: clean.Issues Fixed
None. This is proactive layout performance work.
Let AI finish this PR