mirror of
https://github.com/amnezia-vpn/amneziawg-android.git
synced 2026-12-03 18:32:42 +07:00
[GH-ISSUE #107] libwg-go is built with stock Go, so the boottime runtime patch never makes it in (10–15 s stalls after wake) #104
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
amnezia-vpn/amneziawg-android#104
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Timsonrobl on GitHub (Oct 27, 2026).
Original GitHub issue: https://github.com/amnezia-vpn/amneziawg-android/issues/107
After an Android device wakes from sleep, traffic through AmneziaWG can stall for 10–15 s before connections recover, and longer for apps that add their own reconnect backoff. It isn't tied to a particular phone or app: it shows up on different devices and with different apps, while Windows and macOS clients on the same servers don't have the problem. I reproduced it on AmneziaVPN 5.0.3.0 (Galaxy S25 Ultra, Android 17).
The cause is in the build, not on the device: libwg-go is built with an unpatched Go runtime, so every Android build from this repo since July 2025 is likely affected.
The Makefile downloads Go 1.24.2 and applies
goruntime-boottime-over-monotonic.diffto it, but go.mod saysgo 1.25.0. It has been ahead of the Makefile sincef207d7bf(July 2025), when it went to 1.24.4. With the defaultGOTOOLCHAIN=auto,go builddecides the local toolchain is too old, quietly downloads a stock go1.25.0 and builds with that. The patch is applied to a toolchain that never gets used.You can see it in the shipped library. In the 5.0.3.0 release APK,
lib/arm64-v8a/libwg-go.so,runtime.nanotime1loads clock id 1 before callingclock_gettime:With the patch it would be
#7(CLOCK_BOOTTIME).In practice: CLOCK_MONOTONIC stops while the phone is suspended, so WireGuard's timers and keypair age stop with it. After a few minutes asleep, the client still thinks its keypair is fresh, while the server has already expired it (REJECT_AFTER_TIME). The client keeps sending into the void until the 15 s "stopped hearing back" timer fires and it handshakes again.
I caught one of these with tcpdump on the server (eth0 and the awg interface) and logcat on the phone. According to
dumpsys alarm, the phone had spent 543 of the previous 936 s suspended. The last handshake was 214 s before wake. Once the screen came on, about 45 packets from the phone reached the server's eth0 over 15 s, and none of them showed up decrypted on the awg interface. Then the client logged "Retrying handshake because we stopped hearing back after 15 seconds", and traffic was flowing again 0.4 s later. The app on top added roughly 13 s of its own reconnect backoff, so it was about half a minute from unlock to usable.On the same phone, with a build that uses Go 1.25.0 + the diff +
GOTOOLCHAIN=local:I also ran this repo's build.yml (
debug_apk) on my fork: master produces a libwg-go.so that uses clock 1, and the fix branch one that uses clock 7.