You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(textbox): Keep backward selection on Android IME echoes; unblock Android CI - #26011
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.
The Android NativeAOT lane (master-only) also shows a "scrolled back to the TextBox" failure mode of the touch-lock tests after the pane does open. It isn't addressed here.
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.
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.
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.
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.
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.
@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.
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.
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.
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.
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
Register content cleanup before restoring the real IME extension
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.
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)
Root cause: the echo guards in UpdateTextFromNative and SelectFromNative stop Select from clearing the backward direction. This is a root-cause fix, not just a guard.
Allocation on echo:IsNativeEchoOfCurrentText compares in place, so there is no per-echo copy.
Stale _platformTextApplyInProgress: the early return clears the flag under !_isInputModifyingText, mirroring the finally in ProcessTextInput. The new test covers it.
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
area/automationCategorizes an issue or PR as relevant to project automationarea/skia ✏️Categorizes an issue or PR as relevant to Skia
5 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GitHub Issue: closes #26010
PR Type:
🐞 Bugfix
What changed? 🚀
Two
Given_TextBoxfailures 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
TextInputConnectionreports every selection back to the TextBox as a normalized range (EndBatchEdit→UpdateTextFromNative).TextBoxCorere-applied it withSelect, which always makes the selection forward. After Shift+Home, the next echo moved the caret to the far end and the TextBox scrolled there (HorizontalOffset251 instead of 0 inWhen_Keyboard_Selection_Backwards_ScrollViewer_Offset). Users hit this too, not just the test.UpdateTextFromNativeandSelectFromNativenow ignore an echo of the current range, which is whatRichEditBox.SelectFromNativealready does. Because that early return skipsProcessTextInput, it also clears the platform-applied flag thatProcessTextInputwould have cleared, so a composing-region-only update followed by an echo can't leave the app's nextTextassignment treated as platform-applied. The text comparison doesn't allocate a normalized copy per echo. The newWhen_IME_Echoes_Backward_Selection_Then_Direction_KeptdrivesIImeSessionHostdirectly, 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_Compositioncovers 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)
WaitForAndroidInputPanePositioningcallsInputPane.TryShow(), which returns true, then asserted that the pane becomes visible. On the CI emulator it never does, soWhen_Touch_Tap_/When_Touch_Selection_Flick_Does_Not_Lock_ScrollViewer_Androidtimed 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 everyshowSoftInputafter that is refused as "not served". How that connects to #25823 is still unknown.Not in this PR:
ScrollPresenterTests.OffsetsChangeWithCustomDuration(Linux Framebuffer), the third failure on every master build, is already fixed by fix(framebuffer): Pace software rendering when vsync is unavailable #25382. PRs based on a master before that only need a rebase.Given_Image_Release.When_Stream_Load_Superseded_*andGiven_MobileMultiWindowAccessibility.*are covered by test(imaging): Hold the superseded stream's decode in its test #25993 and test(a11y): Stop two Android accessibility tests racing their setup #26000.Validation
UpdateTextFromNativerow) and passes with it. The fullGiven_TextBoxclass passes with the fix: 351 passed, 0 failed, 24 skipped.When_IME_Echo_After_Platform_Applied_Update_Then_External_Text_Cancels_Compositionfails without the flag fix and passes with it. All 23Given_TextBox.When_IME_*tests pass.PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code
https://claude.ai/code/session_01TXMNtzkhrDvnAe4LN8q2X7