Skip to content

[Testing] Fix flaky UI tests: retryTimeout and SwipeView button fix#33749

Merged
PureWeen merged 8 commits intomainfrom
fix-flaky-tests-2
Jan 31, 2026
Merged

[Testing] Fix flaky UI tests: retryTimeout and SwipeView button fix#33749
PureWeen merged 8 commits intomainfrom
fix-flaky-tests-2

Conversation

@PureWeen
Copy link
Member

@PureWeen PureWeen commented Jan 28, 2026

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!

Description

This PR improves the reliability of several flaky UI tests by:

  1. Replacing Thread.Sleep with retryTimeout - The retryTimeout parameter keeps retrying screenshot comparisons until they match or timeout, adapting to actual UI timing across different machines/load conditions.

  2. Fixing Issue10563 SwipeView button animations - Added flat Background = SolidColorBrush(Colors.LightGray) to buttons to prevent ripple animation artifacts that caused visual differences on CI.

Changes

Test Issue Fix
Issue10563 Button ripple animation artifacts in SwipeView test Flat button background + updated baselines
Issue18857 Thread.Sleep causes flakiness retryTimeout: TimeSpan.FromSeconds(2)
Issue24856 Thread.Sleep causes flakiness retryTimeout: TimeSpan.FromSeconds(2)
Issue25192 Thread.Sleep causes flakiness retryTimeout: TimeSpan.FromSeconds(2)
Issue27418 Thread.Sleep causes flakiness retryTimeout: TimeSpan.FromSeconds(2)
Issue28657 Thread.Sleep causes flakiness retryTimeout: TimeSpan.FromSeconds(2)
Issue30575 Thread.Sleep causes flakiness retryTimeout: TimeSpan.FromSeconds(3)

Related PRs (not overlapping)

Copilot AI review requested due to automatic review settings January 28, 2026 19:30
Copy link
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

This PR addresses UI test flakiness by replacing fixed Thread.Sleep delays with adaptive retryTimeout parameters in VerifyScreenshot calls, following the pattern established in PR #33705. Additionally, it eliminates network dependencies by replacing internet URLs with local image files for Issue18751 and Issue18896 tests.

Changes:

  • Replaced 8 instances of Thread.Sleep with retryTimeout parameter for adaptive screenshot verification
  • Removed #if WINDOWS conditional compilation in favor of cross-platform retryTimeout
  • Eliminated network dependencies by using local monkey images instead of Wikipedia URLs
  • Increased timeouts and added tolerance for tests with animation timing variance
  • Fixed typo in error message and corrected isInternetRequired flags

Reviewed changes

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

Show a summary per file
File Description
Issue30575.cs Replaced 3s Thread.Sleep with retryTimeout for WebView content loading
Issue28657.cs Replaced 400ms Thread.Sleep with 2s retryTimeout for orientation changes (2 occurrences)
Issue27418.cs Removed Windows-specific #if directive, using retryTimeout for scrollbar timing
Issue25192.cs Replaced 1s Thread.Sleep with 2s retryTimeout for CarouselView item loading
Issue24856.cs Replaced Thread.Sleep + retryDelay with retryTimeout for ImageButton aspect changes
Issue18896.cs Replaced Thread.Sleep + retryDelay with retryTimeout, removed internet connectivity check
Issue18857.cs Replaced Thread.Sleep + retryDelay with retryTimeout for ripple animation
Issue18751.cs Removed Task.Delay, changed to void method, replaced URLs with local images
Issue12134.cs Increased WaitForElement timeout to 30s for WebView cookie loading, fixed typo
Issue10563.cs Increased retryTimeout to 3s, added 1% tolerance for SwipeView animations
Issue18896.xaml.cs Removed isInternetRequired flag since local images are now used
Issue18896.xaml Added HasUnevenRows="True" for better variable height support, formatting cleanup
Issue18751.xaml.cs Removed isInternetRequired flag, replaced 16 Wikipedia URLs with local image filenames
*.jpg (6 files) Added local monkey images: papio, capuchin, golden, saimiri, alouatta, bluemonkey

