Skip to content

Fix for concurrent bindable-property updates by using a thread-local stack for pending handler updates - #40234

Closed
BagavathiPerumal wants to merge 9 commits into
dotnet:net11from
BagavathiPerumal:fix-37441
Closed

BagavathiPerumal wants to merge 9 commits into
dotnet:net11from
BagavathiPerumal:fix-37441

Conversation

@BagavathiPerumal

@BagavathiPerumal BagavathiPerumal commented Nov 13, 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!

Root cause

The issue occurs because Element.OnBindablePropertySet uses a per-element HashSet to track pending handler updates. HashSet is not thread-safe, so when multiple threads update different bindable properties on the same Element, concurrent Add, Contains, and Remove operations can corrupt the collection. This can result in exceptions such as IndexOutOfRangeException or InvalidOperationException.
The implementation must also correctly handle nested property changes so that a nested SetValue does not incorrectly remove a pending marker belonging to an outer property update. A lock-based solution was avoided because holding a lock across framework and application callbacks could introduce deadlocks and unnecessary contention.

Solution description

The fix replaces the per-element HashSet with a thread-local stack. Each entry stores the Element instance and the property name of a pending handler update. Each thread keeps its own pending-update state, so concurrent threads no longer modify the same tracking collection. The stack also supports nested property changes. A finally block removes the pending entry even if property-change processing throws an exception.

The fix also keeps the intended property-update order: OnPropertyChanged, then bindable-property change notifications, then Handler.UpdateValue. It does this without holding a lock across framework or application callbacks.

The fix also queues the entire visual state transition on the element's handler dispatcher when the dispatcher reports that dispatch is required. State changes and native property updates therefore run on the UI thread. The background-thread caller does not wait for the queued transition, which avoids deadlocks when the UI thread is waiting on that caller. For these background-thread calls, a true return value means the transition was queued, not that the state was found or applied. Exceptions thrown by a queued transition are caught and logged through the element's MAUI logger, if one is configured. Existing synchronous behaviour, including the return value and exception behaviour, is unchanged when dispatch is not required or when the element has no handler or dispatcher.

Validated the behavior in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Issues Fixed

Fixes #37441

Output ScreenShot

Platform Before After
Android
37441-Android.BeforeFix.mov
37441-Android-AfterFix.mov
iOS
37441-iOS.BeforeFix.mov
37441-iOS-AfterFix.mov
Mac
37441-Mac.BeforeFix.mov
37441-MacAfterFix.mov
Windows
37441-Windows.BeforeFix.1.mp4
37441-Windows.AfterFix.1.mp4

@github-actions

This comment has been minimized.

@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Nov 13, 2026
@azure-pipelines

This comment has been minimized.

@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 Nov 13, 2026
@kubaflo

kubaflo commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

/rebase

@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@MauiBot

MauiBot commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@BagavathiPerumal — existing-test verification; Setup did not capture a tested commit.

Result INCONCLUSIVE Platform Android


🧪 Gate analysis — click to expand

⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect.

No interpretable test-group summary was produced. No additional test execution is inferred.

Setup did not capture a verified PR head; no commit is claimed as tested.

No immutable without-fix baseline was prepared.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Nov 13, 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 — 3 findings

Reviewed commit 998928f.

See inline comments for details.

@kubaflo

This comment has been minimized.

@github-actions

This comment has been minimized.

@vishnumenon2684

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@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 Nov 16, 2026
@MauiBot

MauiBot commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@BagavathiPerumal — existing-test verification; Setup did not capture a tested commit.

Result INCONCLUSIVE Platform Android


🧪 Gate analysis — click to expand

⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect.

No interpretable test-group summary was produced. No additional test execution is inferred.

Setup did not capture a verified PR head; no commit is claimed as tested.

No immutable without-fix baseline was prepared.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Nov 16, 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 — 5 findings

Reviewed commit 65721cb.

See inline comments for details.

@vishnumenon2684

This comment has been minimized.

@azure-pipelines

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 — 7 findings

Reviewed commit 09d73a0.

See inline comments for details.

kubaflo and others added 8 commits November 24, 2026 15:26
)

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

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

Most of the recent `net11` `maui-pr-uitests` red comes from Android API
30 jobs that are cancelled at the 240-minute job limit. The cause is a
lost emulator, not product regressions.

**What happens** (raw logs of build
[1680926](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1680926)
and
[1680462](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1680462),
e.g. API 30 Navigation and API 30 CollectionView3):

