Skip to content

Stop the keyboard and Backtalk waiting on each other in Backtalk's fields - #225

Merged
aryanchoudharypro merged 3 commits into
trypsynth:masterfrom
aaron-gh:keyboard-safe-fields
Oct 20, 2026
Merged

aryanchoudharypro merged 3 commits into
trypsynth:masterfrom
aaron-gh:keyboard-safe-fields

Conversation

@aaron-gh

Copy link
Copy Markdown
Contributor

Typing quickly in one of Backtalk's own text fields, such as a settings dialog or screen search, could stall for seconds and lose or scramble keys.

As a keyboard types, it asks the field about its text and waits for the answer. Backtalk's fields are in Backtalk's own process, so they answered on its main thread. That thread also makes synchronous accessibility requests to the keyboard's window about its keys. Each side waited for the other until the keyboard gave up, about two seconds later.

Backtalk's text fields now answer the keyboard on a thread of their own (KeyboardCalls, used by KeyboardSafeEditText). Each call still runs on the main thread, in order.

  • Changes to the text are made without waiting, since the keyboard doesn't wait for them either.
  • For a question about the text, the keyboard waits at most 150 ms.
  • If a question goes unanswered because the main thread is busy, later questions get no answer straight away until the main thread has run it.

KeyboardSafeEditText is used in every Backtalk layout and dialog that has a text field. It also replaces AndroidX Preference's EditTextPreference dialog layout.

Text fields in other apps answer on those apps' own main threads, so this can't happen there.

Limitations: while the main thread is busy, questions about the text go unanswered. Keyboards handle that as they do a field that can't answer. A keyboard can then misjudge the cursor position for keys typed during that time.

Tested:

  • Unit tests:
    • answering while the main thread is free and while it is busy
    • changes made while it is busy
    • changes not waiting
    • a question seeing an earlier change
  • On an Android 17 emulator with Gboard:
    • 16 fast taps in the Gemini API key field: no stalls or timeouts.
    • Fast typing and Backspace in settings dialogs: the text was correct.
  • With the first commit alone, fast typing in a dialog once stalled for 3.5 s, and every keyboard call timed out. The second commit addresses that. I couldn't reproduce the stall on demand.

aaron-gh and others added 3 commits October 19, 2026 16:09
…elds

Typing quickly in one of Backtalk's own text fields, such as a settings
dialog or screen search, could stall for seconds and lose keys. A
keyboard asks the field about its text as it types, and Backtalk's
fields answered on its main thread. That thread also asks the keyboard
about its keys, so each could wait for the other until the keyboard
gave up two seconds later.

Backtalk's text fields now answer the keyboard on a thread of their
own. Each call still runs on the main thread, in order, but the
keyboard waits for it at most 150 ms. A change to the text that takes
longer still happens; a question about the text that takes longer goes
unanswered, which keyboards handle as they do a field that can't say.

Text fields in other apps answer on those apps' own main threads, so
this can't happen there.

- KeyboardCalls answers an InputConnection on its own thread.
- KeyboardSafeEditText uses it, in every Backtalk layout and dialog,
  and in place of AndroidX Preference's EditTextPreference dialog
  layout.
- Unit tests for answering while the main thread is free and busy, and
  for changes made while it is busy.
Typing quickly in one of Backtalk's own fields could still stall for
seconds and scramble the text. Each call from the keyboard waited up to
150 ms for the main thread, changes included, so while the main thread
was waiting for the keyboard, a question queued behind several changes
waited for all of them, and the keyboard with it.

The keyboard doesn't wait for changes to the text, so they are now made
on the main thread without waiting. After a question goes unanswered
because the main thread is busy, later questions are unanswered at once
until the main thread has run it.

- Unit tests for changes not waiting, questions while the main thread is
  busy and after it is free, and a question seeing an earlier change.
@aryanchoudharypro
aryanchoudharypro merged commit 4715556 into trypsynth:master Oct 20, 2026
2 checks passed
mad-gamer26 added a commit to mad-gamer26/BacktalkRemote that referenced this pull request Oct 20, 2026
Brings in the keyboard-safe text fields (trypsynth#225), which also cover the
remote access key and relay server dialogs through the replaced
EditTextPreference layout, settings that open before Backtalk has
connected (trypsynth#226), and the fresh reading order search (trypsynth#221).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SKArzG82mfYh483GfqQKFo
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