Skip to content

fix(adb): heal wedged offline transport + Player.log boot gate (#18)#19

Merged
Jordan231111 merged 3 commits into
mainfrom
fix/adb-offline-heal-slowboot
Jun 3, 2026
Merged

fix(adb): heal wedged offline transport + Player.log boot gate (#18)#19
Jordan231111 merged 3 commits into
mainfrom
fix/adb-offline-heal-slowboot

Conversation

@Jordan231111

@Jordan231111 Jordan231111 commented Jun 3, 2026

Copy link
Copy Markdown
Owner

What & why

Fixes the #18 failure on a low-end 2013 HP Pavilion where the Android-11 guest boots fine (multi-minute boot, home screen visible) but the script loops on device offline forever and never roots.

Root cause: on a slow boot the per-instance adb transport is created during early boot and wedges in offline (TCP socket up, adb handshake never finalized). adb's connect no-ops on an existing transport (already connected), so it never re-handshakes — Boot-And-Wait polled getprop sys.boot_completed over a dead transport until timeout. The reporter's manual kill-server; connect (after the home screen was up) recovered it — which is exactly what this automates. On a fast PC the offline window is a few seconds and the socket churns/handshakes on its own, so the bug never reproduced.

Changes (tools/bsr_magisk.ps1 → re-embedded into blueStackRoot.cmd)

  • Heal the transport. Per poll: connectget-state; if not device, disconnect+connect to force a fresh handshake, then re-check. Deterministic recovery instead of relying on the socket happening to churn.
  • Host-side boot gate. Player.log is per-instance tagged with a phase (StartingKernel → StartingAndroid → Ready). [Ready] is a "guest booted" signal independent of adb (immune to the offline race). Marked at launch so a previous boot's [Ready] can't false-positive.
  • Liveness, not WMI-only. Relaunch fires only when nothing says the instance is alive (conf adb port not listening AND no Player.log activity AND no process), so the false Get-HdPlayerCount==0 (null/blocked WMI command line) no longer spams retrying launch.
  • Sane timeouts. Fail fast (~90s) when nothing is alive at all (not a slow boot); cap the post-[Ready] wait at 120s; otherwise tolerate multi-minute boots.
  • Retry helpers heal too. AdbShellRetry/AdbTry now disconnect+connect on a dropped transport instead of a no-op reconnect (covers mid-DATA drops such as the magiskd reboot — the reporter's second-boot wedge).

Logging split (intentional)

  • blueStackRoot.cmd (production / all future releases): terminal logging only — the existing Say/Write-Host progress output, no files written.
  • debug.cmd (standalone read-only probe): the foolproof logger — launches the instance, logs get-state / Player.log / WMI, runs the disconnect+connect heal live, and writes a full bsr_debug_*.log to the Desktop with a final VERDICT (SUCCESS via HEAL, booted-but-adb-stuck, never-started, crashed). Designed so one attached log is enough to diagnose.

Tests

  • New unit tests for Parse-AdbState and the Player.log ready/alive parsers (via a PlayerLogProbe seam).
  • Run-Magisk-Unit-Tests.ps1: 256 passed, 0 failed.
  • reembed.ps1 + Check-Embedded-Sync.ps1: embedded blueStackRoot.cmd blocks in sync with tools/ sources; the production .cmd writes no log files (bsr_run_/Init-BsrLog/LogV = 0).

Refs #18

On a slow boot the per-instance adb transport can wedge in 'offline' (socket up, handshake never finalized). adb's 'connect' no-ops on it ('already connected'), so Boot-And-Wait polled getprop over a dead transport until timeout -- the #18 failure on a 2013 low-end PC where the guest booted fine but adb never came online.

Boot-And-Wait now: (1) HEALs an offline transport via disconnect+connect to force a fresh handshake instead of a no-op reconnect -- the deterministic form of the manual kill-server+connect that recovered it by hand; (2) gates 'booted' on a host-side Player.log [Ready] signal (per-instance tagged), independent of adb; (3) bases liveness on the conf adb port listening / Player.log rather than the WMI command-line read alone, so a false WMI zero no longer spams 'retrying launch'; (4) fails fast when nothing is alive and caps the post-[Ready] wait, while still tolerating multi-minute boots. AdbShellRetry/AdbTry now heal (not just reconnect) on a dropped transport.

Adds always-on redacted file logging (Init-BsrLog/LogV) so a failing run leaves a full step-by-step log, plus a standalone read-only debug.cmd probe. New unit tests for Parse-AdbState and the Player.log ready/alive parsers (256 pass). Re-embedded into blueStackRoot.cmd; embedded-sync check green.
blueStackRoot.cmd no longer writes %TEMP%\bsr_work\bsr_run_*.log on every run -- the adb fix is unchanged, only the file logging is removed. The standalone debug.cmd probe remains the sole writer of a log file (bsr_debug_*.log on the Desktop), used only when the main build still fails.
@Jordan231111 Jordan231111 merged commit 86aa98a into main Jun 3, 2026
1 check passed
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.

1 participant