Skip to content

[net12][Proposal] Batch handler updates per dispatcher turn - #37337

Draft
StephaneDelcroix wants to merge 7 commits into
mainfrom
copilot/message-batching-experiment
Draft

StephaneDelcroix wants to merge 7 commits into
mainfrom
copilot/message-batching-experiment

Conversation

@StephaneDelcroix

@StephaneDelcroix StephaneDelcroix commented Aug 12, 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!

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

This is .NET 12 work. The branch has been rebased onto main at 331056d8a2 and the GitHub base is now main.

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 an opt-in experiment that coalesces repeated .NET MAUI handler property updates before they cross into the platform control.

The application surface does not change: apps continue to use ordinary XAML, controls, bindings, events, and handler mapper customization. Once automatic batching is enabled, no method calls or XAML changes are required.

The goal is to avoid repeatedly assigning transient values to the same native properties during a synchronous update burst when only the final value can become visible.

Enabling the experiment

Set both switches before MAUI initializes VisualElement:

AppContext.SetSwitch("Microsoft.Maui.Experimental.HandlerUpdateBatching", true);
AppContext.SetSwitch("Microsoft.Maui.Experimental.HandlerUpdateBatching.AutoDispatch", true);

The values are cached during VisualElement type initialization.

Enabling only Microsoft.Maui.Experimental.HandlerUpdateBatching applies coalescing to existing BatchBegin() / BatchCommit() scopes without enabling automatic dispatcher batching.

What it does

Explicit batches

Property notifications received between BatchBegin() and BatchCommit() are deduplicated and flushed synchronously at commit.

Automatic batches

  1. The first top-level property update for a handler is mapped immediately, preserving sparse-update latency.
  2. The handler schedules one callback on the MAUI dispatcher. There is no fixed millisecond timer.
  3. Later top-level updates received before that callback runs are deduplicated by property.
  4. Pending properties retain relative last-occurrence order. A, B, A flushes as B, A.
  5. The mapper reads the latest managed value when the property is flushed.

A dispatcher turn means the interval before the queued callback executes. It is an event-loop boundary, not a 10 ms window or a guarantee of one display frame.

Correctness model

Only top-level notifications are deferred.

  • UpdateValue calls made by a mapper execute synchronously, preserving dependency order for formatting, container creation, clipping, shadows, borders, and similar mappings.
  • Every command, including InvalidateMeasure, flushes pending properties first; measure invalidation remains synchronous and is not coalesced.
  • PlatformView and ContainerView access flush pending top-level work, except while a mapper is executing.
  • Synchronous barriers reuse the outstanding handler-scoped dispatcher callback rather than posting duplicates.
  • Mapper actions are resolved at flush time, so current chained AppendToMapping / PrependToMapping customization is used.
  • Android flushes call CanInvokeMappers() before touching a potentially disposed Java peer.
  • Virtual-view changes and disconnects discard stale pending work. Getter barriers are suppressed throughout disconnect teardown, including container removal.

Implementation and hot paths

The pending queue is bounded by the number of distinct pending properties and supports O(1) enqueue and move-to-last operations using:

  • a reusable indexed node list;
  • a property-to-index dictionary;
  • head and tail indices.

The dispatcher callback and queue storage are reused after the first batch. Steady-state batches do not allocate.

When batching is inactive, initial mapping, UpdateValue, and command invocation use the existing direct mapper path. Platform-view access reduces to a zero pending-count check.

Benchmark results

The committed BenchmarkDotNet benchmark contains no logging, string formatting, ConcurrentDictionary, or metric aggregation inside timed mapper callbacks. It compares:

  • the base branch;
  • the new implementation with batching disabled;
  • automatic batching;
  • explicit batching.

On an Apple M3 Pro with deliberately no-op mappers:

Scenario Base branch Feature disabled Automatic Explicit
Sparse update 8.09 ns 7.92 ns 28.12 ns —
100 updates 897 ns 830 ns 951 ns 857 ns
1,000 updates 8.84 µs 8.28 µs 8.53 µs 8.25 µs
Steady-state allocation 0 B 0 B 0 B 0 B

These results show the batching machinery itself, not native mapper savings:

  • the disabled path is effectively the stock path;
  • large no-op bursts are approximately parity;
  • small automatic bursts have fixed dispatcher/queue overhead;
  • batching becomes beneficial only when avoided mapper/native work costs more than that overhead.

The earlier 18.1x instrumented Sandbox result overstated elapsed speedup because the timed mapper callbacks performed logging and shared metric aggregation. It remains useful as a qualitative demonstration of mapper-call reduction, not as a representative performance claim.

Demonstration

This synchronized recording shows the earlier instrumented prototype applying the same 100-round update workload in stock and batched modes:

ios-stock-vs-batched-side-by-side.mp4

The recording demonstrates that native values converge to the same final state. Its displayed elapsed times are not the final benchmark evidence.

Validation

Current rebase and review fixes (November 19, 2026)

Rebased onto main at 331056d8a2, retaining upstream handler instrumentation. No Sandbox changes are included.

Non-platform build/test commands below use these MSBuild properties:

nonplatform=(
  -p:IncludeAndroidTargetFrameworks=false
  -p:IncludeIosTargetFrameworks=false
  -p:IncludeMacCatalystTargetFrameworks=false
  -p:IncludeMacOSTargetFrameworks=false
  -p:IncludeWindowsTargetFrameworks=false
)
dotnet build Microsoft.Maui.BuildTasks.slnf "${nonplatform[@]}" -v:q
dotnet test src/Core/tests/UnitTests/Core.UnitTests.csproj "${nonplatform[@]}" -v:normal
dotnet build Microsoft.Maui.BuildTasks.slnf "${nonplatform[@]}" -p:MauiEnableHandlerInstrumentation=true -v:q
dotnet test src/Core/tests/UnitTests/Core.UnitTests.csproj "${nonplatform[@]}" -p:MauiEnableHandlerInstrumentation=true -v:normal
dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj "${nonplatform[@]}" --filter 'FullyQualifiedName~ViewUnitTests|FullyQualifiedName~AnimatableKeyTests' -v:normal
dotnet build src/Core/tests/Benchmarks/Core.Benchmarks.csproj -c Release -restore "${nonplatform[@]}" -v:q

