Skip to content

[Windows] Fix CollectionView ScrollTo related test cases failed in CI#34907

Merged
kubaflo merged 2 commits intodotnet:inflight/currentfrom
HarishwaranVijayakumar:fix-34772
Apr 24, 2026
Merged

[Windows] Fix CollectionView ScrollTo related test cases failed in CI#34907
kubaflo merged 2 commits intodotnet:inflight/currentfrom
HarishwaranVijayakumar:fix-34772

Conversation

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

  • PR 24867 fixed a COM exception on Windows by wrapping ListViewBase.ScrollIntoView inside DispatcherQueue.TryEnqueue() in ItemsViewHandler.Windows.cs → OnItemsVectorChanged. This changed ScrollIntoView from synchronous to asynchronous execution, introducing a race condition in ScrollTo-related UI tests on Windows.

  • Before 24867

    • Items load → OnItemsVectorChanged → ScrollIntoView fires (sync) → Scrolled event updates label → Test resets label → Label = "Not Fired"
  • After 24867 (async via TryEnqueue):

    • Items load → OnItemsVectorChanged → ScrollIntoView is queued (async) → Test resets label to "Not Fired" → Queued ScrollIntoView fires → Scrolled event overwrites label = "Fired"
  • The deferred ScrollIntoView callback executes after the test has already reset the scroll event labels, causing stale scroll events to overwrite the expected state. Similarly, for ScrollTo(animate: true) tests, the animated scroll produces intermediate Scrolled events that haven't settled to the final index when the test reads the label value.

Description of Change

Test reliability improvements:

  • Added a delay in CollectionViewScrollPage.xaml.cs before resetting scroll event labels to ensure deferred callbacks complete, preventing test flakiness on Windows.
  • Disabled animation for ScrollTo actions on Windows in Issue33614.cs to avoid flaky test results.

Test coverage and platform-specific adjustments:

  • Removed Windows-specific test skip conditions in Issue33614.cs and CollectionView_ScrollingFeatureTests.cs, re-enabling these tests on Windows as the related issues have been resolved. [1] [2] [3] [4]
  • Updated conditional compilation for a grouped list test to only skip on Android, as the Windows issue has been addressed.

Issues Fixed

Fixes #34772

Before After

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 10, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 34907

Or

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

@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Apr 10, 2026
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

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

@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Apr 10, 2026
@sheiksyedm sheiksyedm added the area-testing Unit tests, device tests label Apr 13, 2026
@HarishwaranVijayakumar HarishwaranVijayakumar marked this pull request as ready for review April 13, 2026 12:29
Copilot AI review requested due to automatic review settings April 13, 2026 12:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Improves Windows CI reliability for CollectionView ScrollTo-related UI tests that became flaky after ScrollIntoView started running asynchronously on Windows (via DispatcherQueue.TryEnqueue).

Changes:

  • Re-enabled previously skipped Windows UI tests for CollectionView scrolling/ScrollTo scenarios.
  • Added a delay before resetting scroll event labels on the scrolling feature-matrix page to avoid deferred scroll callbacks overwriting the reset state.
  • Disabled animated ScrollTo on Windows for Issue33614’s HostApp page to reduce timing-related flakiness.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33614.cs Removes Windows-only compilation guard so the Issue33614 UI test runs on Windows again.
src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/CollectionView_ScrollingFeatureTests.cs Removes/relaxes Windows skip conditions so ScrollTo-related feature-matrix tests run on Windows.
src/Controls/tests/TestCases.HostApp/Issues/Issue33614.cs Makes Issue33614’s ScrollTo non-animated on Windows to reduce flaky timing in the HostApp scenario.
src/Controls/tests/TestCases.HostApp/FeatureMatrix/CollectionView/ScrollingFeature/CollectionViewScrollPage.xaml.cs Adds an awaitable delay before resetting scroll event labels to avoid deferred Windows callbacks overwriting expected label state.

Comment thread src/Controls/tests/TestCases.HostApp/Issues/Issue33614.cs
@HarishwaranVijayakumar HarishwaranVijayakumar changed the title [WIP] [Windows] Fix CollectionView ScrollTo related test cases failed in CI [Windows] Fix CollectionView ScrollTo related test cases failed in CI Apr 13, 2026
@sheiksyedm
Copy link
Copy Markdown
Contributor

/azp run maui-pr-uitests

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@MauiBot MauiBot added the s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) label Apr 17, 2026
Copy link
Copy Markdown
Contributor

@kubaflo kubaflo left a comment

Choose a reason for hiding this comment

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

Could you please review ai's suggestions

@dotnet dotnet deleted a comment from MauiBot Apr 24, 2026
@kubaflo kubaflo changed the base branch from main to inflight/current April 24, 2026 10:24
@kubaflo kubaflo merged commit 27e0423 into dotnet:inflight/current Apr 24, 2026
126 of 161 checks passed
@github-actions github-actions Bot added this to the .NET 10 SR7 milestone Apr 24, 2026
@dotnet dotnet deleted a comment from MauiBot Apr 24, 2026
@MauiBot
Copy link
Copy Markdown
Collaborator

MauiBot commented Apr 26, 2026

🤖 AI Summary

👋 @HarishwaranVijayakumar — new AI review results are available. Please review the latest session below.

📊 Review Sessiondb23dc8 · Address copilot concern · 2026-04-26 12:03 UTC
🚦 Gate — Test Before & After Fix

Gate Result: ❌ FAILED

Platform: ANDROID

Gate output log
No PR detected, scanning remote branches for closest base...
✅ Base branch: main (via closest-merge-base)
✅ Merge base commit: 857e11c0
   (2 commits ahead of main)
╔═══════════════════════════════════════════════════════════╗
║         ERROR: NO FIX FILES DETECTED                      ║
╠═══════════════════════════════════════════════════════════╣
║  Full verification mode required but no fix files found.  ║
║                                                           ║
║  Possible causes:                                         ║
║  - No non-test files changed since merge-base             ║
║  - All changes are in test directories                    ║
╚═══════════════════════════════════════════════════════════╝
Debug info:
  Merge base: 857e11c0c4b1c4963f56aaa0c576b1625d1cf4ff
  Base branch: main
  Current branch: HEAD
To fix, try one of:
  1. Specify fix files explicitly: -FixFiles @('path/to/fix.cs')
  2. Remove -RequireFullVerification to run in failure-only mode

🧪 UI Tests — Category Detection

Detected UI test categories: CollectionView


🔍 Pre-Flight — Context & Validation

Issue: #34772 - [Testing][Windows]CollectionView ScrollTo related test cases failed in CI
PR: #34907 - [Windows] Fix CollectionView ScrollTo related test cases failed in CI
Platforms Affected: Windows (test reliability fix; gate run on Android)
Files Changed: 0 implementation, 4 test

Key Findings

  • All changes are test-only: no production source files modified
  • Root cause: PR [Windows] Fixed CollectionView with grouping fails to add items when a footer template is present or crashes when removing data. #24867 wrapped ListViewBase.ScrollIntoView inside DispatcherQueue.TryEnqueue() in ItemsViewHandler.Windows.cs, making it async — introducing a race condition where test label resets happen before deferred callbacks fire
  • Fix adds await Task.Delay(300) on Windows in CollectionViewScrollPage.xaml.cs before ResetScrollEventLabels() to let deferred callbacks complete
  • Fix disables animation for ScrollTo on Windows in Issue33614.cs to avoid flaky intermediate scroll events
  • Removes TEST_FAILS_ON_WINDOWS guards from CollectionView_ScrollingFeatureTests.cs and Issue33614.cs tests
  • Gate ❌ FAILED with "NO FIX FILES DETECTED" — expected because this is a test-only PR (no non-test source files changed)
  • Prior Copilot inline review flagged Task.Delay(300) as potentially flaky; author marked as "Addressed" — but delay remains in current code
  • PR has prior s/agent-changes-requested and s/agent-fix-win labels from a previous agent run