@PureWeen PureWeen changed the title Fix flaky UI tests: Thread.Sleep to retryTimeout, local images, longer timeouts Fix flaky UI tests: Thread.Sleep to retryTimeout, SwipeView button animations Jan 29, 2026
@PureWeen PureWeen changed the title Fix flaky UI tests: Thread.Sleep to retryTimeout, SwipeView button animations [Testing] Fix flaky UI tests: Thread.Sleep to retryTimeout, SwipeView button animations Jan 29, 2026
@PureWeen PureWeen changed the title [Testing] Fix flaky UI tests: Thread.Sleep to retryTimeout, SwipeView button animations [Testing] Fix flaky UI tests: retryTimeout and SwipeView button fix Jan 29, 2026
@PureWeen PureWeen requested a review from rmarinho January 29, 2026 05:05
@PureWeen
Copy link
Member Author

/rebase

Ahamed-Ali and others added 8 commits January 29, 2026 20:53
- Issue18896: Replace Thread.Sleep with retryTimeout parameter
- Issue18751: Remove isInternetRequired flag (using local images now)
- Issue10563: Increase retryTimeout to 3s and add 1% tolerance for SwipeView animations
WebView loading and cookie evaluation can take time on slow networks.
Increased WaitForElement timeout from default to 30 seconds.
- Issue18857: ImageButton ripple animation
- Issue24856: ImageButton aspect change
- Issue25192: CarouselView items loading
- Issue27418: CarouselView scrollbar disappearing (Windows)
- Issue28657: Orientation change screenshots
- Issue30575: WebView content loading

Using retryTimeout is more reliable than fixed Thread.Sleep delays
as it retries the screenshot comparison until it matches.
Set Background = SolidColorBrush(Colors.LightGray) on all buttons
to prevent ripple animation that causes visual differences on CI.

Note: Baselines will need regeneration on CI with this change.
- Issue18751/18896 local images: covered by #33737
- Issue12134 timeout: covered by #33689 (uses native CookieManager)
@PureWeen
Copy link
Member Author

/azp run maui-pr-uitests, maui-pr-devicetests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@PureWeen
Copy link
Member Author

  • uitests are all green

@PureWeen PureWeen merged commit bf06307 into main Jan 31, 2026
154 of 163 checks passed
@PureWeen PureWeen deleted the fix-flaky-tests-2 branch January 31, 2026 02:08
kubaflo pushed a commit to kubaflo/maui that referenced this pull request Feb 2, 2026
…otnet#33749)

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

This PR improves the reliability of several flaky UI tests by:

1. **Replacing `Thread.Sleep` with `retryTimeout`** - The `retryTimeout`
parameter keeps retrying screenshot comparisons until they match or
timeout, adapting to actual UI timing across different machines/load
conditions.

2. **Fixing Issue10563 SwipeView button animations** - Added flat
`Background = SolidColorBrush(Colors.LightGray)` to buttons to prevent
ripple animation artifacts that caused visual differences on CI.

## Changes

| Test | Issue | Fix |
|------|-------|-----|
| Issue10563 | Button ripple animation artifacts in SwipeView test |
Flat button background + updated baselines |
| Issue18857 | Thread.Sleep causes flakiness | `retryTimeout:
TimeSpan.FromSeconds(2)` |
| Issue24856 | Thread.Sleep causes flakiness | `retryTimeout:
TimeSpan.FromSeconds(2)` |
| Issue25192 | Thread.Sleep causes flakiness | `retryTimeout:
TimeSpan.FromSeconds(2)` |
| Issue27418 | Thread.Sleep causes flakiness | `retryTimeout:
TimeSpan.FromSeconds(2)` |
| Issue28657 | Thread.Sleep causes flakiness | `retryTimeout:
TimeSpan.FromSeconds(2)` |
| Issue30575 | Thread.Sleep causes flakiness | `retryTimeout:
TimeSpan.FromSeconds(3)` |

## Related PRs (not overlapping)

- dotnet#33737 - Fixes Issue18751/18896 (local monkey images)
- dotnet#33689 - Fixes Issue12134 (WebView cookies)

---------

Co-authored-by: Ahamed-Ali <102580874+Ahamed-Ali@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments