android: request a redraw on GameTextInput commits - #4673
Open
mudbungie wants to merge 1 commit into
Open
Conversation
android-activity's game-activity backend delivers InputEvent::TextEvent and InputEvent::TextAction when the IME's InputConnection edits the GameTextInput buffer, and the looper is already woken for them (native_app_glue's onTextInputEvent calls notifyInput). The android event loop dropped both in its catch-all arm without producing a frame, so an application reading AndroidApp::text_input_state() could only notice an IME commit by polling on a timer — poll cadence becomes typing latency. Set the redraw flag for both events. The flag is read later in the same loop iteration, so a commit produces a frame on its own edge. Translating these events into winit Ime events remains open (the Ime vocabulary cannot express deleteSurroundingText); this only stops discarding the wake that already happened.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The problem
With the
game-activitybackend, everything the IME'sInputConnectioncommits lands in the GameTextInput buffer and reaches winit as
InputEvent::TextEvent(and enter-key actions asInputEvent::TextAction). The android event loop currently drops both inits catch-all
_ =>arm — without requesting a redraw — even though thelooper was already woken for them (
native_app_glue'sonTextInputEventcalls
notifyInput).The consequence: an application that reads
AndroidApp::text_input_state()per frame (the only way to consume IMEtext today, since these events are not translated into
Imeevents) canonly notice a commit by polling on a timer, and that poll cadence is felt
directly as typing latency.
The change
Set the redraw flag for both events.
single_iterationreads the flaglater in the same loop iteration, so an IME commit produces a frame on its
own edge and the buffer poll disappears.
Measured on device (current-generation Pixel, SDK 35, Gboard, egui app):
with this arm and a 1 s heartbeat as the only timer, injected-tap to
glyph-adopted is ~72–87 ms — nearly all of it the injection harness's JVM
startup plus IME processing — where previously text appeared only at the
poll interval.
What this is not
Not IME support: fully translating
TextEventintoImeevents is blockedon semantics (the
Imevocabulary cannot expressdeleteSurroundingText; related: #2305). This change only stopsdiscarding a wake that has already happened, so buffer-reading
applications become event-driven.