Results: prerequisite builds passed; Core 1,154 passed normally and 1,161 passed with instrumentation; targeted Controls 156 passed; benchmark project Release build passed. All reported builds completed with zero warnings and zero errors.

Regression proof: disabling just the teardown guard and outstanding-callback fix produces 10 failures in AbstractViewHandlerTests; restoring them passes all 43 handler cases within the full Core suite. Five barrier variants each reproduce 100 callbacks before / 1 callback after for 100 synchronous barrier cycles. Explicit/automatic container teardown and virtual-view replacement/reconnect are covered.

Android Release build commands:

android=(
  -p:IncludeAndroidTargetFrameworks=true
  -p:IncludeIosTargetFrameworks=false
  -p:IncludeMacCatalystTargetFrameworks=false
  -p:IncludeMacOSTargetFrameworks=false
  -p:IncludeWindowsTargetFrameworks=false
)
dotnet build src/Core/src/Core.csproj -f net11.0-android37.0 -c Release -restore "${android[@]}" -v:q
dotnet restore src/Core/src/HybridWebViewSourceGen/Core.HybridWebViewSourceGen.csproj -v:q
dotnet restore src/Controls/src/BindingSourceGen/Controls.BindingSourceGen.csproj -v:q
dotnet build src/Controls/src/Core/Controls.Core.csproj -f net11.0-android37.0 -c Release --no-restore "${android[@]}" -v:q

Results: Core and Controls Android Release builds passed, zero warnings/errors. The generator restores repair an existing restore-graph issue where -f propagates the Android framework into generator assets.

Remaining validation limitations: iOS and Mac Catalyst Release builds targeting the repository's 27.0 fail with NETSDK1140: this host's installed Apple workloads support only 26.5. The actual SDK used here is 11.0.100-rc.2.26475.136, not the bootstrapped 11.0.100-rtm.26514.118 recorded under tools.dotnet in global.json. Apple builds and device/UI rendering validation still require a matching provisioned host/CI. No new runtime or benchmark timing claims are made by this rebase.

Published head: b433f51c71. Fresh maui-pr build 1689766 is in progress on the final main base. Device/UI checks initially reported ACTION_REQUIRED / "Skipped due to merge conflicts" from before retargeting; those are not passing validation and require fresh runs.

Historical validation before this rebase

  • Core unit tests: 853 passed, 3 skipped, 0 failed
  • Core Release builds: iOS, Android, and Mac Catalyst
  • Android Release runtime: all visible Labels, Buttons, Entries, Switches, Sliders, and ProgressBars reached generation 100
  • Android 100-round runtime workload: 144 instrumented mapper calls
  • Independent final reviews covered mapper ordering, reentrancy, lifecycle, Android disposal, barrier behavior, and queue linkage

Rollout

Performance status: no representative end-to-render or frame-time improvement has been established. The historical no-op benchmarks show fixed automatic-batching overhead, not a native performance win. This remains a draft experiment with do-not-merge while the benefit/complexity tradeoff is evaluated.

  1. Keep the primary feature opt-in.
  2. Validate explicit batching independently.
  3. Keep automatic dispatcher batching behind its second switch until end-to-render device benchmarks and real application scenarios establish the break-even point.

Issues Fixed

Experimental proposal; no issue is closed by this PR.

@github-actions

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@kubaflo kubaflo changed the title [Proposal] Batch handler updates per dispatcher turn [net12][Proposal] Batch handler updates per dispatcher turn Aug 26, 2026
@kubaflo kubaflo added the do-not-merge Don't merge this PR label Aug 26, 2026
@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 Aug 30, 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 — 7 findings

See inline comments for details.

MauiBot

This comment was marked as outdated.

@MauiBot MauiBot added s/agent-changes-requested AI agent recommends changes - found a better alternative or issues 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) and removed s/agent-review-in-progress AI review is currently running for this PR labels Aug 30, 2026
@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 Sep 10, 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.

MauiBot

This comment was marked as outdated.

@MauiBot MauiBot added s/agent-fix-win AI found a better alternative fix than the PR and removed s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates s/agent-review-in-progress AI review is currently running for this PR labels Sep 10, 2026
@kubaflo

This comment has been minimized.

@github-actions github-actions Bot 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.

Expert Review — 3 findings

Reviewed commit b433f51.

See inline comments for details.

var property = node.Property!;
_pendingPropertyUpdateHead = node.Next;
indices.Remove(property);
InvokeCurrentPropertyMapper(property);

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.

[major] Logic and Correctness Verification - Flushing an earlier property can overwrite the managed values of properties still queued. With explicit batching enabled, use a connected Windows Entry displaying "a", then call BatchBegin(); Text = "abcdef"; CursorPosition = 2; SelectionLength = 2; BatchCommit();. Text maps first; Controls' Windows TextBoxExtensions.UpdateText sets native text and calls Select(cursorPosition, 0). EntryHandler.OnPlatformSelectionChanged synchronously writes the resulting caret and zero selection length back into the virtual view, overwriting the requested selection before its queued mappers read it. The final state loses the requested selection, unlike the unbatched sequence where the selection assignments follow the native Text callbacks. Preserve pending selection values across native feedback and cover this with a real Entry regression test; the added counter-only mappers cannot detect it.

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.

MAUI Autopilot · round 1

❌ Not changed. The Windows Entry fix and regression tests could not be published: the append-only push was rejected because existing PR history includes a documentation path outside the allowed paths. The Windows tests still need a Windows runner.


bool IPropertyUpdateBatchingElement.IsAutomaticPropertyUpdateBatchingEnabled => false;

bool IPropertyUpdateBatchingElement.IsPropertyUpdateBatchingExplicitlyScoped => true;

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.

[moderate] Regression Prevention and Test Coverage - These fixtures replace VisualElement's switch-backed batching contract, and the explicit-only fixture reports an open scope before BatchBegin. Making the production enabled property always false would therefore leave these batching assertions unchanged; removing the explicit-only BeginPropertyUpdateBatch notification is also masked by the already-open fixture scope. The existing Controls TestBatching checks only the counter/event without a handler, and the benchmark overrides the interface too. Add isolated switch-initialization coverage with an unmodified control and attached handler, checking primary-switch-only batching, updates outside the scope, nested commits, and the disabled case.

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.

MAUI Autopilot · round 1