1. The emulator boots normally, and tests run for about 9–12 minutes.
2. `[Logcat] Logcat terminated with code 255` appears and adb reports
`device 'emulator-5554' not found`. The emulator is gone.
3. The remaining fixtures of attempt 1 fail quickly once session
recreation fails.
4. `RunUITestsWithRetry` starts **UI test attempt 2** against the
still-missing device. Every fixture now waits about 3.7 minutes in
`AppiumServerContext.CreateUIClientContext`: 11 tries × Appium's
20-second "Could not find a connected Android device".
5. The job runs until Azure DevOps cancels it at 240 minutes. Most of
the failed rows in those builds are these setup failures.

The same tests pass on `candidate/11.0.1xx-sr2`, and none of
`eng/devices`, `UITest.Appium` or `UITest.NUnit` differs between
`net11`, the candidate and `main`. So this is an infrastructure flake
that the retry path amplifies, with no existing fix to backport.

**Fix**

- `RunUITestsWithRetry` gets an optional `beforeAttempt` hook that runs
before **every** attempt, including attempt 1. The iOS, Mac Catalyst and
Windows callers are unchanged.
- Running it only before retries was not enough. In this PR's run
[1682445](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1682445),
three API 30 jobs installed the app and then lost the emulator during
the roughly 2-minute UI-test project build, before attempt 1. Every
fixture in attempt 1 then waited 3 min 40 s (Shell1: 68 fixtures,
CarouselView: 99, 0 passed), and the jobs were cancelled at 240 minutes
before the retry hook could run.
- On Android, the hook checks `sys.boot_completed`:
  - If the device is healthy, it does nothing (one `getprop`).
- If the emulator started by the script is gone, it cleans up, restarts
the emulator through the existing `HandleVirtualDevice` path, and
reinstalls the app with `ExecutePrepareUITests` before the attempt.
- If that cleanup throws (for example `AdbEmuKill` fails), the hook
kills the old emulator process directly before restarting, so the same
AVD is never started twice. In a local fault-injection check, the
previous code left the old PID alive, started a duplicate, and timed out
after about 10 minutes; with this fallback, recovery finished in 39 s.
- Before restarting, the hook waits (bounded by
`EmulatorKillTimeoutSeconds`) until the old process has **confirmed
exited**. If it hasn't, the hook fails the attempt rather than start a
duplicate instance of the same AVD.
- If the device was not started by the script, it logs a warning and
runs the tests as before. Local runs against a user-supplied device are
unchanged.
- `uitest-retry.cake`: a retry no longer leaves never-run ignored tests
as failures. When the device is lost during a fixture's OneTimeSetUp,
NUnit fails every child with `site="Parent"`. If OneTimeTearDown also
throws, the fixture site becomes `TearDown` instead of `SetUp`. Ignored
tests then come back from a green retry as Skipped/Ignored: either a
static `[Ignore]` with the same reason, or a runtime `Assert.Ignore`
with `runstate="Runnable"`. The merge accepted only the
`SetUp`+static-reason shape, so the job failed even though the retry was
green.
- The merge now treats a parent-site error as never-run when the fixture
failed in setup (site `SetUp`, or the child's message starts with
`OneTimeSetUp:`). It accepts a retry that ignores such a test, and
accepts fixtures that contain only such recovered ignores. A test that
actually ran and failed is still never accepted.

**Validation**

- `dotnet cake eng/devices/{android,catalyst,windows,ios}.cake
--target=uitest --dryrun` compiles. iOS has the same pre-existing local
teardown error with and without this change.
- Local end-to-end check on an API 30 arm64 emulator (adb pinned to
`emulator-5554`): a temporary target ran the real `connectToDevice` and
`uitest-prepare` (installed the app), then called
`EnsureDeviceForUITestAttempt` as at the attempt-1 call site.

  | Case | Result |
  | --- | --- |
  | Healthy device | Hook returned in 0.0 s (no-op) |
| `adb emu kill` after install (the 1682445 mode) | `boot_completed` →
null; hook logged the warning, restarted the emulator, and reinstalled
the app (XHarness exit code 0) in 46 s; afterwards `boot_completed` = 1
and `pm path` showed the app |
  | Healthy again after recovery | 0.0 s no-op |
| Missing device not started by the script | Warning logged, no throw |

- Confirmed-exit fault injection (local, API 30):

  | Scenario | Before | After |
  | --- | --- | --- |
| Cleanup returns but the emulator stays alive | Duplicate start; boot
timed out after 10m32s | Attempt fails after 60 s with "did not exit …
not restarting"; no duplicate |
| Emulator killed externally | — | One restart, app reinstalled,
XHarness exit 0 (49 s) |
| Cleanup throws | — | Direct kill, one restart, XHarness exit 0 (41 s)
|

- **CI proof of recovery:** in this PR's run
[1682664](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1682664),
Controls (API 30) Label lost the emulator during attempt 1. All 126
tests failed in OneTimeSetUp, about 3m40s each. Before attempt 2 the
hook restarted Emulator_30 and reinstalled the app, and **attempt 2
passed 124 tests with 2 skipped** in 14 minutes.
- **Retry merge:** that job was still marked failed because two
never-run ignored tests stayed Failed: `Issue488TestsLongTextRotation`
(static `[Ignore]`, fixture site `TearDown`) and
`LabelUITests.IsEnabled` (runtime `Assert.Ignore`). The real TRX and
NUnit XML from both attempts were replayed offline through
`UITestRetry.MergeResults`:

  | Input | Before | After |
  | --- | --- | --- |
| Real 1682664 Label artifacts | Merged outcome Failed (`IsEnabled`,
`Issue488TestsLongTextRotation`) | Completed, 0 failed, no run errors |
  | Retry `IsEnabled` actually fails | — | Failed |
  | Original `IsEnabled` actually ran (site not Parent) | — | Failed |
  | Static ignore reason mismatch | — | Failed |
  | No `OneTimeSetUp:` evidence | — | Failed |

The replay harness was local only; no test was committed, per policy for
CI scripts.
- Final validation is this PR's own `maui-pr-uitests` run.

Fixes Android API 30 `maui-pr-uitests` jobs on `net11` hanging until the
240-minute timeout after the emulator is lost mid-run. Also fixes
recovered retries still failing the job when never-run ignored tests
come back as Skipped/Ignored.

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…ing bindable property updates during reentrant calls and dispatch VisualStateManager transitions to the UI thread when required.
…evaluate triggers on the UI dispatcher, and handle disposed window scopes safely
@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 — 7 findings · ⚠️ 2 breaking changes

Reviewed commit 5186103.

Warning

Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:

See inline comments for details.

}

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

[major] Behavioral Change Disclosure - A worker calling GoToState(label, "MissingState") on a handler-connected label without visual-state groups previously received false synchronously and could run its fallback. When its dispatcher requires dispatch, this now returns true even though no state will be applied, skipping that fallback. Likewise, an existing state with empty setters previously updated CurrentState before return; now that update is deferred. These previously working managed-only cases do not depend on the concurrency defect or native thread-affinity violations. The XML and PR description explain queue acceptance, but there is no compatibility opt-in/opt-out preserving the existing result/completion contract. Provide the target-appropriate compatibility gate and explicitly identify the contract break in breaking-change/release notes.

{
group.UpdateStateTriggersCore(requestVersion);
}
catch (Exception exception)

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] Behavioral Change Disclosure - Deferred trigger evaluation also drops previously observable transition notifications. Configure a handler-connected custom Label with an initialized, unmapped integer property defaulting to 0, an active fallback state setting it to 0, and a higher-priority custom trigger whose state sets it to 1. Toggle that trigger true then false on one worker before the UI dispatcher drains. Previously the managed-only transitions ran synchronously and property observers received 1 then 0; now both evaluations read the final inactive trigger, retain Fallback, and emit neither notification. No concurrent property writes or native-thread violation is required. Disclose this trigger coalescing and provide the target-appropriate opt-in/opt-out preserving existing transition notifications; no compatibility mechanism is present.

}

internal static bool TryUpdateStateRequestVersion(VisualStateGroup group, long requestVersion) =>
s_stateGroupRequestVersions.GetValue(group, static _ => new StateRequestVersion()).TryUpdate(requestVersion);

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 - Request versions are generated per element but retained per group across ownership changes. Transition an Off/On group repeatedly on label A, remove it from A’s groups, and add that same group to a fresh label B. OnGroupRemoving clears CurrentState but not the stored group version. B’s smaller request numbers are rejected by TryUpdate, so GoToState returns true without applying states or setters until B’s counter catches up; trigger transitions are rejected too. This also fails synchronously without a handler. Scope accepted versions to the owning element, or use a shared ordering domain, and add a managed transfer test asserting that B’s first requested state and setter value apply independently of A’s request count.


