Skip to content

Timing learning + freeze fix — improved persist build (2026-11-17)

Choose a tag to compare

@yyoossk yyoossk released this 16 Nov 19:13
· 7 commits to main since this release

Timing learning + freeze fix — improved persist build
A fork of SeanHeuc/CivSwitchFS at commit 59a1ea6 (the pin used by SeanHeuc/civ-autoloader), with two improvements. Only 5 source files differ from upstream (407 insertions, 1 deletion). Confirmed working on real hardware (Switch 2, firmware 23.0.1, Civilization VII v1.0.0 cartridge).
What's new

  1. Timing learning (persistent winning schedule)
    Upstream, the FS canary campaign keeps its timing adjustments only in memory: every Load Game starts again from the stock delay table. This fork records the winning schedule in the save itself and starts from it on the next boot.
    A fixed-size record segment ( XCFG:1: + 120 hex chars: roleDelays ×10, guardDelays ×2, win counter, CRC32) is appended to the trigger record inside XSTRIG.Civ7Save at install time (zeroed = no record).
    On boot, the record is read through the game's own save mount before the race (src/core/timing-slot.mjs). If it validates (magic, CRC, win count ≥ 1, delays within ±1 ms of the stock table, strictly increasing), the run starts from it and the screen shows TIMING: recorded schedule loaded (win N); starting from it.
    After FS acquisition succeeds, the winning schedule is written back in place (same size, read-back verified): AUTOLOADER: TIMING: winning schedule recorded for the next boot.
    Safety: an invalid or corrupted record is ignored (stock behavior). Reinstalling the autoloader save resets the record to zero; installing with the upstream build removes the segment entirely. Fully reversible.
  2. Freeze fix (bounded IPC sends)
    Every IPC send in the payload was a bare svcSendSyncRequest, which has no timeout. When the FS service stops replying mid-race (a known failure mode of this exploit), the payload's only JS thread blocks forever and the console freezes on the last status line (observed at Checking the canary window...).
    sendIPC now runs each send on a sacrificial raw thread and waits at most 10 seconds (src/core/ipc/transport.js).
    On timeout, the packet is poisoned so reply parsing reports an error, a latch makes all later sends fail fast (so cleanup cannot hang either), and the run ends with File-system service stopped responding; the run was stopped safely. instead of freezing.
    If the raw-thread machinery is unavailable, it falls back to the original direct send.
    Note: this cannot make a wedged FS reply succeed — it turns an infinite freeze into a clean, visible failure you can retry from.
    Verified on real hardware (2026-11-17)
    The homemade loader setup (kaiHEN Installer) booted successfully with the Japanese version of the game on a Japanese console — not just overseas versions.
    Timing learning works as intended: after the first success recorded its schedule (win 1), the autoloader starts from the recorded timing on every later boot, and kaiHEN booted at a high rate from the second boot onward.
    The freeze at Checking the canary window... no longer occurs with the bounded-IPC build; the same boot sequence that previously froze now completes.
    Changed files
    src/core/timing-slot.mjs (new, +290)
    src/core.js (+22)
    src/core/autoloader.mjs (+13)
    persist/save-codec.js (+8)
    src/core/ipc/transport.js (+75/−1)
    Use
    Build as usual (npm ci && npm run persist:build), or use the attached prebuilt persist files with the civ-autoloader persist install flow. The attached build is byte-identical to the one verified on hardware:
    persist-bootstrap.js sha256 8179c983aa2853ca4f56fa3f4bd9315eb1f304e85ec5fd6562145b9332082b9b
    save-template.bin sha256 32fa8a0d6dd0a480d8e541e63ea44c4619bc6f7be4282cfc3cb6a4f6d305dfae (unchanged from upstream)
    The timing record only exists in saves installed with this build — reinstall the autoloader save once after switching.
    Credits
    Original work: SeanHeuc (CivSwitchFS / civ-autoloader), Gezine (CivSwitch). This fork only adds the two improvements above. Same license as upstream.

タイミング学習 + フリーズ修正 (改良版 persist ビルド)
SeanHeuc/CivSwitchFS (civ-autoloader が使うピン 59a1ea6) のフォークです。 upstream との差分はソース5ファイルのみ (407行追加・1行削除)。実機確認済み (Switch 2 / FW 23.0.1 / シヴィライゼーション7 カード v1.0.0)。
改良点

  1. タイミング学習
    成功したときの canary タイミングをセーブ内に記録し、次回起動時にそこから開始します。記録は検証付き (CRC・範囲チェック) で、不正なら無視されます。セーブを入れ直せば記録はリセットされ、upstream 版で入れ直せば記録欄ごと消える可逆な実装です。画面表示: TIMING: recorded schedule loaded (win N); starting from it.
  2. フリーズ修正
    タイムアウトのない IPC 送信が FS 無応答時に永久ブロックし、画面が凍結する問題を修正。送信を使い捨てスレッドで実行し最大10秒で打ち切ることで、固まる代わりに File-system service stopped responding; the run was stopped safely. と表示して安全に終了します。
    実機結果 (2026-11-17)
    自作ローダー (kaiHEN Installer) が、日本版のソフト・国内版本体でも起動しました (海外版だけではありません)。
    タイミング学習の効果: 初回の成功でタイミングが記録されて以降 (win 1)、オートローダーは毎回記録したタイミングから開始し、2回目以降は高い確率で kaiHEN が起動しました。
    「Checking the canary window...」で固まる問題は、修正版では発生しなくなり、以前固まった起動手順でも最後まで完了しました。
    使い方
    通常通り npm ci && npm run persist:build でビルドするか、添付のビルド済み persist ファイルをそのまま使えます。学習の記録欄はこの版でセーブを入れ直したときから作られます。