❌ Not changed. The isolated startup-switch test passed locally without changing production switch caching, but the append-only push was rejected because existing PR history includes a documentation path outside the allowed paths.

handler = new HandlerStub(mapper);
var view = new AlwaysBatchingButton();

handler.SetVirtualView(view);

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.

[moderate] Regression Prevention and Test Coverage - This test ends explicit batching during setup: SetVirtualView executes the initial First mapper, which calls FlushPendingPropertyUpdates and clears _isExplicitPropertyUpdateBatching. After mapped.Clear(), both UpdateValue calls consequently map immediately and the final flush is empty. The First/Second assertion never exercises a reentrant commit while Second remains queued, so it cannot detect dropped work in the active-drain scenario named by the test. Suppress the commit during initialization, begin a fresh batch afterward, and assert no mapping occurred before triggering the flush. The reflection-based companion covers the different outside-drain scenario.

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.

MAUI Autopilot · round 1

❌ Not changed. The corrected reentrant-commit test passed locally, but the append-only push was rejected because existing PR history includes a documentation path outside the allowed paths.

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

kubaflo commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

/review run-tests

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Selected UI Tests

@kubaflo — AI-selected UI tests (GPT-6.1 Sol + Claude Opus 5.5) for commit b433f51c.

Result FAILED Platforms Android, iOS, MacCatalyst, Windows Categories All 77 Commit b433f51c


🧪 Test selection — click to expand

❌ maui-pr-uitests #1691867 failed. See the failing checks below or the run for details.

GPT-6.1 Sol: Shared VisualElement and base-handler batching, native-view access and teardown changes require all UI categories on Android, iOS, MacCatalyst and Windows.
Claude Opus 5.5: Adds handler property-update batching to the base ElementHandler, ViewHandler and VisualElement; runs the full UI test suite on all platforms.

🧪 Ran — 77 categories on Android, iOS, MacCatalyst, Windows

The complete maui-pr-uitests suite runs on every platform (same as /azp run).

