Skip to content

test(textbox): De-flake iOS single-tap caret assert - #23963

Merged
Xiaoy312 merged 1 commit into
masterfrom
dev/xygu/20260804/deflake-ios-caret-blink-assert
Aug 5, 2026
Merged

Xiaoy312 merged 1 commit into
masterfrom
dev/xygu/20260804/deflake-ios-caret-blink-assert

Conversation

@Xiaoy312

@Xiaoy312 Xiaoy312 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

GitHub Issue: #9080 (tracking epic — intentionally not auto-closed by this PR)

PR Type:

🏗️ Build or CI related changes

What changed? 🚀

Given_TextBox.When_Touch_SingleTap_Places_Caret_iOS failed the Tests - iOS Skia Runtime Tests 3 shard:

Assert.AreEqual failed. Expected:<ThumblessCaretShowing>. Actual:<ThumblessCaretHidden>.
'expected' expression: 'expectedCaret', 'actual' expression: 'SUT.CaretMode'.
  at Given_TextBox.AssertTouchSingleTapPlacesCaret(TouchTextSelectionConvention, CaretDisplayMode)

ThumblessCaretShowing / ThumblessCaretHidden are the two halves of the caret blink cycle, not two
different outcomes. A 500 ms DispatcherTimer flips between them (TextBox.skia.cs:79, TimerOnTick at
:1504-1517), and Select() restarts that timer on every caret move (:548-555). The test tapped, awaited a
bare WaitForIdle(), then sampled CaretMode exactly once — so any tap→assert gap longer than one blink
period legitimately observes the hidden half and fails. It is the only runtime test that asserted a blinking
mode without a wait.

That gap only opens on the iOS simulator, where focus drives a full native keyboard/IME handshake that
WaitForIdle has to drain (StartImeSession(); the device log shows a keyboard dismiss + show cycle per focus,
UIKeyboardAnimationDuration = 0.25 plus a 0.4 s BSAnimationSettings). Desktop and Android Skia have no
per-focus keyboard cost, which is why the test is green there. On the failing run the shard's agent was
unusually slow — 1 h 4 m vs 29–52 m for the other three iOS shards — and all three in-process retries failed,
so it was reproducible on that agent rather than a one-off.

This waits for the expected mode instead of sampling it:

 			Assert.AreEqual("", SUT.SelectedText);
-			Assert.AreEqual(expectedCaret, SUT.CaretMode);
+			await WindowHelper.WaitFor(
+				() => SUT.CaretMode == expectedCaret,
+				timeoutMS: 3000,
+				message: $"tap should settle the caret in {expectedCaret}");

Notes on the choices:

  • The explicit timeoutMS: 3000 matters — WindowHelper.WaitFor defaults to 1000 ms
    (TestServices.WindowHelper.cs:314), only two blink periods on the one platform that stalls. Line 5072 of
    the same file already passes 3000.
  • Both conventions stay correct: the Android expectation is a thumbed mode, for which the setter stops the
    timer (TextBox.skia.cs:113-117), so it still matches on the first evaluation with no added pumping.
  • Deliberately not relaxed to "either thumbless phase": _caretMode initializes to ThumblessCaretHidden
    (TextBox.skia.cs:55), so that variant would pass vacuously if the tap never registered. Waiting for
    Showing requires focus plus a running timer.
  • Assert.AreEqual("", SUT.SelectedText) is kept ahead of the wait, so a tap ever mis-read as a double-tap
    still fails there with a clear message instead of timing out.
  • No [PlatformCondition] added. Gating this off Skia-UIKit would drop coverage on the very platform whose
    convention the test emulates — worse than the flake it would hide. A genuine focus loss also still fails
    after the timeout with the same symptom (TimerOnTick no-ops when unfocused), so this does not mask a
    regression.

The same wait is applied to AssertTouchGestureOnEmptyBoxOpensFlyout, the one remaining single-shot assert on
a blinking mode. It samples CaretMode after a Task.Delay(1200) and a flyout-open wait — well past one blink
period — and is green today only because its callers are gated to SkiaDesktop | SkiaAndroid, not because the
assert is safe. (The third ThumblessCaret site, AssertTouchTapOnEmptyBoxPlacesCaret, already used
WaitFor.)

Test-only change — no product code touched. The caret is supposed to blink; the test had to tolerate it.

Validation: compile — Uno.UI.RuntimeTests.Skia net10.0, 0 errors / 0 warnings. Runtime — not run locally;
a Skia Desktop run cannot reproduce an iOS-simulator timing flake, so the iOS shards on this PR are the real
gate. Per the investigation this should not be called proven until those shards come back green.

