Skip to content

fix(textbox): Keep backward selection on Android IME echoes; unblock Android CI - #26011

Merged
MartinZikmund merged 5 commits into
masterfrom
dev/mazi/ci-deflake-nov
Nov 5, 2026
Merged

MartinZikmund merged 5 commits into
masterfrom
dev/mazi/ci-deflake-nov

Conversation

@MartinZikmund

@MartinZikmund MartinZikmund commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

GitHub Issue: closes #26010

PR Type:

🐞 Bugfix

What changed? 🚀

Two Given_TextBox failures turn every Skia Android lane red, on master and on almost every PR. Neither is a flake: both fail deterministically on every build and survive all 3 retries.

1. Backward selection flipped by IME echoes (product fix)

The Android TextInputConnection reports every selection back to the TextBox as a normalized range (EndBatchEdit → UpdateTextFromNative). TextBoxCore re-applied it with Select, which always makes the selection forward. After Shift+Home, the next echo moved the caret to the far end and the TextBox scrolled there (HorizontalOffset 251 instead of 0 in When_Keyboard_Selection_Backwards_ScrollViewer_Offset). Users hit this too, not just the test.

UpdateTextFromNative and SelectFromNative now ignore an echo of the current range, which is what RichEditBox.SelectFromNative already does. Because that early return skips ProcessTextInput, it also clears the platform-applied flag that ProcessTextInput would have cleared, so a composing-region-only update followed by an echo can't leave the app's next Text assignment treated as platform-applied. The text comparison doesn't allocate a normalized copy per echo. The new When_IME_Echoes_Backward_Selection_Then_Direction_Kept drives IImeSessionHost directly, so it runs on desktop as well, and checks with one more Shift+Right that the caret really stayed at the start. When_IME_Echo_After_Platform_Applied_Update_Then_External_Text_Cancels_Composition covers the flag.

Side effect: an echo no longer resets the "currently typing" state, so Android undo grouping now follows the other platforms.

2. Touch-lock tests waiting for a keyboard that never shows (test fix)

WaitForAndroidInputPanePositioning calls InputPane.TryShow(), which returns true, then asserted that the pane becomes visible. On the CI emulator it never does, so When_Touch_Tap_/When_Touch_Selection_Flick_Does_Not_Lock_ScrollViewer_Android timed out. The helper now waits up to 5 s. If the pane still isn't visible, it logs that and cancels the request through the platform input-pane extension (InputPane.TryHide() no-ops while the pane isn't visible), so the pane can't open (and bring the caret back into view) in the middle of the pan.