📊 Results — failed: 126 passed, 7 failed of 133 jobs
Job Result
Android UITests CoreClr Controls (API 30) Accessibility,ActionSheet,ActivityIndicator,Animation,AppLinks ✅ succeeded
Android UITests CoreClr Controls (API 30) Border,BoxView,Brush,Button ✅ succeeded
Android UITests CoreClr Controls (API 30) CarouselView ✅ succeeded
Android UITests CoreClr Controls (API 30) Cells,CheckBox,ContextActions,CustomRenderers,DatePicker,Dispatcher,DisplayAlert,DisplayPrompt,DragAndDrop ✅ succeeded
Android UITests CoreClr Controls (API 30) CollectionView1 ✅ succeeded
Android UITests CoreClr Controls (API 30) CollectionView2 ✅ succeeded
Android UITests CoreClr Controls (API 30) CollectionView3 ✅ succeeded
Android UITests CoreClr Controls (API 30) CollectionView4 ✅ succeeded
Android UITests CoreClr Controls (API 30) CollectionView5 ✅ succeeded
Android UITests CoreClr Controls (API 30) CollectionView6 ✅ succeeded
Android UITests CoreClr Controls (API 30) CollectionView7 ✅ succeeded
Android UITests CoreClr Controls (API 30) Editor,Effects,Essentials,FlyoutPage,Focus,Fonts,Frame,Gestures,GraphicsView ✅ succeeded
Android UITests CoreClr Controls (API 30) Entry ✅ succeeded
Android UITests CoreClr Controls (API 30) Image,ImageButton,IndicatorView,InputTransparent,IsEnabled,IsVisible ✅ succeeded
Android UITests CoreClr Controls (API 30) Label ✅ succeeded
Android UITests CoreClr Controls (API 30) Layout ✅ succeeded
Android UITests CoreClr Controls (API 30) Lifecycle,ManualReview,Maps ✅ succeeded
Android UITests CoreClr Controls (API 30) Navigation ✅ succeeded
Android UITests CoreClr Controls (API 30) Page,Performance,Picker,ProgressBar ✅ succeeded
Android UITests CoreClr Controls (API 30) RadioButton,RefreshView ✅ succeeded
Android UITests CoreClr Controls (API 30) ScrollView ✅ succeeded
Android UITests CoreClr Controls (API 30) SearchBar,Shape,Slider ✅ succeeded
Android UITests CoreClr Controls (API 30) Shadow ✅ succeeded
Android UITests CoreClr Controls (API 30) Shell1 ✅ succeeded
Android UITests CoreClr Controls (API 30) Shell2 ✅ succeeded
Android UITests CoreClr Controls (API 30) SoftInput,Stepper,Switch,SwipeView ✅ succeeded
Android UITests CoreClr Controls (API 30) TabbedPage,TableView,TimePicker,TitleView,ToolbarItem,Triggers ✅ succeeded
Android UITests CoreClr Controls (API 30) ViewBaseTests,VisualStateManager,Window ✅ succeeded
Android UITests CoreClr Controls (API 30) WebView ✅ succeeded
Android UITests Material3 Controls Material3 (API 36) ✅ succeeded
Android UITests SafeAreaEdges (API 36 Pixel 3 XL) Controls SafeAreaEdges (API 36 Pixel 3 XL) ✅ succeeded
Android UITests Shell Renderer Controls Shell Renderer (API 30) Shell1 ✅ succeeded
Android UITests Shell Renderer Controls Shell Renderer (API 30) Shell2 ✅ succeeded
Build UITests CoreCLR Sample App Build Sample App ✅ succeeded
Build UITests Material3 Sample App Build Sample App (Material3) ✅ succeeded
Build UITests Windows CV1 Sample App Build Sample App (Windows CV1) ✅ succeeded
Build UITests Windows Sample App Build Sample App (Windows) ✅ succeeded
iOS UITests CoreCLR Controls (vlatest) Accessibility,ActionSheet,ActivityIndicator,Animation,AppLinks ✅ succeeded
iOS UITests CoreCLR Controls (vlatest) Border,BoxView,Brush,Button ✅ succeeded
iOS UITests CoreCLR Controls (vlatest) CarouselView ❌ failed
iOS UITests CoreCLR Controls (vlatest) Cells,CheckBox,ContextActions,CustomRenderers,DatePicker,Dispatcher,DisplayAlert,DisplayPrompt,DragAndDrop ✅ succeeded
iOS UITests CoreCLR Controls (vlatest) CollectionView1 ✅ succeeded
iOS UITests CoreCLR Controls (vlatest) CollectionView2 ❌ failed
iOS UITests CoreCLR Controls (vlatest) CollectionView3 ✅ succeeded
iOS UITests CoreCLR Controls (vlatest) CollectionView4 ❌ failed
iOS UITests CoreCLR Controls (vlatest) CollectionView5 ✅ succeeded
iOS UITests CoreCLR Controls (vlatest) CollectionView6 ✅ succeeded
iOS UITests CoreCLR Controls (vlatest) CollectionView7 ✅ succeeded
iOS UITests CoreCLR Controls (vlatest) Editor,Effects,Essentials,FlyoutPage,Focus,Fonts,Frame,Gestures,GraphicsView ✅ succeeded
iOS UITests CoreCLR Controls (vlatest) Entry ✅ succeeded
iOS UITests CoreCLR Controls (vlatest) Image,ImageButton,IndicatorView,InputTransparent,IsEnabled,IsVisible ✅ succeeded
iOS UITests CoreCLR Controls (vlatest) Label ✅ succeeded
iOS UITests CoreCLR Controls (vlatest) Layout ❌ failed
iOS UITests CoreCLR Controls (vlatest) Lifecycle,ManualReview,Maps ✅ succeeded
iOS UITests CoreCLR Controls (vlatest) Navigation ✅ succeeded
iOS UITests CoreCLR Controls (vlatest) Page,Performance,Picker,ProgressBar ✅ succeeded
iOS UITests CoreCLR Controls (vlatest) RadioButton,RefreshView ✅ succeeded
iOS UITests CoreCLR Controls (vlatest) SafeAreaEdges ✅ succeeded
iOS UITests CoreCLR Controls (vlatest) ScrollView ✅ succeeded
iOS UITests CoreCLR Controls (vlatest) SearchBar,Shape,Slider ✅ succeeded
iOS UITests CoreCLR Controls (vlatest) Shadow ✅ succeeded
iOS UITests CoreCLR Controls (vlatest) Shell1 ✅ succeeded
iOS UITests CoreCLR Controls (vlatest) Shell2 ✅ succeeded
iOS UITests CoreCLR Controls (vlatest) SoftInput,Stepper,Switch,SwipeView ✅ succeeded
iOS UITests CoreCLR Controls (vlatest) TabbedPage,TableView,TimePicker,TitleView,ToolbarItem,Triggers ✅ succeeded
iOS UITests CoreCLR Controls (vlatest) ViewBaseTests,VisualStateManager,Window ✅ succeeded
iOS UITests CoreCLR Controls (vlatest) WebView ✅ succeeded
MacCatalyst UITests CoreCLR Controls Accessibility,ActionSheet,ActivityIndicator,Animation,AppLinks ✅ succeeded
MacCatalyst UITests CoreCLR Controls Border,BoxView,Brush,Button ✅ succeeded
MacCatalyst UITests CoreCLR Controls CarouselView ❌ failed
MacCatalyst UITests CoreCLR Controls Cells,CheckBox,ContextActions,CustomRenderers,DatePicker,Dispatcher,DisplayAlert,DisplayPrompt,DragAndDrop ✅ succeeded
MacCatalyst UITests CoreCLR Controls CollectionView1 ❌ failed
MacCatalyst UITests CoreCLR Controls CollectionView2 ✅ succeeded
MacCatalyst UITests CoreCLR Controls CollectionView3 ✅ succeeded
MacCatalyst UITests CoreCLR Controls CollectionView4 ✅ succeeded
MacCatalyst UITests CoreCLR Controls CollectionView5 ✅ succeeded
MacCatalyst UITests CoreCLR Controls CollectionView6 ✅ succeeded
MacCatalyst UITests CoreCLR Controls CollectionView7 ✅ succeeded
MacCatalyst UITests CoreCLR Controls Editor,Effects,Essentials,FlyoutPage,Focus,Fonts,Frame,Gestures,GraphicsView ✅ succeeded
MacCatalyst UITests CoreCLR Controls Entry ✅ succeeded
MacCatalyst UITests CoreCLR Controls Image,ImageButton,IndicatorView,InputTransparent,IsEnabled,IsVisible ✅ succeeded
MacCatalyst UITests CoreCLR Controls Label ✅ succeeded
MacCatalyst UITests CoreCLR Controls Layout ✅ succeeded
MacCatalyst UITests CoreCLR Controls Lifecycle,ManualReview,Maps ✅ succeeded
MacCatalyst UITests CoreCLR Controls Navigation ❌ failed
MacCatalyst UITests CoreCLR Controls Page,Performance,Picker,ProgressBar ✅ succeeded
MacCatalyst UITests CoreCLR Controls RadioButton,RefreshView ✅ succeeded
MacCatalyst UITests CoreCLR Controls SafeAreaEdges ✅ succeeded
MacCatalyst UITests CoreCLR Controls ScrollView ✅ succeeded
MacCatalyst UITests CoreCLR Controls SearchBar,Shape,Slider ✅ succeeded
MacCatalyst UITests CoreCLR Controls Shadow ✅ succeeded
MacCatalyst UITests CoreCLR Controls Shell1 ✅ succeeded
MacCatalyst UITests CoreCLR Controls Shell2 ✅ succeeded
MacCatalyst UITests CoreCLR Controls SoftInput,Stepper,Switch,SwipeView ✅ succeeded
MacCatalyst UITests CoreCLR Controls TabbedPage,TableView,TimePicker,TitleView,ToolbarItem,Triggers ✅ succeeded
MacCatalyst UITests CoreCLR Controls ViewBaseTests,VisualStateManager,Window ✅ succeeded
MacCatalyst UITests CoreCLR Controls WebView ✅ succeeded
WinUI UITests Controls Accessibility,ActionSheet,ActivityIndicator,Animation,AppLinks ✅ succeeded
WinUI UITests Controls Border,BoxView,Brush,Button ✅ succeeded
WinUI UITests Controls CarouselView ✅ succeeded
WinUI UITests Controls Cells,CheckBox,ContextActions,CustomRenderers,DatePicker,Dispatcher,DisplayAlert,DisplayPrompt,DragAndDrop ✅ succeeded
WinUI UITests Controls CollectionView1 ✅ succeeded
WinUI UITests Controls CollectionView2 ✅ succeeded
WinUI UITests Controls CollectionView3 ✅ succeeded
WinUI UITests Controls CollectionView4 ✅ succeeded
WinUI UITests Controls CollectionView5 ✅ succeeded
WinUI UITests Controls CollectionView6 ✅ succeeded
WinUI UITests Controls CollectionView7 ✅ succeeded
WinUI UITests Controls Editor,Effects,Essentials,FlyoutPage,Focus,Fonts,Frame,Gestures,GraphicsView ✅ succeeded
WinUI UITests Controls Entry ✅ succeeded
WinUI UITests Controls Image,ImageButton,IndicatorView,InputTransparent,IsEnabled,IsVisible ✅ succeeded
WinUI UITests Controls Label ✅ succeeded
WinUI UITests Controls Layout ✅ succeeded
WinUI UITests Controls Lifecycle,ManualReview,Maps ✅ succeeded
WinUI UITests Controls Navigation ✅ succeeded
WinUI UITests Controls Page,Performance,Picker,ProgressBar ✅ succeeded
WinUI UITests Controls RadioButton,RefreshView ✅ succeeded
WinUI UITests Controls SafeAreaEdges ✅ succeeded
WinUI UITests Controls ScrollView ✅ succeeded
WinUI UITests Controls SearchBar,Shape,Slider ✅ succeeded
WinUI UITests Controls Shadow ✅ succeeded
WinUI UITests Controls Shell1 ✅ succeeded
WinUI UITests Controls Shell2 ✅ succeeded
WinUI UITests Controls SoftInput,Stepper,Switch,SwipeView ✅ succeeded
WinUI UITests Controls TabbedPage,TableView,TimePicker,TitleView,ToolbarItem,Triggers ✅ succeeded
WinUI UITests Controls ViewBaseTests,VisualStateManager,Window ✅ succeeded
WinUI UITests CV1 Controls (CV1) CollectionView1 ✅ succeeded
WinUI UITests CV1 Controls (CV1) CollectionView2 ✅ succeeded
WinUI UITests CV1 Controls (CV1) CollectionView3 ✅ succeeded
WinUI UITests CV1 Controls (CV1) CollectionView4 ✅ succeeded
WinUI UITests CV1 Controls (CV1) CollectionView5 ✅ succeeded
WinUI UITests CV1 Controls (CV1) CollectionView6 ✅ succeeded
WinUI UITests CV1 Controls (CV1) CollectionView7 ✅ succeeded