Code Review Summary

Verdict: LGTM
Confidence: high
Errors: 0 | Warnings: 1 | Suggestions: 2

Key code review findings:

  • ⚠️ CollectionViewScrollPage.xaml.cs:25Task.Delay(300) could be reduced to Task.Delay(0) or Task.Yield() for dispatcher-flush semantics (functionally correct but slower and marginally more fragile)
  • 💡 Issue33614.cs:5PlatformAffected attribute still only lists iOS | macOS despite now having Windows-specific code
  • 💡 Issue33614.cs:75 — trailing whitespace in comment

Fix Candidates

# Source Approach Test Result Files Changed Notes
PR PR #34907 Test-only: add Task.Delay(300) on Windows before label reset + disable animation on Windows for Issue33614 + remove TEST_FAILS_ON_WINDOWS guards ⏳ PENDING (Gate failed: test-only PR, no fix files) CollectionViewScrollPage.xaml.cs, Issue33614.cs, CollectionView_ScrollingFeatureTests.cs, Issue33614.cs (tests) Original PR

🔬 Code Review — Deep Analysis

Code Review — PR #34907

Independent Assessment

What this changes: Four files, all in the test layer:

  1. A #if WINDOWS Task.Delay(300) in NavigateToOptionsPage_Clicked before ResetScrollEventLabels() in HostApp
  2. A #if WINDOWS switch from animate: trueanimate: false in Issue33614's scroll button handler
  3. Removal of TEST_FAILS_ON_WINDOWS guards from the Issue33614 UI test class
  4. Narrowing #if TEST_FAILS_ON_ANDROID && TEST_FAILS_ON_WINDOWS#if TEST_FAILS_ON_ANDROID on VerifyKeepScrollOffsetWithObservableList
  5. Removal of #if TEST_FAILS_ON_WINDOWS block guarding VerifyScrollToByIndexWithMakeVisiblePositionAndVerticalList_Carrot and following ScrollTo tests

Inferred motivation: Windows CollectionView ScrollTo tests were racing against async scroll triggered by items loading. PR #24867 wrapped ListViewBase.ScrollIntoView in DispatcherQueue.TryEnqueue(), making the initial auto-scroll deferred — labels get reset before the deferred callback fires, then overwritten.


Reconciliation with PR Narrative

Agreement: Root cause analysis precisely matches the code. The Task.Delay(300) lets the dispatcher queue flush before label reset. The animate: false avoids intermediate Scrolled events from animation that would set a non-final FirstVisibleItemIndex when the test reads it. Both are technically sound workarounds.


Findings

⚠️ Warning — Task.Delay(300) may be larger than necessary and risks future flakiness

File: CollectionViewScrollPage.xaml.cs:25

#if WINDOWS
    await Task.Delay(300);
#endif

On WinUI, await checkpoints yield control back to the DispatcherQueue, meaning the enqueued callback will process when the await completes — not after 300ms of wall-clock time. This means await Task.Delay(0) (or await Task.Yield()) would achieve the same flush semantics.

The 300ms:

  1. Adds 300ms to every test that navigates through this page on Windows
  2. Doesn't provide stronger guarantees than Task.Delay(0) for the stated use case
  3. Could theoretically fail on a severely degraded CI machine

Recommendation: await Task.Delay(0) or await Task.Yield() for semantically clearer, faster, equally correct behavior.

💡 Suggestion — [Issue] attribute PlatformAffected doesn't reflect Windows coverage

File: src/Controls/tests/TestCases.HostApp/Issues/Issue33614.cs:5

[Issue(IssueTracker.Github, 33614, "...", PlatformAffected.iOS | PlatformAffected.macOS)]

This HostApp page now includes Windows-specific code. The PlatformAffected annotation should be updated to include Windows.

💡 Suggestion — Trailing space in comment