foreach (var pendingUpdate in s_pendingHandlerUpdatesFromBPSet)
{
if (ReferenceEquals(pendingUpdate.Element, this) &&

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 - The element-identity guard still has no discriminating negative-case test. Both added device tests and the existing #23746 ordering tests use one target. Removing ReferenceEquals would suppress element B’s direct notification for the same property name while element A has that property pending, without failing these assertions. Add a managed ElementTests case raising B’s notification inside A’s callback and assert that B’s handler receives the update while A’s update remains deferred.

changed,
willFirePropertyChanged);
}
finally

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 - Exception cleanup and genuinely nested non-notifying updates remain uncovered. The existing #23746 reentrant test sets the same property again, which BindableObject.IsBeingSet queues rather than nesting OnBindablePropertySet. Moving Pop out of finally leaves a stale marker after a callback throws, suppressing a later direct notification; popping unconditionally during a nested non-effective ClearValue consumes the outer marker despite willFirePropertyChanged being false. Add deterministic managed tests asserting that a notification after a caught callback exception reaches the handler and that nested non-effective ClearValue preserves the outer notification-before-handler order without unbalancing the stack.

{
GoToStateCore(visualElement, name, force, requestVersion);
}
catch (Exception exception)

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 - The new exception test exercises only the separate UpdateStateTriggers dispatch callback. Direct queued GoToState requests still use only valid setters, so removing this catch would let their failures escape the dispatcher without failing the added assertions. Use an existing namescope and an unresolved Setter.TargetName in a controlled-dispatcher unit test: draining a direct request must not throw, a configured logger must receive the failure, and the same request with dispatch disabled must propagate XamlParseException. The trigger test does not protect this independent catch or synchronous behavior.

