fix(adb): heal wedged offline transport + Player.log boot gate (#18)#19
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 offlineforever 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'sconnectno-ops on an existing transport (already connected), so it never re-handshakes —Boot-And-Waitpolledgetprop sys.boot_completedover a dead transport until timeout. The reporter's manualkill-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 intoblueStackRoot.cmd)connect→get-state; if notdevice,disconnect+connectto force a fresh handshake, then re-check. Deterministic recovery instead of relying on the socket happening to churn.Player.logis 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.Get-HdPlayerCount==0(null/blocked WMI command line) no longer spamsretrying launch.[Ready]wait at 120s; otherwise tolerate multi-minute boots.AdbShellRetry/AdbTrynowdisconnect+connecton 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 existingSay/Write-Hostprogress output, no files written.debug.cmd(standalone read-only probe): the foolproof logger — launches the instance, logsget-state/ Player.log / WMI, runs the disconnect+connect heal live, and writes a fullbsr_debug_*.logto the Desktop with a finalVERDICT(SUCCESS via HEAL,booted-but-adb-stuck,never-started,crashed). Designed so one attached log is enough to diagnose.Tests
Parse-AdbStateand thePlayer.logready/alive parsers (via aPlayerLogProbeseam).Run-Magisk-Unit-Tests.ps1: 256 passed, 0 failed.reembed.ps1+Check-Embedded-Sync.ps1: embeddedblueStackRoot.cmdblocks in sync withtools/sources; the production.cmdwrites no log files (bsr_run_/Init-BsrLog/LogV= 0).Refs #18