File: src/Controls/tests/TestCases.HostApp/Issues/Issue33614.cs:75

// Disable animation on Windows to avoid flaky test results 

Minor trailing whitespace.


Blast Radius

Scope: Test files only. No production code path affected. No handler, renderer, or platform layer changed.

Impacted test categories: CollectionView, ScrollView (indirectly)

Failure modes:

  • Task.Delay(300) not long enough → scrolledEventLabel.Text = "Fired" when test expects "Not Fired" → test fails obviously (no silent pass risk)
  • Animation disabled on Windows for Issue33614 → reduces coverage of animated-scroll path on Windows (known accepted trade-off)

Verdict: LGTM

Confidence: high

Summary: Pure test-layer fix. Removes Windows skip guards and adds targeted workarounds for known Windows async dispatch behavior. Task.Delay(300) could be Task.Delay(0) for equivalent correctness and faster tests, and PlatformAffected should include Windows, but neither is a blocking issue. No production code changed.


🔧 Fix — Analysis & Comparison

Fix Candidates

# Source Approach Test Result Files Changed Notes
1 try-fix (claude-opus-4.6) Replace Task.Delay(300) with Task.Yield() for dispatcher-flush semantics ⚠️ BLOCKED CollectionViewScrollPage.xaml.cs, Issue33614.cs, test files Test-only PR, no fix files for baseline script
2 try-fix (claude-sonnet-4.6) DispatcherQueue.TryEnqueue(Low priority) + TaskCompletionSource for deterministic flush ⚠️ BLOCKED CollectionViewScrollPage.xaml.cs, Issue33614.cs Test-only PR, deterministic but cannot be tested
3 try-fix (gpt-5.3-codex) Deterministic label polling in UI test assertions; remove animate:false ⚠️ BLOCKED All 4 test files Test-only PR, Windows UI tests cannot run on Android agent
4 try-fix (gpt-5.4) Production code fix in ItemsViewHandler.Windows.cs — suppress auto-scroll when ListViewBase.IsLoaded is false ⚠️ BLOCKED ItemsViewHandler.Windows.cs Only attempt targeting production code; cannot run Windows UI tests on Android
PR PR #34907 Test-only: Task.Delay(300) on Windows before label reset + animate:false on Windows + remove TEST_FAILS_ON_WINDOWS guards ❌ Gate FAILED (test-only, no fix files detected) 4 test files Original PR

Cross-Pollination

Model Round New Ideas? Details
claude-opus-4.6 2 No All approaches identified correctly. Attempt 4 (production code fix in ItemsViewHandler.Windows.cs) is the right direction but needs Windows agent.

Exhausted: Yes
Selected Fix: PR's fix — No test-executable alternative found (all blocked due to test-only PR + Android-only agent). PR's test-only approach is the pragmatic choice and code review rated LGTM.

Notes

  • All try-fix attempts were BLOCKED because: (1) this is a test-only PR with no non-test source files changed, so EstablishBrokenBaseline.ps1 cannot establish a broken baseline; (2) the target platform is Android but the issue and tests are Windows-specific
  • Attempt 4 proposed a potentially stronger production code fix in ItemsViewHandler.Windows.cs that would eliminate the root cause entirely, but cannot be empirically tested on this agent

📋 Report — Final Recommendation

⚠️ Final Recommendation: REQUEST CHANGES

Phase Status

Phase Status Notes
Pre-Flight ✅ COMPLETE Test-only PR, issue #34772, Windows CollectionView ScrollTo flakiness
Code Review LGTM (high) 0 errors, 1 warning, 2 suggestions
Gate ❌ FAILED Android — "No fix files detected" (expected: test-only PR)
Try-Fix ✅ COMPLETE 4 attempts, 0 passing (all BLOCKED: test-only + Android agent)
Report ✅ COMPLETE

Code Review Impact on Try-Fix

The code review ⚠️ Warning about Task.Delay(300) being replaceable with Task.Yield() or Task.Delay(0) was reflected in Attempts 1 and 2, which explored Task.Yield() and a DispatcherQueue.TryEnqueue(Low) + TaskCompletionSource flush respectively. Attempt 4 (gpt-5.4) went further and proposed a production-code fix in ItemsViewHandler.Windows.cs to eliminate the root cause entirely. The code review finding guided all models toward more deterministic synchronization approaches.

Summary

PR #34907 is a test-only fix for Windows CollectionView ScrollTo flakiness caused by PR #24867's async DispatcherQueue.TryEnqueue wrapper. The fix is pragmatically sound: a Task.Delay(300) to allow deferred callbacks to complete before resetting labels, animate:false on Windows to avoid intermediate scroll events, and removal of TEST_FAILS_ON_WINDOWS guards. Code review rated LGTM with one warning.

Recommendation is REQUEST CHANGES for the following reasons:

  1. Gate failed — tests did not behave as expected (per prompt). While the gate failure is due to a test-only PR detection issue (not actual test failures), the gate outcome is ❌ FAILED.
  2. Stronger alternative identified — Try-Fix Attempt 4 proposed a production-code fix in ItemsViewHandler.Windows.cs that would suppress the auto-scroll on pre-load item population (!ListViewBase.IsLoaded). This would fix the root cause instead of working around it in tests, and would benefit all users — not just test reliability.
  3. Task.Delay(300) is fragile — The 300ms arbitrary delay could be replaced with Task.Delay(0) or a DispatcherQueue.TryEnqueue(Low) flush for equivalent correctness. As noted by Copilot's inline review comment (which the author dismissed), the timing-based approach may still be flaky on heavily loaded CI machines.

Root Cause

PR #24867 changed ScrollIntoView in OnItemsVectorChanged from synchronous to asynchronous via DispatcherQueue.TryEnqueue() on Windows. This introduced a race: when a test navigates to the scroll page, items load → OnItemsVectorChanged fires → ScrollIntoView is queued async → test code resets labels → queued scroll fires → labels overwritten with "Fired" instead of "Not Fired".

Fix Quality

The PR's test-layer fix is reasonable and pragmatic for immediate CI stabilization. However:

  • Task.Delay(300) is an arbitrary timing heuristic — it works in practice but could silently become flaky if CI machines are slower, or waste 300ms when Task.Delay(0) would be sufficient
  • Disabling animation on Windows for Issue33614 reduces test coverage of the animated scroll path (this concern was raised by Copilot inline review but dismissed by the author)
  • Attempt 4's !ListViewBase.IsLoaded check in ItemsViewHandler.Windows.cs offers a cleaner production-code fix that would make the test-layer workarounds unnecessary

Suggested improvements:

  1. Replace await Task.Delay(300) with await Task.Delay(0) (dispatcher flush) or a deterministic DispatcherQueue-based flush helper
  2. Consider the production code fix: in ItemsViewHandler.Windows.cs OnItemsVectorChanged, capture !ListViewBase.IsLoaded before TryEnqueue and skip ScrollIntoView if true
  3. Update PlatformAffected in Issue33614's [Issue] attribute to include PlatformAffected.Windows

@MauiBot MauiBot added s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates and removed s/agent-fix-win AI found a better alternative fix than the PR labels Apr 26, 2026
PureWeen pushed a commit that referenced this pull request Apr 28, 2026
…#34907)

<!-- 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!
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->
### Root Cause

