android-emulator: api36-v4 — pin emulator 36.1.9; bind socat to pod IP

Two final fixes from the live debugging session: (1) sdkmanager-latest
emulator 36.6.11 hangs before executing a single guest instruction in
this pod (KVM and TCG alike, every gpu mode, crash-reporting on or off)
while 36.1.9 boots Android in ~107s — the entrypoint now pins build
13823996 on the PVC; (2) the emulator already listens on 127.0.0.1:5555,
so socat's wildcard bind died with EADDRINUSE and its exit restarted the
pod right after a successful boot — socat now binds the pod IP only.
This commit is contained in:
Viktor Barzin 2026-06-11 22:52:54 +00:00
parent 85dbec6108
commit 577267cd97
3 changed files with 23 additions and 5 deletions

View file

@ -4,8 +4,8 @@
# cmdline-tools and the native libraries the emulator needs at runtime.
#
# Rebuild + push (rare — only when tool/library versions bump):
# docker build -t forgejo.viktorbarzin.me/viktor/android-emulator:api36-v3 .
# docker push forgejo.viktorbarzin.me/viktor/android-emulator:api36-v3
# docker build -t forgejo.viktorbarzin.me/viktor/android-emulator:api36-v4 .
# docker push forgejo.viktorbarzin.me/viktor/android-emulator:api36-v4
FROM eclipse-temurin:17-jdk-jammy
ENV DEBIAN_FRONTEND=noninteractive

View file

@ -6,6 +6,11 @@ set -euo pipefail
API_LEVEL="${API_LEVEL:-36}"
SYSTEM_IMAGE="system-images;android-${API_LEVEL};google_apis;x86_64"
# Pinned emulator build (36.1.9). The sdkmanager-latest emulator (36.6.11)
# hangs before executing a single guest instruction in this pod (KVM and TCG
# alike, all gpu modes) — debugged 2026-06-11; 36.1.9 boots fine. Bump only
# after verifying a newer build actually boots here.
EMULATOR_BUILD="${EMULATOR_BUILD:-13823996}"
AVD_NAME="${AVD_NAME:-lab}"
EMULATOR_RAM_MB="${EMULATOR_RAM_MB:-4096}"
SCREEN_GEOMETRY="${SCREEN_GEOMETRY:-1080x2280x24}"
@ -39,6 +44,16 @@ if [ ! -f "$MARKER" ]; then
touch "$MARKER"
fi
# --- pin the emulator build (replaces whatever sdkmanager installed) ---------
if [ ! -f "/sdk/.emulator-pinned-${EMULATOR_BUILD}" ]; then
echo "Pinning emulator build ${EMULATOR_BUILD}..."
wget -q "https://dl.google.com/android/repository/emulator-linux_x64-${EMULATOR_BUILD}.zip" -O /sdk/emu.zip
rm -rf /sdk/emulator
unzip -qo /sdk/emu.zip -d /sdk && rm -f /sdk/emu.zip
rm -f /sdk/.emulator-pinned-*
touch "/sdk/.emulator-pinned-${EMULATOR_BUILD}"
fi
# --- AVD (idempotent) --------------------------------------------------------
# avdmanager IGNORES ANDROID_SDK_ROOT (and has no --sdk_root): it derives the
# SDK root from its own toolsdir. Run it from a copy of cmdline-tools seeded
@ -83,8 +98,11 @@ done
echo "Boot completed."
# Expose the emulator's adbd (localhost:5555) to the pod network. Plain TCP,
# no auth — reachable only inside the LAN via the MetalLB IP.
socat TCP-LISTEN:5555,fork,reuseaddr TCP:127.0.0.1:5555 &
# no auth — reachable only inside the LAN via the MetalLB IP. Bind to the pod
# IP only: the emulator itself already listens on 127.0.0.1:5555, so a
# wildcard bind fails with EADDRINUSE.
POD_IP=$(hostname -i | awk '{print $1}')
socat "TCP-LISTEN:5555,bind=${POD_IP},fork,reuseaddr" TCP:127.0.0.1:5555 &
# Supervise: if any background process dies, exit so the pod restarts.
wait -n

View file

@ -5,6 +5,6 @@ variable "tls_secret_name" {
variable "image_tag" {
type = string
default = "api36-v3"
default = "api36-v4"
description = "android-emulator image tag at forgejo.viktorbarzin.me/viktor/android-emulator. Built + pushed manually from stacks/android-emulator/docker/ (see README.md) — bump this when the image is rebuilt."
}