android: the phone walk waits for the app, not just for the WebView

A walk always follows a fresh install, so the app is always cold: the shell
mounts, the library loads, Soulseek logs in and the share index is built.
Attaching only proves the WebView answers, and the walk used to begin its
first step there — against a page that had not finished mounting, which
reads as a broken feature rather than a slow boot. It now waits for the
handle it drives, and the attach itself gets two more tries when the
devtools socket outlasts its own forty seconds of patience.
This commit is contained in:
KeelrLeek committed 2026-09-14 06:43:53 -05:00
1 parent 0ce8c63cb6
commit 9bfbcfc96c
2 files changed
+22 -4

No files matched your search

+5 -4
View File
@@ -97,12 +97,13 @@ export async function attachPhone(port) {
/* The devtools socket is registered by the WebView, not by the process, so
there is a window after a launch where the app is up, focused and has a
pid, and the socket does not exist yet. On a loaded machine that window
has been as long as ten seconds — a walk that attached once and gave up
read it as "is SoulStream on screen?" when it plainly was. Try for a
while, re-reading the pid each time in case the app restarted under us. */
has been longer than CDP.attach’s own forty seconds of patience — and the walk
then reported "is SoulStream on screen?" about an app that plainly was. Each
attempt below already waits 40s; three of them is the ceiling, re-reading the
pid each time in case the app restarted underneath us. */
let pid = "";
let last = null;
for (let attempt = 0; attempt < 6; attempt++) {
for (let attempt = 0; attempt < 3; attempt++) {
pid = adb("shell", "pidof", "com.soulstream.app").toString().trim();
if (pid) {
adb("forward", "--remove-all");
+17
View File
@@ -2290,6 +2290,23 @@ async function main() {
steps = PHONE_STEPS; expect = PHONE_EXPECT; prefix = "phone-";
still = phoneStill;
console.log("attached to the phone's WebView (pid " + pid + ")");
/* A walk follows a fresh install, so the app is always cold here: the
shell mounts, the library loads, Soulseek logs in and the share
index is built. Attaching only proves the WebView answers — it says
nothing about the app being up. Starting anyway means the first
steps run against a half-mounted page and get reported as broken
features, which is exactly how an hour went once. Wait for the
handle the walk actually drives. */
const upFrom = Date.now();
let up = false;
while (Date.now() - upFrom < 90_000) {
try {
if (await cdp.evaluate(`!!(window.__ss && document.querySelector('.app'))`) === true) { up = true; break; }
} catch { /* a page mid-navigation answers nothing; ask again */ }
await sleep(1000);
}
if (!up) throw new Error("the app never came up on the phone (no __ss and no .app after 90s)");
console.log("the app is up (" + ((Date.now() - upFrom) / 1000).toFixed(1) + "s after attaching)");
} else {
if (!CHROME) throw new Error("Chrome not found");
console.log("building dist-smoke/ …");