Failed tests (15)

Test Platforms
CarouselViewAdjustPeekAreaInsets.ChangePeekAreaInsetsInOnSizeAllocatedTest iOS
CarouselViewPositionVisibility.Issue12848Test iOS
Issue17664.VerifyGroupedCollectionViewVisibleItemIndices iOS
Issue19609.CanTapButtonOnEmptyView iOS
Issue21814.VerifyNavigationEventArgs MacCatalyst
Issue22417.AddItemsToCarouselViewWorks iOS
Issue23902.Issue23902NavigationTest MacCatalyst
Issue27418.CarouselItemsShouldRenderProperly iOS
Issue29544.PreviousPositionUpdatesCorrectlyOnScrollTo MacCatalyst
Issue31680.CollectionViewInsideCarouselViewShouldNotThrowIndexOutOfRangeException iOS
Issue31897.EnsureCollectionViewLayoutOnItemsSourceChange iOS
Issue38730.VerifyVerticalItemSpacingPageRendering MacCatalyst
Issue7678_1.VerifyCarouselViewBindingAndRendering MacCatalyst
Issue7678.VerifyCarouselViewItemsRenderAfterBinding iOS, MacCatalyst
Issue9075.FlexLayoutCycleException iOS
🤖 Why these tests — AI rationale (GPT-6.1 Sol + Claude Opus 5.5)

Each model chose independently; every test that runs was selected by at least one of them.

Platform GPT-6.1 Sol Claude Opus 5.5
Android all categories all categories
iOS all categories all categories
MacCatalyst all categories all categories
Windows all categories all categories

GPT-6.1 Sol — Shared VisualElement and base-handler batching, native-view access and teardown changes require all UI categories on Android, iOS, MacCatalyst and Windows.

  • VisualElement.cs and ElementHandler.cs change shared batching, mapping and teardown: full run on all four platforms.
  • ViewHandler.cs changes native/container access; include Android Material3.
  • Docs, unit tests and benchmarks add no lanes.

Claude Opus 5.5 — Adds handler property-update batching to the base ElementHandler, ViewHandler and VisualElement; runs the full UI test suite on all platforms.

  • ElementHandler.cs, ElementHandlerOfT.cs, ViewHandler.cs and IElementHandler.cs change the base handler pipeline for every control. The PlatformView getter now flushes pending updates, and SetVirtualView clears queued updates. These paths run even with the experimental switch off.
  • VisualElement.cs changes BatchBegin/BatchCommit, which animations and layout use, to call into the handler.
  • These are wide-blast-radius base classes, so full_run is set.
  • The docs, benchmark and unit-test changes do not affect UI tests on their own.

Generated by /review run-tests. A targeted run is a fast signal, not full-suite certification.

kubaflo added a commit that referenced this pull request Nov 30, 2026
…p the zero-spacing item decoration (#40901)

<!-- copilot-assessment:v1 -->
### Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: `949b79d0638d22483c94bae3f804090cd6646aca`

| Dimension | Assessment | Rationale |
|---|---|---|
| Change confidence | 8.5/10 | ↑ Android CollectionViewTests and
CarouselViewTests pass on this revision: 314 passed, 1 skipped by its
attribute, 0 failed (Android 15 emulator).<br>↑ New device tests cover
the selection of recycled rows (Single and Multiple, default color and
Selected visual state) and spacing changes between zero and non-zero
(linear in both orientations, grid).<br>↑ A trace shows the removed work
gone (selection 2.2% and GetItemOffsets 0.8% of UI-thread samples, both
to 0), with allocations unchanged.<br>↓ No speed-up is measurable on the
emulator, and the A/B included a third commit that is no longer part of
this PR.<br>↓ Android UI tests, CI and physical devices not run
yet.<br>↓ OnSelectedChanged is no longer called on bind or recycle when
the selection doesn't change, which a custom SelectableViewHolder
subclass could notice. |
<!-- /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).

