Skip to content

Run Map: never launch without the sign-in lock, and keep the Battle.net window out of sight - #1627

Merged
Frotty merged 3 commits into
masterfrom
battlenet-lock-busy
Nov 17, 2026
Merged

Frotty merged 3 commits into
masterfrom
battlenet-lock-busy

Conversation

@Frotty

@Frotty Frotty commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Two fixes to Run Map's Battle.net sign-in renewal (#1624).

1. Never launch without the sign-in lock

BattleNetSignIn.acquireGate() waited only 30 s for the shared Battle.net sign-in lock, then threw a plain IOException. RunMap.renewBattleNetSignIn treats any IOException from renew() as "could not renew", so in wc3LaunchMode "auto" it launched on the stored sign-in without the lock.

Another Run Map, grill run or other tool's run legitimately holds that lock through its renewal (up to 90 s) and until its client signs in (up to 120 s). An unlocked launch in that window can spend the token that client has not read yet, leaving one of them at the login panel.

  • The lock wait now covers another holder's renewal and sign-in: GATE_WAIT_SECONDS = 90 + 120 + 30 s.
  • While waiting, Run Map shows "Another Warcraft III launch is signing in; waiting until it has...".
  • A lock still held after that ends in BattleNetSignIn.LockBusyException. RunMap.renewOrRefuse turns it into a failed run in every mode ("Run the map again once it has signed in.").
  • Other renewal failures (Battle.net closed, signed out, updating) keep their fallback.

This mirrors the fix in grill run (wurstscript/WurstSetup#90).

2. Keep the Battle.net window out of sight

Asked to start Warcraft III for the renewal, Battle.net creates a window and shows it in front. Depending on its "when I launch a game" setting, it leaves it there. It also shows it again as the launched client signs in, 10–20 s later. The handoff after the launch (BattleNetLaunchWindows, #1625) can only minimize it after it has flashed on screen.

Before asking, the renewal now starts battlenet-window.ps1, a shared window-watcher script:

  • It hooks window creation (SetWinEventHook). Each new Battle.net window is moved off-screen as it is created, shown out of sight, and minimized without activation.
  • Its restore position is set back to where Battle.net put it, so the user's own next Restore opens it normally.
  • It also hides a launcher window the app shows again or restores. A launcher the user already had open in the background is left alone.
  • It closes a crash reporter (BlizzardError.exe) that appears before the map's client, which can only belong to the renewal's closed client.
  • It ends itself a minute after the map's client appears, past its sign-in, or after WINDOW_WATCH_SECONDS without one.
  • It runs with -File from a content-named temp copy: passed with -EncodedCommand, the script is close to Windows' 32,767-character command line limit.
  • It runs without -FocusGame, since BattleNetLaunchWindows focuses the client by process id.

Validation

  • Tests pass:

    • BattleNetSignInTest (9)
    • BattleNetLaunchWindowsTest (1)
    • InitialBuildProgressTest (8)
    • MapRequestPatchTargetTests (17)
    • WurstBuildConfigTests (14)
    • BuildDiagnosticsTests (10)
    • MapModelReuseTests (56)

    New tests cover:

    • a busy lock: LockBusyException after a short, injectable wait, with the wait reported;
    • renewOrRefuse refusing on a busy lock and passing other failures on;
    • the lock wait and watcher lifetimes;
    • the watcher command and its ASCII script copy.
  • Live on Windows, twice, through BattleNetSignIn.renew(), a direct launch and releaseWhenSignedIn(), with a separate logger sampling every 100 ms:

    • The Battle.net window only ever appeared minimized at -18286,-18286, never on screen or in the foreground.
    • The game took the foreground when its window opened.
    • The lock was released 13 s after launch.
    • Nothing else showed for the remaining ~38 s, which covers the sign-in.
  • The same sequence without the watcher showed Battle.net's window in front during the renewal and again ~19 s after launch.

  • Not tried from VS Code's Run Map itself.

Run Map gave up on the renewal lock after 30 s and, in wc3LaunchMode "auto",
treated that like any renewal failure: it launched on the stored sign-in
without the lock. Another Run Map, grill run or harness run holds the lock
through its renewal (up to 90 s) and until its client signs in (up to
120 s), so that unlocked launch could spend the token the other client had
not read yet, leaving one of them at the login panel.

The lock wait now covers a renewal and a sign-in (240 s), says why the run
is waiting, and ends in a LockBusyException. RunMap.renewOrRefuse turns that
into a failed run in every mode; other renewal failures keep their fallback.
This mirrors grill run (wurstscript/WurstSetup#90).
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T14:07:39.123437Z 5410c9e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Asked to start Warcraft III for the renewal, Battle.net creates a window
and shows it in front, and shows it again as the launched client signs
in, ten to twenty seconds later. The handoff after the launch
(BattleNetLaunchWindows) minimized it only once it had flashed on screen.

Before asking, the renewal now starts battlenet-window.ps1, a copy of the
wc3-e2e-harness script, run with -File from a content-named temp copy. It
hooks window creation: each new Battle.net window is moved off-screen as
it is created, shown out of sight, and minimized without activation with
its restore position set back, so the user's own next Restore opens it
normally. It also hides a window the app shows again or restores, closes
a crash reporter of the renewal's closed client, and ends a minute after
the map's client appears.
@Frotty Frotty changed the title Never launch Run Map without the Battle.net sign-in lock Run Map: never launch without the sign-in lock, and keep the Battle.net window out of sight Nov 17, 2026
Updates the copy of wc3-e2e-harness battlenet-window.ps1. Until the run's client appeared, the watcher closed every new BlizzardError.exe, so a crash report from a game the user already had open was cut short too. It now closes a new reporter only when its parent is a renewal client it saw (started by Battle.net) or a process already gone that was not one of the games running before; every other reporter is left alone.
@Frotty
Frotty merged commit f07038a into master Nov 17, 2026
2 checks 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