This is a workaround to unblock CI, not a fix. The failures started on master with build 242458 (#25823), and it isn't a shard reshuffle: shard 0 ran the same tests before and after. #25823 also turns memory-aware template and array pooling back on (FrameworkTemplatePool.CanUsePool, DefaultArrayPoolPlatformProvider). In the failing shards, the device log shows Gboard restarting after a Play Services update, and every showSoftInput after that is refused as "not served". How that connects to #25823 is still unknown.

Not in this PR:

Validation

  • Runtime (Skia Desktop, Windows): the new test fails without the fix (UpdateTextFromNative row) and passes with it. The full Given_TextBox class passes with the fix: 351 passed, 0 failed, 24 skipped.
  • Runtime (Skia Desktop, Windows), review follow-up: When_IME_Echo_After_Platform_Applied_Update_Then_External_Text_Cancels_Composition fails without the flag fix and passes with it. All 23 Given_TextBox.When_IME_* tests pass.
  • Android: not run locally (no emulator here). CI on this PR is the Android validation.

PR Checklist ✅

🤖 Generated with Claude Code

https://claude.ai/code/session_01TXMNtzkhrDvnAe4LN8q2X7

Copilot AI balanced review requested due to automatic review settings November 4, 2026 01:11
@github-actions github-actions Bot added the area/skia ✏️ Categorizes an issue or PR as relevant to Skia label Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 19s —— View job


Review summary

Verdict: looks good, with one minor nit.

  • Blocking: 0
  • Minor: 1 (inline, allocation in UpdateTextFromNative)

What I checked (code review only; I did not build or run anything):

  • The root cause is addressed at the mutation point. Select always clears selectionEndsAtTheStart (TextBoxCore.Input.cs:767), and the echo guard now skips it when the incoming range equals the current one. This is a root-cause fix, not just a guard.
  • The new test When_IME_Echoes_Backward_Selection_Then_Direction_Kept covers both entry points (UpdateTextFromNative and SelectFromNative). It drives IImeSessionHost directly, so it runs on desktop, and the PR reports it fails before the fix and passes after.
  • The WaitForAndroidInputPanePositioning change is a test-helper fix. It only weakens the wait and then cancels the request with TryHide(). That is reasonable, but it has no Android validation until CI runs.

Cross-cutting notes:

  • The PR notes that an echo no longer resets the "currently typing" state. That changes Android undo grouping, which is intended, but it is the one behavioral side effect to watch in Android runtime tests.
  • Android validation relies entirely on this PR's CI. Please confirm the two touch-lock tests and When_Keyboard_Selection_Backwards_ScrollViewer_Offset go green there.
  • The Android NativeAOT touch-lock failure is explicitly left out of scope. It needs a follow-up issue so it isn't lost.

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.

🟡 Changes recommended

Active issues can leave Android text composition incorrectly active after an external text replacement and allow a pending keyboard show request to bring the caret into view during panning.

2 open issues
What changed in this PR

Addresses #26010 by preserving backward TextBox selections when Android echoes the current selection and adjusting touch-scroll tests for emulators that never display the keyboard.

Changes:

  • Ignore unchanged native selection echoes to preserve caret direction.
  • Add a regression test covering selection-only and text-plus-selection echoes.
  • Bound the Android keyboard wait to five seconds and attempt to hide the pane after timeout.
File Description
src/​Uno.UI/​UI/​Xaml/​Controls/​TextBoxCore/​TextBoxCore.IME.cs Detects native echoes and avoids reapplying unchanged selections.
src/​Uno.UI.RuntimeTests/​Microsoft/​UI/​Xaml/​Controls/​Given_TextBox.skia.cs Adds backward-selection coverage and adjusts Android keyboard setup waits.

Review effort: Balanced

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 243482 found UI Test snapshots differences: skia-linux-screenshots: 2458, skia-windows-screenshots: 2458

Details
  • skia-linux-screenshots: 2458 changed over 2492

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AndroidWindowInsets.png-dark
    • AppBarButtonWithIconTest.png-dark
    • AppBarButtonWithIconTest.png
    • ApplicationViewMode.png
    • AppBar_KeyBoard.png
    • AppWindowPositionAndSize.png-dark
    • Application_DispatcherShutdownMode.png
    • ArcSegment.png-dark
    • AppXamlDefinedResources.png-dark
    • Attributed_text_Simple.png-dark
    • Arrange_Performance01.png
    • AutoBorderStretchwithrightmargin.png-dark
    • Attributed_text_Simple.png
    • AutomationProperties_Landmark.png-dark
    • AuthenticationBroker_Cancel.png
    • AutoSizedPathCentered.png
    • AutoBorderStretchwithtopmargin.png-dark
    • AutoSizedTopLeft.png-dark
    • AutoBorderStretchwithtopmargin.png
  • skia-windows-screenshots: 2458 changed over 2492

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedIconPage.png-dark
    • AnimatedVisualsTestbedPage.png-dark
    • AppBarToggleButtonTest.png-dark
    • ApplicationViewSpanningRectsPage.png-dark
    • AppWindowClosing.png-dark
    • AppWindowPositionAndSize.png
    • AppXamlDefinedResources.png
    • Arrange_Performance01.png
    • Attributed_text_Simple.png
    • Attributed_text_Supserscript.png-dark
    • AutoBorderStretchwithleftmargin.png-dark
    • AutoBorderStretchwithleftmargin.png
    • AutomationProperties_Name.png
    • AutomationProperties_Relations.png-dark
    • AutoSuggestBox_Description.png-dark
    • AutoSuggestBox_Description.png
    • BackGesture.png-dark
    • BackGesture.png
    • Basics Pivot Test.png-dark
    • Basics Pivot Test.png

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

Approving: the echo guard fixes the backward-selection flip at its source. All five Android Skia shards are green on build 243482, with When_Keyboard_Selection_Backwards_ScrollViewer_Offset, the touch-lock tests and the new test passing.

One note on the description, which says the touch-lock trigger is most likely a CI shard reshuffle. Comparing master builds 242457 (last pass) and 242458 (first fail, #25823): shard 0, where both tests fail, ran the same 2022 tests on Skia and WebGPU, and the same 1665 on NativeAOT. #25823's two new Given_MemoryManager tests landed in shard 4. So it isn't a reshuffle.

#25823 also changes more than probes at runtime: it turns memory-aware template and array pooling back on (FrameworkTemplatePool.CanUsePool, DefaultArrayPoolPlatformProvider). How that breaks the keyboard is still unknown. In the failing shards, the device log shows Gboard restarting after a Play Services update, and every showSoftInput after that is refused as "not served".

The helper change here works around that rather than fixing it. That's fine for unblocking CI, but worth saying in the description.

Copilot AI balanced review requested due to automatic review settings November 4, 2026 10:33
@MartinZikmund

Copy link
Copy Markdown
Member Author

@Xiaoy312 thanks for digging into the shard data. I corrected the description: it is not a shard reshuffle, and the helper change is called out as a workaround to unblock CI rather than a fix, with the pooling + Gboard "not served" findings recorded there. The root cause behind #25823 is still open.

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.

🟡 Changes recommended

Both new tests leave a focused TextBox attached when the fake IME is restored, risking input-session state leaking into later tests unless scoped content cleanup runs first, including on assertion failures.

1 open issue
2 resolved since last review

Review effort: Balanced

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 20s —— View job


Review summary

Verdict: looks good. Nothing blocking, no new inline findings.

  • Blocking: 0
  • Minor: 0 new

I read the current branch head (f9af6d22) and did not build or run anything. The earlier review threads are addressed in the code:

  • Allocation on echo: IsNativeEchoOfCurrentText compares in place with no Replace copy.
  • Stale _platformTextApplyInProgress: the echo path clears the flag when _isInputModifyingText is false, so the skipped finally no longer leaves it set.
  • TryHide no-op while invisible: the helper now calls IInputPaneExtension.TryHide() directly, so the hide request reaches the platform.
  • Fallback logging: it writes a Console.WriteLine line when the pane never opens.
  • Issue link: the new test has [GitHubWorkItem(.../issues/26010)].

Remaining notes

  • Android validation comes only from CI. Xiaoy312 reports all five Android Skia shards green on build 243482.
  • Xiaoy312 found that the shard-reshuffle explanation in the description is wrong. The ApiInformation change in fix: Re-enable memory-aware pooling #25823 also re-enabled template and array pooling, and the failing shards show Gboard restarting after a Play Services update. The helper change works around that and doesn't fix it. I'd update the description to say so, and file a follow-up for the Gboard cause and for the NativeAOT touch-lock failure, so neither is lost.
  • The screenshot-compare report on build 243482 shows about 2,458 of 2,492 images changed on both Skia Linux and Windows. This PR only touches TextBox IME code and runtime tests. That pattern looks like a baseline or infrastructure problem rather than something this PR caused. Please confirm it before merging.

@MartinZikmund

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Copilot AI balanced review requested due to automatic review settings November 4, 2026 14:18
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@github-actions github-actions Bot added the area/automation Categorizes an issue or PR as relevant to project automation label Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 25s —— View job


Review summary

Verdict: looks good, with a few small follow-ups.

  • Blocking: 0
  • Minor: 1 new inline (the undisclosed SamplesApp.csproj change)

I reviewed the branch head by reading the code. I did not build or run anything.

Cross-cutting notes

  • The earlier threads (allocation on echo, stale _platformTextApplyInProgress, TryHide no-op, logging, issue link, extra Shift+Right check) are addressed in the code.
  • Copilot's latest thread asks for scoped cleanup of the focused TextBoxes in the two new IME tests, before the fake IME is restored (.claude/rules/runtime-tests.md). I agree that is worth doing. I haven't checked how the other When_IME_* tests handle it.
  • The screenshot-compare report (about 2,458 of 2,492 images changed) is not plausibly caused by TextBox IME code. Please confirm it is a baseline or infrastructure problem before merging.
  • Follow-up issues are still needed for the Gboard "not served" cause after fix: Re-enable memory-aware pooling #25823 and for the Android NativeAOT touch-lock failure. Neither is tracked yet.

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.

🔵 Needs a closer look

The tests need failure-safe content cleanup before restoring the real IME extension to prevent focused TextBoxes and active-session state from leaking into subsequent headless tests.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Register content cleanup before restoring the real IME extension

src/​Uno.UI.RuntimeTests/​Microsoft/​UI/​Xaml/​Controls/​Given_TextBox.skia.cs:11237

This test leaves its focused TextBox mounted when imeDisposable restores the real IME extension, which does not clear the coordinator's active host. Headless runs do not automatically unload the content, so shared focus/session state can carry into subsequent tests. Register content cleanup after imeDisposable so it runs first, including on assertion failures, as required by .claude/rules/runtime-tests.md:15.

1 resolved since last review

Review effort: Balanced

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 243580 found UI Test snapshots differences: skia-linux-screenshots: 2458, skia-windows-screenshots: 2458

Details
  • skia-linux-screenshots: 2458 changed over 2492

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedBackVisualSourceSamplePage.png
    • AppBarButtonWithIconTest.png
    • ApplicationViewMode.png
    • AppWindowClosing.png
    • AppWindowTitleBar Properties.png
    • Attributed_text_Simple.png-dark
    • AuthenticationBroker_Demo.png-dark
    • AutomationProperties_Name.png-dark
    • AutoSizedPathCentered.png-dark
    • AutoSizedPathCentered.png
    • AutoSuggestBox_Reason.png-dark
    • AutoSuggestBox_Reason.png
    • BasicAutoSuggestBox.png-dark
    • BasicAutoSuggestBox.png
    • Battery.png-dark
    • Battery.png
    • BenchmarkDotNet.png-dark
    • BenchmarkDotNet.png
    • BitmapImage_vs_SvgImageSource.png-dark
    • BitmapImage_vs_SvgImageSource.png
  • skia-windows-screenshots: 2458 changed over 2492

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Accessibility_ScreenReader.png-dark
    • AppBarToggleButtonTest.png
    • Application_DispatcherShutdownMode.png-dark
    • AppWindowTitleBar Properties.png-dark
    • Arrange_Performance01.png
    • AuthenticationBroker_Cancel.png-dark
    • AutoBorderStretchwithrightmargin.png
    • AutomationProperties_Name.png
    • AutoSuggestBoxChosenSuggestion.png-dark
    • AutoSuggestBoxChosenSuggestion.png
    • AutoSuggestBox_Reason.png-dark
    • AutoSuggestBox_Reason.png
    • BasicAutoSuggestBox.png-dark
    • BasicAutoSuggestBox.png
    • BasicThemeResources.png-dark
    • BasicThemeResources.png
    • BitmapIcon_Foreground.png-dark
    • BitmapIcon_Foreground.png
    • BorderImageBrush.png-dark
    • BorderImageBrush.png

MartinZikmund and others added 4 commits November 5, 2026 09:32
The Android input connection reports every selection back as a
normalized range through EndBatchEdit. Re-applying it flipped a
backward selection forward, moving the caret to the far end and
scrolling the TextBox there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TXMNtzkhrDvnAe4LN8q2X7
The Android touch-lock tests timed out waiting for an input pane the
CI emulator accepted but never displayed. Give it a bounded wait, then
cancel the request so it can't open mid-pan.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TXMNtzkhrDvnAe4LN8q2X7
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/ci-deflake-nov branch from 8d6b950 to 362337f Compare November 5, 2026 08:32
Copilot AI balanced review requested due to automatic review settings November 5, 2026 08:32
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 27s —— View job


Review summary

Verdict: looks good (ship). No blocking findings, no new inline comments.

  • Blocking: 0
  • Minor: 0 new

Code review only: I read git diff origin/master...HEAD and did not build or run anything.

Checked at the current head (362337fc)

Open threads from earlier reviews

  • SamplesApp.csproj: the NuGet audit suppression that an earlier review flagged is no longer in the diff. The PR now touches only the two files in the description, so that concern is resolved.
  • Test cleanup (Copilot): the two new tests leave the focused TextBox mounted when the fake IME is restored. The other 25 SetImeExtensionForTesting call sites in Given_TextBox.skia.cs don't clean up either, so I'm not blocking on it. A try/finally that sets WindowHelper.WindowContent = null would be cheap and matches .claude/rules/runtime-tests.md. It's optional, and ideally done for all the IME tests together.

Cross-cutting notes

  • Android validation comes only from CI. Earlier comments report the five Android Skia shards green on build 243482. Please confirm that again on the latest build.
  • About 2,458 of 2,492 screenshots changed on Skia Linux and Windows in builds 243482 and 243580. TextBox IME code and runtime tests can't plausibly cause that, so it looks like a baseline or infrastructure problem. Please confirm that before merging.
  • Follow-up issues are still worth filing for the Gboard "not served" cause after fix: Re-enable memory-aware pooling #25823 and for the Android NativeAOT touch-lock failure. The TryHide workaround and the timeout are CI-only mitigations.

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.

🔵 Needs a closer look

Android CI results are needed to verify native IME echo handling and delayed keyboard-show cancellation, since the supplied Skia Desktop validation cannot establish Android timing behavior.

No open issues 🎉

Review effort: Balanced

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 243892 found UI Test snapshots differences: skia-linux-screenshots: 2458, skia-windows-screenshots: 2458

Details
  • skia-linux-screenshots: 2458 changed over 2494

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AppBarButtonWithIconTest.png-dark
    • AppBar_KeyBoard.png
    • ApplicationViewSpanningRectsPage.png
    • AppWindowFeatures.png
    • AppXamlDefinedResources.png-dark
    • Attributed_text_FontSize_Changing.png
    • AutoBorderStretchwithbottommargin.png-dark
    • AutomationProperties_Landmark.png-dark
    • AutomationProperties_Landmark.png
    • AutoSuggestBox_Description.png-dark
    • AutoSuggestBox_Description.png
    • BadgeNotificationTests.png-dark
    • BadgeNotificationTests.png
    • Basics_Automated.png-dark
    • Basics_Automated.png
    • BindableDrawerLayout_ChangePane.png-dark
    • BindableDrawerLayout_ChangePane.png
    • BorderBottomwithmargins.png-dark
    • BorderBottomwithmargins.png
  • skia-windows-screenshots: 2458 changed over 2494

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Accessibility_ScreenReader.png
    • AndroidWindowInsets.png
    • AnimatedBackVisualSourceSamplePage.png
    • AnimatedIconPage.png
    • AppBarButtonTest.png
    • AppBarButtonWithIconTest.png
    • AppBar_KeyBoard.png-dark
    • ApplicationViewSizing.png-dark
    • AppWindowClosing.png
    • AppWindowFeatures.png-dark
    • AppXamlDefinedResources.png
    • ArcSegment.png-dark
    • AuthenticationBroker_Demo.png-dark
    • AuthenticationBroker_Demo.png
    • AutomationProperties_AutomationId.png
    • AutomationProperties_Landmark.png-dark
    • AutoSuggestBoxChosenSuggestion.png
    • AutoSuggestBox_BitmapIcon.png-dark
    • BackGesture.png-dark
    • BackGesture.png

@mergify

mergify Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@MartinZikmund
MartinZikmund merged commit ab9aef9 into master Nov 5, 2026
52 checks passed
@MartinZikmund
MartinZikmund deleted the dev/mazi/ci-deflake-nov branch November 5, 2026 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android: TextBox runtime tests fail on every master build (IME echo flips backward selection; touch-lock tests wait for a keyboard that never shows)

5 participants