PR Checklist ✅

  • 🧪 Added Runtime tests, UI tests, or a manual test sample (for bug fixes / features, if applicable) — N/A, this hardens two existing runtime-test assertions
  • 📚 Docs have been added/updated following the documentation template (for bug fixes / features) — N/A, no user-facing change
  • 🖼️ Validated PR Screenshots Compare Test Run results. — N/A, no rendering change
  • ❗ Contains NO breaking changes
  • 👀 Reviewed 2 other open pull requests (optional but appreciated!)

🤖 Generated with Claude Code

When_Touch_SingleTap_Places_Caret_iOS asserted CaretMode exactly once
after a bare WaitForIdle, but ThumblessCaretShowing/Hidden are the two
halves of the caret blink cycle, flipped every 500ms by a DispatcherTimer
that Select() restarts on each caret move. Any tap-to-assert gap longer
than one blink period legitimately leaves the caret hidden, which is what
failed the iOS Skia shard on an unusually slow simulator agent (all three
in-process retries failed there).

Wait for the expected mode instead, with an explicit 3000ms timeout since
WaitFor defaults to 1000ms. The Android expectation is a thumbed mode
that stops the timer, so it still matches on the first evaluation, and a
genuine focus loss still fails after the timeout with the same symptom.

Applies the same wait to AssertTouchGestureOnEmptyBoxOpensFlyout, the one
remaining single-shot assert on a blinking mode; it is green today only
because its callers are gated off Skia-UIKit.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI lite review requested due to automatic review settings August 4, 2026 18:33
@github-actions github-actions Bot added the area/skia ✏️ Categorizes an issue or PR as relevant to Skia label Aug 4, 2026

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

🟢 Ready to approve

The change is confined to runtime tests, uses an existing WindowHelper.WaitFor API correctly (including timeoutMS), and I did not find any correctness or maintainability issues in the updated assertions.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

This PR hardens TextBox touch runtime tests on Skia to avoid flakiness caused by the iOS thumbless caret blinking (500ms cycle), by waiting for the expected CaretMode instead of sampling it once.

Changes:

  • Replaces a single-shot Assert.AreEqual(expectedCaret, SUT.CaretMode) with WindowHelper.WaitFor(() => SUT.CaretMode == expectedCaret, timeoutMS: 3000, ...) for the single-tap caret assertion.
  • Applies the same “wait for expected caret mode” approach to the empty-box gesture → flyout scenario to avoid mid-blink sampling failures.
File summaries
File Description
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs Updates two caret-mode assertions to wait (with a 3000ms timeout) for the expected CaretMode, avoiding iOS blink-cycle timing flakiness.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 225780 found UI Test snapshots differences: skia-linux-screenshots: 57, skia-windows-screenshots: 2348, wasm: 11

Details
  • skia-linux-screenshots: 57 changed over 2348

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • Buttons.png-dark
    • Buttons.png
    • Examples.png-dark
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • ClipboardTests.png-dark
    • ContextRequested.png-dark
    • ContextRequested.png
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Focus_FocusVisual_Properties.png-dark
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
  • skia-windows-screenshots: 2348 changed over 2394

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AppBar_KeyBoard.png
    • ApplicationViewSizing.png
    • AppWindowPresenters.png
    • Attributed_text_Simple.png
    • AutoBorderStretchwithtopmargin.png
    • AutoSuggestBox_Description.png
    • BadgeNotificationTests.png-dark
    • Basics.png-dark
    • BezierSegment.png-dark
    • BezierSegment.png
    • BorderBottomwithmargins.png-dark
    • BorderBottomwithmargins.png
    • BorderRightwithmargins.png
    • BorderTopwithmargins.png-dark
    • Border_CornerRadius_Binding.png
    • Border_CornerRadius_BorderThickness.png-dark
    • Border_Simple_No_Background.png
    • Border_Simple_No_Background_With_Content_Border_With_Background.png-dark
    • Brushes_ImplicitConvert.png-dark
    • Brushes_ImplicitConvert.png
  • wasm: 11 changed over 1076

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected
    • UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests.WinUIExpanderPage
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Minimal
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Ogg_Extension
    • UITests.Uno_Web.Http.CookieManagerTests
    • UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigationProperties
    • UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
    • SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_EnableDevTools
    • Uno.UI.Samples.Content.UITests.WebView.WebView_AnchorNavigation
    • UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Theming

@Xiaoy312
Xiaoy312 merged commit f22dc5d into master Aug 5, 2026
53 checks passed
@Xiaoy312
Xiaoy312 deleted the dev/xygu/20260804/deflake-ios-caret-blink-assert branch August 5, 2026 18:27
@Xiaoy312

Xiaoy312 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio backport release/stable/6.7

@mergify

mergify Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

backport release/stable/6.7

✅ Backports have been created

Details

agneszitte added a commit that referenced this pull request Nov 3, 2026
…6.7/pr-23963

test(textbox): De-flake iOS single-tap caret assert (backport #23963)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/skia ✏️ Categorizes an issue or PR as relevant to Skia

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants