Skip to content

Send the terminal resize off the main thread - #81

Merged
ehoeve786 merged 1 commit into
mainfrom
resize-off-main
Oct 31, 2026
Merged

ehoeve786 merged 1 commit into
mainfrom
resize-off-main

Conversation

@ehoeve786

Copy link
Copy Markdown
Owner

Cause of the SSH drops after a resize

TerminalEmulator calls onResize on the main thread, and the bridge sent the PTY window-change from there. Android refuses network I/O on the main thread. JSch had already encrypted the packet and advanced its outgoing sequence number before the socket write failed, and runCatching hid the error. Every later packet was then out of step with the server, which closed the connection at the client's next packet:

  • C3X: the reply to the server's 10-second keepalive probe (its sessions lasted exactly 10 s in last).
  • Proxmox: the 5-second client keepalive from Send the client keepalive every 5 seconds #80 (dropped about 2.5 s after the keyboard closed).

Termux and non-terminal commands don't resize, so they were unaffected.

Change

The resize goes through the bridge's single writer thread, the one keystrokes already use, so it is sent off the main thread and in order with typed input.

The earlier experiments (#76 dedupe, #78 read/draw split, #79 zero pixels, #80 5-second keepalive) stay; they're harmless, and the keepalive still detects dead links within 30 s.

Test

On the C3X and Proxmox: connect, open and close the keyboard and a sheet, then leave it idle for a minute.


Generated by Claude Code

onResize runs on the main thread, and the window-change it sent is network I/O, which Android refuses there. The SSH library had already encrypted the packet and advanced its sequence number before the write failed, so every later packet was out of step with the server, and the server closed the connection at the client's next packet: the reply to the C3X's 10-second keepalive probe, or the 5-second client keepalive on Proxmox.

The resize now goes through the bridge's writer thread, the same one keystrokes use, so it is sent in order with them.

Claude-Session: https://claude.ai/code/session_01CiTeuL5wrBa86ELAzASv4B
@ehoeve786
ehoeve786 merged commit f845e68 into main Oct 31, 2026
6 checks passed
@ehoeve786
ehoeve786 deleted the resize-off-main branch October 31, 2026 23:13
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