Skip to content

fix: keep a hand-off's Battle.net alive and its wait cancellable - #29

Closed
grpace wants to merge 1 commit into
LightforgeProject:mainfrom
grpace:fix/handoff-close-quits-client
Closed

grpace wants to merge 1 commit into
LightforgeProject:mainfrom
grpace:fix/handoff-close-quits-client

Conversation

@grpace

@grpace grpace commented Nov 12, 2026

Copy link
Copy Markdown

Problem

With "keep Battle.net in the background" off and "start Battle.net minimized" on, "Launch via Battle.net" never started the game, and the window went unresponsive for the full 180 s hand-off timeout. It reproduced on every hand-off since 2026-11-08 (1.0.0-beta.11, GE-Proton11-7, Fedora 45 KDE Wayland, client 2.53.8).

1. The tray keeper quits the client mid-launch

account_tweaks(false) writes HideOnClose=false ("closing the window quits") and DisplayExitPrompt=false. launch_via_battle_net still arms ClientWindows::keep_closed for a client started in the tray. Its WM_DELETE_WINDOW is therefore a quit, and the client exits with the launch in flight:

02:34:28.514003 [GameLaunchController] LaunchBinary: uid=wowf selectedRegion=US binaryType=game
02:34:28.515240 [ProductState] InstallState (wowf): GameLaunching=1
02:34:28.549476 [Frontend] Destroying AppController      <- 35 ms later, no "Launched ... Wow.exe"

Lightforge: sent Battle.net's window back to the tray 1 time(s), then no game started within 180s. Agent never saw Wow.exe. The one hand-off that worked was started as a normal window (--from-launcher, no tray), so tray was None and nothing was closed.

Fix: battlenet::close_hides_window(background) reads the same account tweaks, and the tray keeper runs only when it's true. Without it, the client shows its window for the ~2-3 s until the game is up, then exits as GameLaunchWindowBehavior: 2 intends.

2. The 180 s wait blocks shutdown

The game wait (preflight::wait_for_game_start) ran inside spawn_blocking, and the tokio runtime waits for blocking tasks on shutdown. Closing the window during a hand-off left it on screen and unresponsive, with the main thread parked in futex_wait, until the wait ran out. The process exited in the same second as the no game started within 180s warning.

Fix: after the launch is sent and taken, wait_for_handoff awaits the wait: one blocking scan (preflight::game_started, split out of wait_for_game_start) per HANDOFF_POLL. It also returns Handoff::ClientClosed once the client has been gone for two looks in a row with no new game, instead of polling an empty prefix for three minutes. GameLaunchWindowBehavior: 2 exits only after the game is up, so a game that wins that race is still found first.

Testing

  • cargo test --workspace: all pass, including the new only_a_background_client_survives_its_window_being_closed.
  • cargo clippy --all-targets: clean.
  • Not yet run against a live hand-off with this build. I'll report back after trying it.

Related, Not in This PR

  • Hand-off drops the product's tweaks. Direct Play runs Wow.exe with the profile's PROTON_ENABLE_WAYLAND, PROTON_ENABLE_NVAPI and LD_PRELOAD. The hand-off starts the client with battle_net_tweaks only, so the game Battle.net spawns inherits none of them.
  • No control over which game account launches. With several WoW game accounts (WoW1-WoW4 here), the hand-off launches whatever Battle.net last selected. It restores that from account.db (New selection for product group WoW: ... name=WoW4, logged as GAME_ACCOUNT=WoW4 at launch), and silently falls back to a default on a fresh prefix. Direct Play leaves it to the client's SET accountList "...|!WoW4|..." in Config.wtf. A per-product "game account" setting, a warning when Battle.net's selection differs, or a "Launching as WoW4" status line would make a wrong pick visible.

Without "keep Battle.net in the background", the per-account tweaks write
HideOnClose=false and DisplayExitPrompt=false, so closing the client's
window quits it at once. A hand-off to a client started in the tray still
sent WM_DELETE_WINDOW to push the window back, and the client exited 35 ms
after GameLaunching=1, before the game's process existed. The launch was
lost and Lightforge waited out the full 180 s. The tray keeper now runs only
where closing hides the window (close_hides_window).

The 180 s game wait also ran inside spawn_blocking. The runtime waits for
blocking tasks when it shuts down, so a window closed during the wait stayed
on screen, unresponsive, until it ran out. The wait is now async, one blocking
scan per poll, and it ends early when the client is gone with no new game.
@grpace

grpace commented Nov 12, 2026

Copy link
Copy Markdown
Author

Tested live with a release build of this branch (148e04c), same machine and settings as the report: background off, start minimized on, client 2.53.8, GE-Proton11-7.

Before (beta.11), the client exited mid-launch:

02:34:28.515240 InstallState (wowf): GameLaunching=1
02:34:28.549476 [Frontend] Destroying AppController        (no Wow.exe; Lightforge waited out 180 s)

With this PR, the client starts in the tray, no WM_DELETE_WINDOW is sent, and the game is up in about 2 s:

03:02:05.289329 [GameLaunchController] LaunchBinary: uid=wowf selectedRegion=US binaryType=game
03:02:05.442073 [InstallManager] Game launch options: programId=WoW GAME_ACCOUNT=WoW4 REGION=US ...
03:02:05.588036 [InstallManager] Launched C:/Program Files (x86)/World of Warcraft/_forever_/Wow.exe with args: -launcherlogin -uid wowf, pid: 1384
03:02:06.642233 [InstallManager] Game is running: wowf
03:02:07.168970 [Frontend] Destroying AppController         (GameLaunchWindowBehavior 2, as intended)

Lightforge:

21:02:04  starting Battle.net (Product { code: Forever, exec: Some("WoWF") })
21:02:06  Battle.net hand-off for wowf: game started
21:02:06  status: Wow.exe is running

Ready for review from my side.

@simplykenny

Copy link
Copy Markdown
Member

hey, as far as i know i have already fixed that because of an issue

i will go over your PR today and check it

will be in the next release. thank you

@simplykenny

Copy link
Copy Markdown
Member

Checked it again, already done on dev.
Thank you anyways for the PR!

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.

2 participants