- PR [24867](#24867) fixed a COM
exception on Windows by wrapping
[ListViewBase.ScrollIntoView](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
inside
[DispatcherQueue.TryEnqueue()](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
in
[ItemsViewHandler.Windows.cs](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
→
[OnItemsVectorChanged](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html).
This changed
[ScrollIntoView](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
from synchronous to asynchronous execution, introducing a race condition
in ScrollTo-related UI tests on Windows.

- Before [24867](#24867)
- Items load →
[OnItemsVectorChanged](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
→
[ScrollIntoView](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
fires (sync) → Scrolled event updates label → Test resets label → Label
= "Not Fired"

- After [24867](#24867) (async via
TryEnqueue):
- Items load →
[OnItemsVectorChanged](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
→
[ScrollIntoView](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
is queued (async) → Test resets label to "Not Fired" → Queued
[ScrollIntoView](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
fires → Scrolled event overwrites label = "Fired"

- The deferred
[ScrollIntoView](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
callback executes after the test has already reset the scroll event
labels, causing stale scroll events to overwrite the expected state.
Similarly, for [ScrollTo(animate:
true)](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
tests, the animated scroll produces intermediate
[Scrolled](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
events that haven't settled to the final index when the test reads the
label value.

### Description of Change

<!-- Enter description of the fix in this section -->
**Test reliability improvements:**

* Added a delay in `CollectionViewScrollPage.xaml.cs` before resetting
scroll event labels to ensure deferred callbacks complete, preventing
test flakiness on Windows.
* Disabled animation for `ScrollTo` actions on Windows in
`Issue33614.cs` to avoid flaky test results.

**Test coverage and platform-specific adjustments:**

* Removed Windows-specific test skip conditions in `Issue33614.cs` and
`CollectionView_ScrollingFeatureTests.cs`, re-enabling these tests on
Windows as the related issues have been resolved.
[[1]](diffhunk://#diff-d98964fb2b3496a40f82c4700a38b02be920ba2dc4c500cd6f020d1f74b847d1L1)
[[2]](diffhunk://#diff-d98964fb2b3496a40f82c4700a38b02be920ba2dc4c500cd6f020d1f74b847d1L24)
[[3]](diffhunk://#diff-d0158d1415828d2b2a784462d5b03cadbc262b1cd822351d96b35b146976da66L1580)
[[4]](diffhunk://#diff-d0158d1415828d2b2a784462d5b03cadbc262b1cd822351d96b35b146976da66L1793)
* Updated conditional compilation for a grouped list test to only skip
on Android, as the Windows issue has been addressed.

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

Fixes #34772

| Before | After |
|----------|----------|
| <img
src="https://github.com/user-attachments/assets/7db67c75-c970-43b0-bcb8-3232af341fa4">
| <img
src="https://github.com/user-attachments/assets/998d74ee-5d4b-48b2-8632-47dc89d2e3e7">
|


<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
PureWeen pushed a commit that referenced this pull request Apr 29, 2026
…#34907)

<!-- 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!
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->
### Root Cause

- PR [24867](#24867) fixed a COM
exception on Windows by wrapping
[ListViewBase.ScrollIntoView](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
inside
[DispatcherQueue.TryEnqueue()](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
in
[ItemsViewHandler.Windows.cs](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
→
[OnItemsVectorChanged](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html).
This changed
[ScrollIntoView](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
from synchronous to asynchronous execution, introducing a race condition
in ScrollTo-related UI tests on Windows.

- Before [24867](#24867)
- Items load →
[OnItemsVectorChanged](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
→
[ScrollIntoView](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
fires (sync) → Scrolled event updates label → Test resets label → Label
= "Not Fired"

- After [24867](#24867) (async via
TryEnqueue):
- Items load →
[OnItemsVectorChanged](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
→
[ScrollIntoView](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
is queued (async) → Test resets label to "Not Fired" → Queued
[ScrollIntoView](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
fires → Scrolled event overwrites label = "Fired"

- The deferred
[ScrollIntoView](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
callback executes after the test has already reset the scroll event
labels, causing stale scroll events to overwrite the expected state.
Similarly, for [ScrollTo(animate:
true)](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
tests, the animated scroll produces intermediate
[Scrolled](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
events that haven't settled to the final index when the test reads the
label value.

### Description of Change

<!-- Enter description of the fix in this section -->
**Test reliability improvements:**

* Added a delay in `CollectionViewScrollPage.xaml.cs` before resetting
scroll event labels to ensure deferred callbacks complete, preventing
test flakiness on Windows.
* Disabled animation for `ScrollTo` actions on Windows in
`Issue33614.cs` to avoid flaky test results.

**Test coverage and platform-specific adjustments:**

* Removed Windows-specific test skip conditions in `Issue33614.cs` and
`CollectionView_ScrollingFeatureTests.cs`, re-enabling these tests on
Windows as the related issues have been resolved.
[[1]](diffhunk://#diff-d98964fb2b3496a40f82c4700a38b02be920ba2dc4c500cd6f020d1f74b847d1L1)
[[2]](diffhunk://#diff-d98964fb2b3496a40f82c4700a38b02be920ba2dc4c500cd6f020d1f74b847d1L24)
[[3]](diffhunk://#diff-d0158d1415828d2b2a784462d5b03cadbc262b1cd822351d96b35b146976da66L1580)
[[4]](diffhunk://#diff-d0158d1415828d2b2a784462d5b03cadbc262b1cd822351d96b35b146976da66L1793)
* Updated conditional compilation for a grouped list test to only skip
on Android, as the Windows issue has been addressed.

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

Fixes #34772

| Before | After |
|----------|----------|
| <img
src="https://github.com/user-attachments/assets/7db67c75-c970-43b0-bcb8-3232af341fa4">
| <img
src="https://github.com/user-attachments/assets/998d74ee-5d4b-48b2-8632-47dc89d2e3e7">
|


<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
PureWeen pushed a commit that referenced this pull request Apr 30, 2026
…ability (#35133)

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

> **Depends on #35136** (pipeline category detection — should merge
first)

## What this does

Two things:

### 1. UI test category detection in PR review

During the PR review workflow, Step 0.5 detects which UI test categories
the PR impacts and writes the result to the AI summary comment. This
gives reviewers visibility into which UI tests are relevant.

**Detection** reuses the 3-tier script from #35136 (test attributes →
source paths → AI reasoning).

**AI summary** shows a new 🧪 UI Tests section with detected categories
before the gate section.

### 2. Gate reliability fixes

Multiple fixes to make the gate (`verify-tests-fail.ps1`) more
deterministic:

| Fix | Problem it solves |
|-----|-------------------|
| **Absolute path resolution** | Gate scripts not found on Linux CI
agents (`Resolve-Path`, `GetFullPath`) |
| **File existence check** | Instant cryptic failure when verify script
is missing — now logs clear error |
| **3x retry on ENV ERROR** | Emulator timeouts, ADB failures, app
crashes — transient issues that pass on retry |
| **Strip bad report blocks** | Old verify script produces `Passed:
False` with empty counts — stripped instead of shown |
| **Gate log in fallback** | When report is missing, shows last 20 lines
of gate output instead of just `❌ FAILED / Platform: IOS` |

## Files

| File | Changes |
|------|---------|
| `.github/scripts/Review-PR.ps1` | Step 0.5 category detection + all 5
gate fixes |
| `.github/scripts/post-ai-summary-comment.ps1` | Add `uitests` phase to
render detected categories |
| `.github/pr-review/pr-preflight.md` | Step 7: AI identifies impacted
UI test categories |

## Validation — PR reviewer builds (Apr 26)

10 builds against real PRs — all succeeded ✅. Category detection shown
in AI summary comment.

| PR | Categories Detected | Build | AI Summary |
|----|-------------------|-------|------------|
| #35037 (WebView theme) | `ViewBaseTests,WebView` |
[13940071](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940071)
|
[comment](#35037 (comment))
|
| #35031 (Shell memory leak) | `Shell` |
[13940072](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940072)
|
[comment](#35031 (comment))
|
| #35020 (XAML Hot Reload) | _(none — XAML only)_ |
[13940073](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940073)
| ✅ Shows "No UI test categories" |
| #35008 (Shell SearchHandler) | `Shell` |
[13940074](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940074)
| ✅ |
| #34997 (RadioButton gradient) | `RadioButton,ViewBaseTests` |
[13940075](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940075)
| ✅ |
| #34980 (DatePicker rotation) | `ViewBaseTests` |
[13940076](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940076)
| ✅ |
| #34974 (Picker CharacterSpacing) | `ViewBaseTests` |
[13940077](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940077)
| ✅ |
| #34923 (SwipeView threshold) | `SwipeView,ViewBaseTests` |
[13940078](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940078)
| ✅ |
| #34907 (CollectionView ScrollTo) | `CollectionView` |
[13940079](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940079)
| ✅ |
| #34845 (RefreshView binding) | `RefreshView,ViewBaseTests` |
[13940080](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940080)
| ✅ |

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
github-actions Bot pushed a commit that referenced this pull request May 6, 2026
…#34907)

<!-- 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!
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->
### Root Cause

- PR [24867](#24867) fixed a COM
exception on Windows by wrapping
[ListViewBase.ScrollIntoView](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
inside
[DispatcherQueue.TryEnqueue()](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
in
[ItemsViewHandler.Windows.cs](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
→
[OnItemsVectorChanged](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html).
This changed
[ScrollIntoView](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
from synchronous to asynchronous execution, introducing a race condition
in ScrollTo-related UI tests on Windows.

- Before [24867](#24867)
- Items load →
[OnItemsVectorChanged](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
→
[ScrollIntoView](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
fires (sync) → Scrolled event updates label → Test resets label → Label
= "Not Fired"

- After [24867](#24867) (async via
TryEnqueue):
- Items load →
[OnItemsVectorChanged](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
→
[ScrollIntoView](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
is queued (async) → Test resets label to "Not Fired" → Queued
[ScrollIntoView](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
fires → Scrolled event overwrites label = "Fired"

- The deferred
[ScrollIntoView](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
callback executes after the test has already reset the scroll event
labels, causing stale scroll events to overwrite the expected state.
Similarly, for [ScrollTo(animate:
true)](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
tests, the animated scroll produces intermediate
[Scrolled](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
events that haven't settled to the final index when the test reads the
label value.

### Description of Change

<!-- Enter description of the fix in this section -->
**Test reliability improvements:**

* Added a delay in `CollectionViewScrollPage.xaml.cs` before resetting
scroll event labels to ensure deferred callbacks complete, preventing
test flakiness on Windows.
* Disabled animation for `ScrollTo` actions on Windows in
`Issue33614.cs` to avoid flaky test results.

**Test coverage and platform-specific adjustments:**

* Removed Windows-specific test skip conditions in `Issue33614.cs` and
`CollectionView_ScrollingFeatureTests.cs`, re-enabling these tests on
Windows as the related issues have been resolved.
[[1]](diffhunk://#diff-d98964fb2b3496a40f82c4700a38b02be920ba2dc4c500cd6f020d1f74b847d1L1)
[[2]](diffhunk://#diff-d98964fb2b3496a40f82c4700a38b02be920ba2dc4c500cd6f020d1f74b847d1L24)
[[3]](diffhunk://#diff-d0158d1415828d2b2a784462d5b03cadbc262b1cd822351d96b35b146976da66L1580)
[[4]](diffhunk://#diff-d0158d1415828d2b2a784462d5b03cadbc262b1cd822351d96b35b146976da66L1793)
* Updated conditional compilation for a grouped list test to only skip
on Android, as the Windows issue has been addressed.

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

Fixes #34772

| Before | After |
|----------|----------|
| <img
src="https://github.com/user-attachments/assets/7db67c75-c970-43b0-bcb8-3232af341fa4">
| <img
src="https://github.com/user-attachments/assets/998d74ee-5d4b-48b2-8632-47dc89d2e3e7">
|


<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-testing Unit tests, device tests community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration s/agent-changes-requested AI agent recommends changes - found a better alternative or issues 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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Testing][Windows]CollectionView ScrollTo related test cases failed in CI

5 participants