{
context = visualElement.Handler?.MauiContext;
dispatcher = null;
if (IsWindowScopeDisposed(context))

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 - The disposed-window guards have no discriminating VSM regression coverage. Every new controlled-dispatcher fixture substitutes IMauiContext, so IsWindowScopeDisposed is always false; existing mapper-teardown tests do not exercise GoToState’s new service resolution. Add managed tests with a real MauiContext: a live scope must apply the state, a disposed scope must return false without resolving dispatcher services, and disposing after enqueue must leave state/setter values unchanged when the callback drains. The live-window device scenario cannot detect removal of these disposal guards.

@kubaflo
kubaflo deleted the branch dotnet:net11 November 24, 2026 14:43
@kubaflo kubaflo closed this Nov 24, 2026
@kubaflo kubaflo reopened this Nov 24, 2026
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 24, 2026 14:49 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 24, 2026 14:49 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 24, 2026 14:50 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 24, 2026 14:52 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 24, 2026 14:55 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 24, 2026 14:55 — with GitHub Actions Inactive
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Nov 26, 2026
…dotnet#40305)

<!-- 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!

### Target Branch

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

CI and workflow infrastructure, so it targets `main`. The slash command
activates only once the workflow is on the default branch.

### Description of Change

Adds `/review run-tests`. Two AI models, **GPT-6.1 Sol** and **Claude
Opus 5.5**, each read the PR diff independently and pick the UI test
categories and platforms it can affect. `maui-pr-uitests` then runs
**only the union of their picks**. A CollectionView-only Android fix
runs the CollectionView shards on Android, not all 77 categories on 4
platforms.

Replaces dotnet#40253.

**When what runs**

| Trigger | What runs |
| --- | --- |
| `/review run-tests` on any PR (write access) | Only what the models
selected: the per-platform union of both picks |
| Both models choose the full suite (e.g. core `Element` changes) | Full
suite |
| Neither model produces a pick | Nothing is queued; the comment says so
|
| `/azp run maui-pr-uitests` | Full suite, unchanged |
| Branch, scheduled and manual builds (`main`, `release/*`,
`candidate/*`, …) | Full suite, unchanged. `ci-uitests.yml` only passes
a selection when `Build.SourceBranch` is `refs/pull/*`. |

Nothing is ever added that a model did not choose: no full-suite
fallback, unknown category names run nothing, Android and the Material3
lane run only when selected (also enforced in the pipeline template),
and only the five declared proposal fields are read.

**What the requester sees**

1. **Native checks in the PR's checks list.** `maui-pr-uitests` is
queued through the Build API as a *pull-request* build
(`reason=pullRequest` + `triggerInfo.pr.sourceSha`), so Azure Pipelines
reports the run and every job as checks on the PR head, exactly like
`/azp run`.
2. **Skipped checks for everything not selected.** One `maui-pr-uitests
(skipped) <Category>` check per category and one `maui-pr-uitests
(skipped) <Platform> UITests` check per platform, plus a
`maui-pr-uitests (test selection)` summary check.
3. **A summary comment in the PR Test Gate layout:** title, requester
line and Result / Platforms / Categories / Commit badges, with
everything else in one collapsed **Test selection** section: build
status, each model's summary, what ran, results with failed tests, the
skipped list, and **Why these tests** with a per-platform table of each
model's pick and both rationales. `review-run-tests-results.yml` updates
it in place when the `maui-pr-uitests` check completes, with a
half-hourly sweep as backup.

**How it works**

| Piece | Role |
| --- | --- |
| `copilot-review-run-tests.md` (gh-aw, GPT-6.1 Sol) | Pre-activation
authorizes an exact `/review run-tests` from a write+ user and collects
the diff, the category inventory from
`eng/pipelines/common/ui-tests.yml`, which categories have enabled tests
per platform, and which the PR's own tests enable. The read-only agent
(`checkout: false`) proposes platforms, categories, `full_run`, a
summary and a rationale. The safe-output job saves the proposal and
starts the Opus workflow. |
| `copilot-review-run-tests-opus.md` (gh-aw, Claude Opus 5.5, new) |
`workflow_dispatch` only. Verifies the source run (run-tests lock
workflow, default branch, same repo, under 3 hours old), reuses its
context artifact, and makes an independent proposal with the same shared
prompt (`shared/run-tests-selection.md`). Then it starts the dispatcher
with both run ids. If either agent fails, the chain still hands over. |
| `review-run-tests-dispatch.yml` | `workflow_dispatch` on `main`, with
**no environment**, so its OIDC subject is
`repo:dotnet/maui:ref:refs/heads/main` like `review-trigger.yml`.
Verifies both runs, downloads each proposal (a listed artifact that
fails to download fails the job), checks each proposal's model and
source run, and runs `Invoke-RunTests.ps1`. |
| `Invoke-RunTests.ps1` | Trusted. Validates each proposal against the
inventory, prunes each platform to categories with enabled tests there,
and merges the two per platform. When every selected platform runs the
same categories they are sent as plain names; otherwise every entry is
platform-qualified (`android:Button`, `ios:Label`), never a mix.
Re-checks the requester's permission, the PR head and its target branch,
waits for a verified test-merge commit, queues the pull-request build
and cancels it if Azure didn't apply the selection. Then publishes the
Skipped and selection checks and the comment. |
| `review-run-tests-results.yml` | Updates the comment when the
`azure-pipelines` `maui-pr-uitests` check completes; sweeps every 30
minutes as backup. |
| `eng/pipelines/**/ui-tests*.yml`, `ci-uitests.yml` | Optional
`selectedRun`, `selectedPlatforms`, `selectedCategories` parameters
filter stages and matrix entries at compile time. `CollectionView` and
`Shell` expand to their shards; `<platform>:<Category>` limits a
category to one platform, and every stage guard, including the dedicated
Shell renderer, SafeAreaEdges, Material3 and Windows CV1 lanes, handles
both the plain and the qualified form. The sample build gets
template-evaluated booleans, never parameter text. Defaults expand to
exactly `main`'s jobs. |
| `review-trigger.yml`, `ReviewCommandHelpers.ps1`, rebalance skill |
`/review run-tests` is excluded from `/review` and from recovery.
`rebalance-ui-test-categories` understands the typed
`categoryGroupsToTest` parameter. |

`/azp run`, `/review`, `/review gate` and `/review tests` are unchanged.
Device tests are out of scope.

**Model policy exception:** the repo's GPT-only automation policy
(`CopilotPipeline.Tests.ps1`, from dotnet#38040) gets one narrow exception:
exactly `claude-opus-5.5`, only in the run-tests selection files (the
Opus workflow and its lock file, the dispatcher, `RunTests.Common.ps1`
and the tests). Any other Claude/Anthropic model, or that model anywhere
else, still fails the test. Opus only proposes a selection; trusted code
validates it, and it can only add tests, never remove the other model's
picks.

**Security review notes:** the new Opus workflow uses only existing
secrets (the `COPILOT_PAT_0..9` pool via `copilot-pat-pool`); the
dispatcher uses the existing `AZDO_TRIGGER_TENANT_ID` /
`AZDO_TRIGGER_CLIENT_ID`. No new third-party actions. All actions are
pinned by SHA.

### Validation

**End to end in a fork (kubaflo/maui)** through the real GPT agent →
Opus agent → dispatcher path, on 8 current PRs. All 24 workflow runs
succeeded; each PR got the comment with both models' picks and the
Skipped checks. Azure is skipped there because the fork has no federated
identity.

**Real builds on dotnet/maui.** Other PRs' merge refs don't have the new
pipeline parameters until this merges, so each trial was a temporary
draft PR: this branch plus one current PR's change.
`Invoke-RunTests.ps1` ran locally with both models' proposals from the
fork run on the same diff, queued `maui-pr-uitests`, and posted the
comment. Every build got exactly the selected platforms and categories.

| Trial | Copy of | GPT-6.1 Sol | Claude Opus 5.5 | Ran | Result |
| --- | --- | --- | --- | --- | --- |
| dotnet#40442 | dotnet#40369 Windows title bar | `Window` | + `TitleView`,
`Lifecycle` | Windows, 3 categories | Passed in 39 min |
| dotnet#40443 | dotnet#40366 Shell modal stack | `Shell1/2` on iOS, Mac | same |
iOS + MacCatalyst | Passed |
| dotnet#40444 | dotnet#40363 Android EmptyView | CollectionView + CarouselView |
same | Android, 8 categories | Passed in 41 min |
| dotnet#40445 | dotnet#40344 Shell tab reselect | `Shell1/2`, `Navigation` | +
`TabbedPage` | All platforms, 4 categories | Running at time of writing
|
| dotnet#40446 | dotnet#40291 `DisplayPromptAsync` | Prompt, Alert, ActionSheet |
same | All platforms, 3 categories | 1 test failed on MacCatalyst |
| dotnet#40447 | dotnet#40234 `Element` / VSM threading | Full suite | Full suite |
Full suite | Running at time of writing |
| dotnet#40448 | dotnet#40385 CodeQL CI-only | Nothing | Nothing | Nothing (no
build) | Comment only |
| dotnet#40449 | dotnet#39487 Button corner radius | `Button`, `ImageButton` on iOS,
Mac | same | iOS + MacCatalyst | 1 Button test failed |

The failures are the same tests that failed in an earlier round on the
same copied changes, so they come from those PRs, not the selection. The
comments were refreshed from the real timelines and test results with
`Update-RunTestsResults.ps1`.

**Azure previews of this PR's merge ref:**
- Defaults: identical to `main` (13 jobs, 157 matrix entries).
- Android `Button`: 2 jobs, no Material3 lane. `Button` + `Material3`:
the Material3 lane is included.
- Qualified selections: `android:Material3` + `ios:Label` runs only the
Material3 lane on Android; `android:Shell1` also runs the Shell renderer
lane; `android:SafeAreaEdges` runs its dedicated lane;
`windows:CollectionView1` runs the CV1 lane; an Android-only
CollectionView pick never starts the Windows CV1 lane.
- `selectedPlatforms` containing `"x; Remove-Item"`: only template
booleans reach the build step.

**Tests:** `RunTests.Tests.ps1` has 39 Pester tests covering the
inventory and `#if` evaluator, pruning and qualification, the two-model
union (one model empty, neither, full only when chosen), AI-only rules,
the queue request and dropped-selection guard, the check plan, comment
rendering and updates, and static template checks. The `ReviewTrigger`,
`Recover-MissedReviewCommands` and `CopilotPipeline` suites pass. `gh aw
compile --strict` succeeds.

**Not verified before merge:**
- The slash command and the dispatcher's OIDC exchange on `dotnet/maui`
itself. GitHub only runs them from the default branch. After merge,
comment `/review run-tests` on a PR to confirm.
- The `check_run`-triggered comment update on `dotnet/maui` (the script
itself is verified; the half-hourly sweep is the backup).
- The `copilot-pat-pool` token selection in the new Opus workflow (the
fork used a single secret).

---------

Co-authored-by: Copilot CI <copilot-ci@microsoft.com>
@BagavathiPerumal

Copy link
Copy Markdown
Contributor Author

The fix adds complexity and introduces breaking changes, so I am closing the PR for now.

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — 5186103f Deployed Nov 24, 2026 by kubaflo via conclusion #3286
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Element._pendingHandlerUpdatesFromBPSet (unsynchronized HashSet<string>) is corrupted by concurrent bindable-property writes

5 participants