Skip to content

fix(ironsmith): stop Commander games freezing, start seats together, stop the guest hand blinking - #1300

Merged
khaliostr merged 3 commits into
witchesofthehill:mainfrom
Chiplis:fix/ironsmith-startup-and-flicker
Nov 26, 2026
Merged

khaliostr merged 3 commits into
witchesofthehill:mainfrom
Chiplis:fix/ironsmith-startup-and-flicker

Conversation

@Chiplis

@Chiplis Chiplis commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Updates ironsmith-wasm to 1.0.3, which fixes Commander games slowing down and then freezing, and makes the engine hold a pass-until target the way hosted Forge does.
  • The host sends the match's decks to the other seats before it starts its own engine, so every seat compiles the cards at the same time instead of one after another.
  • A seat puts its own view back right after the room's public view is drawn, so a guest's hand no longer blinks on every input.

Why

A three-player Commander table on play.manabrew.app got slower every turn (about 5 s per land tap) and then stopped responding. Two other things showed up in the same game: a long "waiting for players" at the start, and the guests' hands flickering.

The freeze (engine, fixed in 1.0.2). The engine has a cheap test for "this cost certainly cannot be paid". It stood down whenever it met an ability it did not recognise, and ordinary spell markers counted: cascade, "can't be countered if X is 5 or more", "damage can't be prevented". With one of those on a commander or in hand and a Signet in play, every unaffordable check simulated every activation order. Each seat replays every input, so every engine paid for it. Measured on the published 1.0.0 package with three seats and an 8-mana commander: one input took 21–28 s with four mana sources and 177 s a turn later; the same game without commanders stayed under 250 ms. 1.0.2 also bounds the commander check like the rest of the menu, counts what a mana ability costs to activate (a Signet nets one mana), and budgets the re-plan after a manual tap, which had been taking 16–19 s per tap on a six-source board.

Phase stops (engine, fixed in 1.0.3). During the game a player noted that turns were slow compared to Forge because the phase stops did not seem to be honoured. A pass carries an until target, and hosted Forge holds it per seat until that player's step arrives (PriorityFastForward). Ironsmith mapped it to an engine yield that ended with the current turn and whenever any other seat stopped, so every seat was asked again at upkeep and at each of the active player's stops. With the client's default stops, three seats that only pass got 15 priority prompts a turn where Forge's rule gives 5. The adapter now keeps the target per seat across turns, still asks when something is on the stack or creatures are attacking, and drops the hold on an extra phase, the holder's own extra turn, or a target player leaving. Verified matches keep the engine's signed yield and are unchanged.

Startup. A seat only began compiling cards when the host's first sync arrived, which the host sends after its own engine has started. Compiling three Commander decks takes about 20 s, so seats were ready one compile after the host. Now the host sends a prepare payload with the decks first; a seat compiles them in an engine it then keeps for the sync. This uses registerManabrewDeckSources, which 1.0.0 already has.

Flicker. The store draws the room's public view (no hidden cards) on every seat. A seat then asked its engine for its own view again, which is a worker round trip, so the public view was painted in between. A seat now re-emits the view it last drew, in a microtask, so it lands after every listener of the event and before the browser paints.

Test plan

  • Three seats of the real IronsmithTrustedGameApi in Chrome pages joined by an in-process relay, three preset Commander decks:
    • all seats ready: 46.4 s on main, 30.3 s here (all three engines shared one machine; on separate machines a seat should be ready about when the host is);
    • frames in which a guest that holds cards is shown none: 6–13% on main, 0 of ~7,900 here;
    • a 38-turn, 1,200-input game on 1.0.2 completed with every seat in step.
  • Engine, in Node on the package: the 45-turn freeze repro's worst input went from 177 s to 215 ms; a manual tap in the commander's payment prompt from 16–19 s to at most 370 ms.
  • Phase stops, in Node on the 1.0.3 adapter with the client's default stops and getNextStop targets: 12 pass-only turns went from 15 priority prompts a turn to 5 (the active seat's main 1, attackers and main 2, and each opponent's end step); a 29-turn game with real actions finished without errors, and every prompt during a hold was in a combat step with attackers.
  • vitest run src/game: 55 pass. eslint and prettier --check on the changed files are clean; tsc reports nothing in them (my checkout has stub wasm bindings, so it still reports the existing WasmBot/WasmManabot errors elsewhere).
  • Not done: the full yarn lint, the tests/e2e-ironsmith suite, a run against the real relay with players on separate machines, and a browser run on 1.0.3 (the three-seat browser runs above were on 1.0.2; 1.0.3 was measured through the adapter in Node, and tests/e2e-ui/forge-wasm-autopass.mjs was not run against it).

Still slow, though no longer growing without limit: on a 19-permanent board, cancelling a payment took about 1 s per seat.

prepare is a new private payload type. Older clients ignore payload types they do not know, so this needs no transcript version bump; a seat that does not get one starts as before.

🤖 Generated with Claude Code

…t hand blinking

The host now sends the match's decks to the other seats before it starts
its own engine, so each seat compiles the cards while the host does
instead of after it. A seat keeps that engine for the sync that follows.

A seat also puts its own view back right after the room's public view is
drawn, before the browser paints, so its hand no longer disappears for a
moment on every input.
1.0.2 fixes Commander games freezing: checking whether a commander or
any other spell could be paid for searched every activation order once a
Signet was in play, and each manual land tap re-searched the payment.
1.0.3 holds a pass-until target the way hosted Forge does: across turn
boundaries, and without another seat's stop ending it. With default phase
stops a three-player turn went from 15 priority prompts to 5.
@khaliostr
khaliostr merged commit 6eb573a into witchesofthehill:main Nov 26, 2026
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