This is .NET 12 performance work, so it targets `main`.

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

<!-- Enter description of the fix in this section -->

When a CollectionView scrolls on Android, every row that comes into view
is bound and every row that leaves it is recycled. Two parts of that
work called into Java (or were called from Java) for every row without
changing anything. This PR removes those calls. What the user sees
doesn't change.

#### 1. Don't reapply an unchanged selection

Files: `SelectableViewHolder.cs`, `SelectableItemsViewAdapter.cs`,
`TemplatedItemViewHolder.cs`

`SelectableItemsViewAdapter` sets `SelectableViewHolder.IsSelected` for
every item it binds and every holder it recycles. The setter always
applied the value:
- It set the item view's `Foreground`, `Background`, `Activated` and
`Selected`. Each of these is a JNI call after a JNI read of
`ViewHolder.ItemView`.
- It scanned the content's visual state groups and set `IsItemSelected`.

With `SelectionMode.None` the value is always `false`. So for every row
it scrolled, a list made 8 JNI field reads (with peer lookups) and 8 JNI
property sets that changed nothing.

Binding and recycling now call a new internal `UpdateIsSelected`, which
skips a value that the item view and its content already show.
- A holder applies its selection the first time it is bound.
- It applies it again after `TemplatedItemViewHolder` replaces its
content: new content isn't selected yet, and its visual states decide
whether the default selection color applies.
- Selection changes still set `IsSelected` as before:
`MarkPlatformSelection`, `ClearPlatformSelection` and clicks, including
the unconditional re-sync from #31591. The public `IsSelected` setter is
unchanged.

#### 2. No item decoration without item spacing

File: `MauiRecyclerView.cs` (`UpdateItemSpacing`)

`UpdateItemSpacing` always added a `SpacingItemDecoration`, even when
the spacing is zero, which is the default. Its `GetItemOffsets` then
offsets nothing. RecyclerView still calls it from Java for every row it
binds, and each call looks up the peers of its four arguments and calls
back into Java for `base.GetItemOffsets`.

Now no decoration is added without spacing; the RecyclerView's padding
is still reset as before.
- Changing the spacing to or from zero removes or adds the decoration.
- A decoration from an overridden `CreateSpacingDecoration` is always
added, including a subclass of `SpacingItemDecoration`.
- CarouselView uses its own decoration and is not affected.

#### Why it's safe

- **Selection:** the check only skips writing values that are already
applied. It is reset whenever a holder's content is replaced. Holders
that RecyclerView keeps in its view cache stay in `_currentViewHolders`,
so selection changes still reach them.
- **Decoration:**
- A decoration whose offsets are all zero has the same effect as no
decoration.
- RecyclerView's `willNotDraw` stays `false`, because CollectionView
doesn't set `OverScrollMode.Never`.
- `InvalidateItemDecorations()` becomes a no-op when there's nothing to
invalidate.

#### Behavior changes

- `SelectableViewHolder.OnSelectedChanged()` (protected virtual) is no
longer called when binding or recycling a holder doesn't change its
selection. A custom subclass that used it as a per-bind hook would see
fewer calls.
- Selection visuals are reapplied only when the selection changes or the
holder's content is replaced, not at every bind.
- With zero spacing, `MauiRecyclerView.ItemDecorationCount` is 0 instead
of 1.

#### Results

