Skip to content

Raise the TcpUsb bridge's max payload to 1 MiB - #551

Merged
koral-- merged 1 commit into
DeviceFarmer:masterfrom
jozenstar:tcpusb-max-payload
Oct 5, 2026
Merged

koral-- merged 1 commit into
DeviceFarmer:masterfrom
jozenstar:tcpusb-max-payload

Conversation

@jozenstar

Copy link
Copy Markdown

A stream through the TcpUsb bridge has one packet in flight: the next A_WRTE waits for the peer's A_OKAY. With packets capped at 64 KiB (UINT16_MAX), throughput is at most 64 KiB per round trip, about 2.8 Mbit/s at 186 ms. That makes remote adb over a WAN noticeably slow, including screen mirroring.

This raises the cap to 1 MiB, adb's own MAX_PAYLOAD. The negotiated size is still min(cap, the client's A_CNXN max payload), so older clients that advertise less are unaffected.

Measurements

Measured through an STF 3.8.0 provider 186 ms away (link about 27 Mbit/s), 8 MiB per transfer:

Direction 64 KiB 1 MiB
exec-out (device → client) 1.86 Mbit/s 34.1 Mbit/s
adb reverse (device → client) 1.89 Mbit/s 35.6 Mbit/s
push (client → device), checksum verified 2.55 Mbit/s 3.8 Mbit/s

push gains less because adb's sync protocol sends its own 64 KiB chunks.

The adb reverse row relies on #550. This change doesn't depend on it.

Testing

npm test: 198 passing.

A stream through the bridge has one packet in flight: the next A_WRTE waits
for the peer's A_OKAY. With packets capped at 64 KiB, throughput is at most
64 KiB per round trip, about 2.8 Mbit/s at 186 ms. 1 MiB is adb's own
MAX_PAYLOAD; the negotiated size is still the minimum of this and what the
client advertises in A_CNXN, so older clients are unaffected.

Measured through an STF provider 186 ms away, 8 MiB per transfer:

  exec-out (device -> client)     1.86 -> 34.1 Mbit/s
  adb reverse (device -> client)  1.89 -> 35.6 Mbit/s
  push (client -> device)         2.55 ->  3.8 Mbit/s

Android Studio's Device Mirroring streams its video over adb reverse.

Signed-off-by: Arthur Yazhevich <[email protected]>
@koral--
koral-- merged commit eab178e into DeviceFarmer:master Oct 5, 2026
2 checks passed
@jozenstar
jozenstar deleted the tcpusb-max-payload branch October 5, 2026 13:10
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