The numbers come from the CollectionView scroll benchmark
([source](https://github.com/dotnet/maui/tree/simonrozsival-collectionview-scroll-benchmark/src/Controls/tests/CollectionViewScrollBenchmark),
pushed for reference; it isn't part of this or any PR).
- What it scrolls: a CollectionView of 1,000 items. Each row is a Grid
with a BoxView, 7 Labels, a ProgressBar and a CheckBox, with 13 compiled
bindings and the default `SelectionMode.None` and zero spacing.
- How it scrolls: 100 dp per frame for 240 frames per pass, which binds
about 267 rows per pass.
- Method: base and candidate launches are interleaved. Each launch is
reduced to the median of its 5 warm passes, launches are paired by
round, and the result is the median paired difference with a 95%
sign-test interval.

Setup:
- Base is main bd40bc6.
- The candidate is this PR plus a third commit that coalesced layout
requests during a rebind. I dropped that commit from this PR because it
added machinery to Core without a measurable gain. **So the A/B measured
all three changes together.**
- Device: an Android 15 emulator (Pixel 6 profile, android-35
google_apis arm64-v8a, 4 cores, 4 GB) on a shared, heavily loaded Mac
(load average 15–64).
- Runtime: CoreCLR .NET 12.0.0-alpha.1.26523.103, Release builds.

**Allocations are unchanged:** 20,009 B/row in both (difference 0 [0 ..
0]), with 2 gen0 GCs per pass.

**Timing: no significant difference.** The emulator resolves only
differences of about 20% or more.

| Run (rounds) | Rebind, UI-thread CPU per row | UI-thread CPU per row |
Wall time per pass |
|---|---|---|---|
| 1, vs main build (12) | +5.5% [−24.1 .. 56.1 µs] | +7.5% [−70 .. 390
µs] | +20.6% [34 .. 2,584 ms] * |
| 2, vs main build, reversed order (12) | +6.6% [−17.0 .. 28.8 µs] |
+8.8% [−116 .. 170 µs] | +0.7% [−81 .. 211 ms] |
| 3, vs main built in the same checkout (10) | +1.5% [−15.9 .. 10.6 µs]
| −2.6% [−88.6 .. 60.8 µs] | 0.0% [−86 .. 3 ms] |
| 3, control: main vs main, two builds (10) | +2.8% [−3.1 .. 15.6 µs] |
+2.6% [−22.0 .. 139.8 µs] | +0.1% [−1 .. 85 ms] |

In run 1, the candidate's slow passes also took more UI-thread CPU for
the same rows. That points to the emulator losing CPU to the host rather
than to the change, and runs 2 and 3 didn't reproduce it. Run 3's
control shows the same small lean between two builds of the same commit.

**Trace evidence for the two changes in this PR.** I traced the
candidate with the EventPipe sample profiler over 8 warm passes (2,136
rows) and compared it with a trace of main. The traces were taken at
different times, so compare shares, not totals.

| UI-thread samples | main | candidate |
|---|---|---|
| Total | 1,434 | 1,095 |
| `SelectableViewHolder` frames (`SetSelectionStates`, the `IsSelected`
setter) | 32 (2.2%) | 0 |
| … of which JNI reads of `ViewHolder.ItemView` (`GetObjectField`) | 18
(1.3%) | 0 |
| `SpacingItemDecoration.GetItemOffsets`, called from Java | 11 (0.8%) |
0 |

Per bound row, the two changes remove:
- 8 JNI property sets and 8 JNI field reads, when the selection doesn't
change;
- 1 call from Java into .NET with 4 peer lookups, plus 1 call back into
Java, when there's no spacing.

#### Tests

New device tests in `CollectionViewTests.Android.cs`:
- `RecycledItemsShowTheirOwnSelection` (4 cases). Single and Multiple
selection, each with the default selection color and with a template
that colors selection through a `Selected` visual state. It scrolls so
that rows are recycled, changes the selection while the selected item is
out of view, and turns selection off. Every row in view must show the
selection of the item it is bound to: `IsSelected`, `Activated`,
`Selected`, `IsItemSelected`, the default color and the visual state.
- `LinearItemSpacingChangesBetweenZeroAndNonZero` (vertical,
horizontal). It checks the decoration count and item bounds as the
spacing goes 0 → 40 px → 0 → 40 px.
- `GridItemOffsetsExcludeCrossAxisOuterSpacing` (existing, 4 cases) now
also checks the decoration count and the non-zero → zero transition.

Run on this revision, on an Android 15 (API 35) emulator, Release:

```
pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform android -DeviceUdid emulator-5620 -DotnetPath $PWD/.dotnet/dotnet -IncludeClasses 'Microsoft.Maui.DeviceTests.CollectionViewTests,Microsoft.Maui.DeviceTests.CarouselViewTests' -Timeout 01:30:00
```

Result: **Passed.** 315 total, 314 passed, 1 skipped
(`CellSizeAccountsForMargin`, skipped by its attribute), 0 failed.

`dotnet format whitespace --folder --verify-no-changes` on the changed
files reports nothing new. `SelectableItemsViewAdapter.cs` has 27
whitespace issues that are also on main; I left them, because #40881
reformats that file.

Not run:
- Android UI tests (Appium), including the selection screenshot tests;
left to CI.
- Physical devices.
- iOS, Mac Catalyst and Windows, which these Android-only files don't
affect.
- Unit tests, since no shared code changed.

#### Overlap with #40881

#40881 also edits `SelectableItemsViewAdapter.cs`. Merging the two
conflicts in `OnViewRecycled`, where each PR changes one of two adjacent
lines. The bind path merges cleanly. The resolution keeps both:

```csharp
selectable.Clicked -= SelectableClickedHandler;
selectable.UpdateIsSelected(false);
```

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

None; this was found by profiling.

Related:
- #40881 also edits `SelectableItemsViewAdapter.cs`; see above.
- #40318 (inflight/11.0.1xx-sr3) composes with the decoration change:
its checks treat a missing decoration like a zero-spacing one.
- #37337 is opt-in handler update batching.
- #31591 re-syncs selection on click; that path is unchanged here.
- #38969 and #39661 also changed the spacing decoration (its cost and
its outer-edge spacing).

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

This comment has been minimized.

@github-actions github-actions Bot added the s/autopilot-running MAUI Autopilot loop is running; remove this label to stop it label Dec 1, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot added the s/autopilot-fixing MAUI Autopilot: fixing review findings or failing tests (GPT-6.2 Sol vs MAI Code 2) label Dec 1, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

# Conflicts:
#	src/Core/src/Handlers/Element/ElementHandler.cs
#	src/Core/src/Handlers/IElementHandler.cs
#	src/Core/tests/UnitTests/AbstractViewHandlerTests.cs
@github-actions github-actions Bot added s/autopilot-reviewing MAUI Autopilot: MAUI expert review in progress and removed s/autopilot-fixing MAUI Autopilot: fixing review findings or failing tests (GPT-6.2 Sol vs MAI Code 2) labels Dec 1, 2026

@github-actions github-actions Bot 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.

Expert Review — 4 findings

Reviewed commit 48d8389.

See inline comments for details.

var property = node.Property!;
_pendingPropertyUpdateHead = node.Next;
indices.Remove(property);
InvokeCurrentPropertyMapper(property);

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.

[major] Logic and Correctness Verification - Earlier queued mappers can overwrite values that later queued mappers are supposed to apply. With the primary batching switch enabled before VisualElement initialization, take a connected Windows Entry displaying "a" and execute BatchBegin(); Text = "abcdef"; CursorPosition = 2; SelectionLength = 2; BatchCommit();. The Text mapper runs first through Controls' Windows TextBoxExtensions.UpdateText, which changes native text and calls Select(cursorPosition, 0). EntryHandler.OnPlatformSelectionChanged writes that caret and zero selection length back through ITextInput into the managed properties, overwriting the requested selection before its pending mappers read it. Without batching, the selection assignments follow Text's native callbacks and survive. Preserve pending selection intent across native feedback and add a real Windows Entry regression test; the added list/counter-only mapper tests cannot detect this lost selection.

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.

MAUI Autopilot · round 1

❌ Not changed. The Windows Entry fix and regression tests could not be published: the append-only push was rejected because existing PR history includes a documentation path outside the allowed paths. The Windows tests still need a Windows runner.


bool IPropertyUpdateBatchingElement.IsAutomaticPropertyUpdateBatchingEnabled => false;

bool IPropertyUpdateBatchingElement.IsPropertyUpdateBatchingExplicitlyScoped => true;

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.

[moderate] Regression Prevention and Test Coverage - These fixtures replace VisualElement's switch-backed batching contract, and AlwaysBatchingButton reports an open explicit scope before BatchBegin. Returning false from the production enabled property would leave the batching assertions unchanged; removing the explicit-only BeginPropertyUpdateBatch notification is also masked by this pre-opened scope. The benchmark overrides the interface too, while Controls' TestBatching has no attached handler. Add isolated switch-initialization coverage with an unmodified control and attached handler, checking the disabled case, primary-switch-only batching, automatic batching, updates outside a scope, and nested commits.

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.

MAUI Autopilot · round 1

❌ Not changed. The isolated startup-switch test passed locally without changing production switch caching, but the append-only push was rejected because existing PR history includes a documentation path outside the allowed paths.

handler = new HandlerStub(mapper);
var view = new AlwaysBatchingButton();

handler.SetVirtualView(view);

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.

[moderate] Regression Prevention and Test Coverage - SetVirtualView executes the initial First mapper, whose FlushPendingPropertyUpdates call ends explicit batching during setup. After mapped.Clear(), both UpdateValue calls therefore execute immediately and the final flush is empty. The First/Second assertion never exercises a reentrant commit with Second still queued, so it cannot detect dropped work in the active-drain scenario. Suppress the commit during initialization, begin a fresh batch afterward, and assert that nothing mapped before triggering the flush. The reflection-based companion covers the different outside-drain scenario.

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.

MAUI Autopilot · round 1

❌ Not changed. The corrected reentrant-commit test passed locally, but the append-only push was rejected because existing PR history includes a documentation path outside the allowed paths.

// BatchedPropertyUpdatesResolveChainedMapperAtFlushTime); switching this to the
// cached path would silently drop any chained-mapper customization applied
// between when a property was queued and when it is flushed.
_mapper.GetProperty(property)?.Invoke(this, VirtualView!);

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.

[minor] Complexity Reduction - This separate mapper-invocation path duplicates existing infrastructure and drops its instrumentation. With HANDLER_INSTRUMENTATION enabled and an ActivityListener attached, explicit-batch flushes and automatic trailing updates execute without the MapProperty activities emitted by PropertyMapper.UpdateProperty, so their mapper work disappears from attribution. The historical reason in the comment no longer applies to this pinned source: PropertyMapper.Merged validates ChainVersion across chained mappers and rebuilds after parent customization. Reuse the existing UpdateProperty invocation path for queued updates to preserve both live chained customization and instrumentation.

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.

MAUI Autopilot · round 1

❌ Not changed. The local instrumentation test failed on the original direct mapper path and passed with the shared path, but the append-only push was rejected because existing PR history includes a documentation path outside the allowed paths.

@github-actions github-actions Bot added s/autopilot-fixing MAUI Autopilot: fixing review findings or failing tests (GPT-6.2 Sol vs MAI Code 2) and removed s/autopilot-reviewing MAUI Autopilot: MAUI expert review in progress labels Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

MAUI Autopilot · round 1

No fixes were published: the push was rejected because the existing PR history includes docs/design/HandlerUpdateBatching.md, which is outside the allowed paths. The four local commits change only src/; the PR branch and review threads remain unchanged.

@github-actions github-actions Bot added s/autopilot-testing MAUI Autopilot: relevant UI/device tests are being selected or run and removed s/autopilot-fixing MAUI Autopilot: fixing review findings or failing tests (GPT-6.2 Sol vs MAI Code 2) labels Dec 1, 2026
@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added s/autopilot-fixing MAUI Autopilot: fixing review findings or failing tests (GPT-6.2 Sol vs MAI Code 2) and removed s/autopilot-testing MAUI Autopilot: relevant UI/device tests are being selected or run labels Dec 1, 2026
kubaflo added a commit that referenced this pull request Dec 1, 2026
…hout a proposal (#40919)

<!-- copilot-assessment:v1 -->
### Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: `11c30c44a06a0739ce0715e1b6f5aecbd44f3fc9`

| Dimension | Assessment | Rationale |
|---|---|---|
| Change confidence | 9/10 | ↑ Replayed the job condition on real run
results: MAI run 46558270750 (agent success, no proposal) now hands
over; normal runs and agent-failure-after-proposal unchanged.<br>↑
`review-run-tests-dispatch.yml` already handles one or both proposals
missing and posts a result.<br>↑ Both workflows compile.<br>↓ Live check
pending merge. |
| Diagnosis confidence | 9.5/10 | ↑ MAI agent log: "Unable to complete
because I did not call the required test-selection output tool";
`agent_output.json` has 0 items; `run_selected_ui_tests` and
`run-tests-fallback` both skipped; no dispatch run for #37337. |
| Evidence fit | 9.5/10 | ↑ #37337 has sat in `s/autopilot-testing`
since 01:59 with no test comment for its head. |
<!-- /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!

### Description of Change

`/review run-tests` selects tests with two models in sequence, then
`review-run-tests-dispatch.yml` combines their proposals and posts the
result. The fallback that hands over without a proposal ran only when
the agent job **failed**.

For #37337 the MAI Code 2 agent **succeeded** but never called the
selection tool, so `run_selected_ui_tests` and `run-tests-fallback` were
both skipped. Nothing was dispatched, no result comment was posted, and
MAUI Autopilot waits in `testing` forever.

The fallback in both `copilot-review-run-tests` and
`copilot-review-run-tests-mai` now also runs when the agent succeeded
but nothing was dispatched.

Validation: replayed the job condition against real run results; `gh aw
compile` succeeds for both workflows.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot removed s/autopilot-running MAUI Autopilot loop is running; remove this label to stop it s/autopilot-fixing MAUI Autopilot: fixing review findings or failing tests (GPT-6.2 Sol vs MAI Code 2) labels Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

MAUI Autopilot — Stopped

@kubaflo ❌ The last fix round found nothing more it could fix. Decide how to continue, or comment /review autopilot to run it again.

Why

No fixes were published. The PR is still on the same head that the append-only push rejected because its existing diff includes docs/design/HandlerUpdateBatching.md, outside the permitted src/ scope. The branch and all review threads were left unchanged.

[Run](https://github.com/dotnet/maui/actions/runs/46570528912).

@github-actions github-actions Bot added the s/autopilot-needs-maintainer-decision MAUI Autopilot stopped: a maintainer needs to decide how to continue label Dec 1, 2026

This branch was previously deployed

1 inactive (outdated) deployment
copilot-pat-pool — 8e4d85a0 Deployed Aug 12, 2026 by StephaneDelcroix via conclusion #1249
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge Don't merge this PR s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-win AI found a better alternative fix than the PR 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) s/autopilot-needs-maintainer-decision MAUI Autopilot stopped: a maintainer needs to decide how to continue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants