xgameruntime: LEONIDA_TRACE_XGAMESAVE logs every XGameSave call #2432

Manually merged
github merged 1 commit from github-bot/gh-2432 into gh-pr/2432/base 2026-11-27 10:53:08 +00:00 AGit
Owner

@⁠OreoFR on GitHub · 2026-11-27 03:28 UTC · original
OreoFR:rt-xgamesave-trace → main · +476 −50 · 4 files · 1 commits · merged 2026-11-27 10:48 UTC

Claimed in the coordination issue as: RT-XGAMESAVE-TRACE

What and why

"Couldn't autosave" still shows sometimes, and the logs cannot say whether a save call failed: the offline save shim (runtime/shims/xgameruntime_gamesave.cpp) logs only when the provider opens. Reads, updates, writes and submits make no log line, so "no save call" and "a save call failed" look the same in a log.

LEONIDA_TRACE_XGAMESAVE=1 makes every XGameSave* and XGameSaveFiles* slot log one [rt] xgamesave: line on stderr. Each line has the call, its handles, container and blob names, sizes and HRESULT, after t=<ms since the process started>ms tid=<thread>. An async call also logs these lines:

  • schedule: when begin() calls XAsyncSchedule.
  • run: when its work starts on the queue, with waited= for the time it sat there.
  • complete: with its HRESULT and how long the work took.
  • the ...Result call: when the title collects the result.

All of these lines name the title's XAsyncBlock, so one job's lines can be matched up (XAsync hands the provider a copy of the block, so the shim keeps the title's block pointer). A job stuck behind a stalled queue, or a result the title never collects, then shows in the log. Blob contents are never logged: a read logs its blob names and sizes only. Enumerations log how many containers or blobs they returned.

It is off by default. The variable is read once, and when it is off each call costs one relaxed load. Names are only looked up while tracing. The slot behaviour does not change. Where a slot had early returns, its body moved into a helper so that the wrapper can log the result.

The row is in runtime/README.md's xgameruntime table, and there is a paragraph under XGameSaveImpl in docs/runtime_imports.md.

Tested

  • xgameruntime_gamesave_test: a new block turns the trace on through a test hook (xgameruntime_gamesave_trace_for_test, which sends the lines to a callback instead of stderr). It creates a container and an update, writes a 300-byte blob, then:

    • submits it with SubmitUpdateAsync/Result;
    • reads it with ReadBlobData, then with ReadBlobDataAsync/Result;
    • closes the handles and deletes the container, all in a temporary LEONIDA_SAVE_DIR.

    It checks the line format, the names, sizes and HRESULTs, and that the schedule, run, complete and Result lines come in that order and name the title's block. It also checks that the blob's contents appear in no line and that a call logs nothing once the trace is off. 91 checks, 0 failures.

  • ctest -R ^xgameruntime: 8/8 pass (xgameruntime, _user, _gamesave, _store, _offline, _offline_hdr, _user_gamertag, _user_gamertag_long). No new warnings in the shim at /W4.

  • The 13 tests/test_docs_*.py pass. scripts/check_no_game_data.py passes on the four changed files.

  • Not yet run on retail. The runs from a fixed copy of the save folder described in the claim come next, as a finding.

GPUs tested: n/a (no GPU code); built and tested on Windows 11, MSVC.

AI-assisted: yes (Claude Code, Claude Opus 5.5)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: runtime only)

🤖 Generated with Claude Code

**@⁠OreoFR** on GitHub · 2026-11-27 03:28 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2432) `OreoFR:rt-xgamesave-trace` → `main` · +476 −50 · 4 files · 1 commits · merged 2026-11-27 10:48 UTC Claimed in the coordination issue as: [RT-XGAMESAVE-TRACE](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ### What and why "Couldn't autosave" still shows sometimes, and the logs cannot say whether a save call failed: the offline save shim (`runtime/shims/xgameruntime_gamesave.cpp`) logs only when the provider opens. Reads, updates, writes and submits make no log line, so "no save call" and "a save call failed" look the same in a log. `LEONIDA_TRACE_XGAMESAVE=1` makes every `XGameSave*` and `XGameSaveFiles*` slot log one `[rt] xgamesave:` line on stderr. Each line has the call, its handles, container and blob names, sizes and HRESULT, after `t=<ms since the process started>ms tid=<thread>`. An async call also logs these lines: - `schedule`: when `begin()` calls `XAsyncSchedule`. - `run`: when its work starts on the queue, with `waited=` for the time it sat there. - `complete`: with its HRESULT and how long the work took. - the `...Result` call: when the title collects the result. All of these lines name the title's `XAsyncBlock`, so one job's lines can be matched up (XAsync hands the provider a copy of the block, so the shim keeps the title's block pointer). A job stuck behind a stalled queue, or a result the title never collects, then shows in the log. Blob contents are never logged: a read logs its blob names and sizes only. Enumerations log how many containers or blobs they returned. It is off by default. The variable is read once, and when it is off each call costs one relaxed load. Names are only looked up while tracing. The slot behaviour does not change. Where a slot had early returns, its body moved into a helper so that the wrapper can log the result. The row is in `runtime/README.md`'s xgameruntime table, and there is a paragraph under `XGameSaveImpl` in `docs/runtime_imports.md`. ### Tested - `xgameruntime_gamesave_test`: a new block turns the trace on through a test hook (`xgameruntime_gamesave_trace_for_test`, which sends the lines to a callback instead of stderr). It creates a container and an update, writes a 300-byte blob, then: - submits it with `SubmitUpdateAsync`/`Result`; - reads it with `ReadBlobData`, then with `ReadBlobDataAsync`/`Result`; - closes the handles and deletes the container, all in a temporary `LEONIDA_SAVE_DIR`. It checks the line format, the names, sizes and HRESULTs, and that the schedule, run, complete and Result lines come in that order and name the title's block. It also checks that the blob's contents appear in no line and that a call logs nothing once the trace is off. 91 checks, 0 failures. - `ctest -R ^xgameruntime`: 8/8 pass (`xgameruntime`, `_user`, `_gamesave`, `_store`, `_offline`, `_offline_hdr`, `_user_gamertag`, `_user_gamertag_long`). No new warnings in the shim at `/W4`. - The 13 `tests/test_docs_*.py` pass. `scripts/check_no_game_data.py` passes on the four changed files. - Not yet run on retail. The runs from a fixed copy of the save folder described in the claim come next, as a finding. GPUs tested: n/a (no GPU code); built and tested on Windows 11, MSVC. AI-assisted: yes (Claude Code, Claude Opus 5.5) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: runtime only) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
With LEONIDA_TRACE_XGAMESAVE=1 the offline XGameSaveImpl logs one
"[rt] xgamesave:" line per XGameSave* and XGameSaveFiles* call: the call,
its handles, container and blob names, sizes and HRESULT, with the
milliseconds since the process started and the thread id. An async call
also logs when begin() schedules its job, when the work runs (and how
long it waited on the queue), when it completes and when the title
collects the result, all naming the title's XAsyncBlock. Blob contents
are never logged. Off by default: a call then pays one relaxed load.

xgameruntime_gamesave_test turns it on through a test hook, writes and
reads a blob (sync and async) and checks the lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 03:30:51 +00:00
Author
Owner

@⁠tiguan26 on GitHub · 2026-11-27 05:28 UTC · original · approved these changes

Approving. Checked on 2bf19e690, which fast-forwards onto main.

Built xgameruntime_gamesave_test (clang-cl, cross-built) and ran it under Wine: passes with the trace off, and with LEONIDA_TRACE_XGAMESAVE=1 (exit 0, including "no trace line holds blob contents"). The docs validators (test_docs_env_vars.py and the other doc tests) pass. I read the stderr output of a traced run as well: the sync calls, the enumerations' counts and sizes, the too-small-buffer reads (read=(none) hr=0x80830007) and the async jobs' schedule/run/complete/Result lines all match up by async=, with the work on another tid and waited= filled in. No contents anywhere, only names and sizes.

Read the diff. The places that could have gone wrong look right to me: the Begin and DoWork lines copy what they need before XAsyncSchedule/XAsyncComplete can free the job, container_label and update_label take the recursive mutex so calling them under it in CloseContainer is fine, and every *count/*out dereference in a trace line is behind SUCCEEDED(hr) or a null check.

One small thing, not a blocker: for an async call the call's own line (XGameSave...Async async=... hr=) is logged after XAsyncBegin returns, so it always comes after the schedule line and sometimes after run (in the traced test run, schedule then the call line then run). The doc says the async call "logs four more lines", which is true, but a reader matching lines in a stalled run might expect the call line first. A word in the doc, or logging the call line before XAsyncBegin, would settle it.

**@⁠tiguan26** on GitHub · 2026-11-27 05:28 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2432#pullrequestreview-6083865941) · **approved these changes** Approving. Checked on 2bf19e690, which fast-forwards onto main. Built `xgameruntime_gamesave_test` (clang-cl, cross-built) and ran it under Wine: passes with the trace off, and with `LEONIDA_TRACE_XGAMESAVE=1` (exit 0, including "no trace line holds blob contents"). The docs validators (`test_docs_env_vars.py` and the other doc tests) pass. I read the stderr output of a traced run as well: the sync calls, the enumerations' counts and sizes, the too-small-buffer reads (`read=(none) hr=0x80830007`) and the async jobs' schedule/run/complete/Result lines all match up by `async=`, with the work on another tid and `waited=` filled in. No contents anywhere, only names and sizes. Read the diff. The places that could have gone wrong look right to me: the Begin and DoWork lines copy what they need before `XAsyncSchedule`/`XAsyncComplete` can free the job, `container_label` and `update_label` take the recursive mutex so calling them under it in CloseContainer is fine, and every `*count`/`*out` dereference in a trace line is behind `SUCCEEDED(hr)` or a null check. One small thing, not a blocker: for an async call the call's own line (`XGameSave...Async async=... hr=`) is logged after `XAsyncBegin` returns, so it always comes after the `schedule` line and sometimes after `run` (in the traced test run, `schedule` then the call line then `run`). The doc says the async call "logs four more lines", which is true, but a reader matching lines in a stalled run might expect the call line first. A word in the doc, or logging the call line before `XAsyncBegin`, would settle it.
github-bot changed target branch from main to gh-pr/2432/base 2026-11-27 10:53:07 +00:00
github manually merged commit 2bf19e6908 into gh-pr/2432/base 2026-11-27 10:53:08 +00:00
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-27 10:48 UTC · original

Merging.

  • Why: a trace of the save calls, off by default.
  • Open nit, left for a follow-up: the call's own line is logged after schedule (from @⁠tiguan26's review).
  • Tested on main 2859d0c9b + #2418, #2440, #2432 and #2439, integrated RDNA2 GPU (RADV, Mesa 26.3.1):
    • Windows suite under Wine: 425 pass, 25 fail. The only changes against the stored baseline are xdxr_build_check (a timeout under load) and xmem_no_write_watch, both flaky here.
    • Linux runtime ctest: 115 of 116, the same timeout.
  • Not tested: no game run from this head.

Thanks @⁠OreoFR.

AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)

**@⁠aslan2142** on GitHub · 2026-11-27 10:48 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2432#issuecomment-7216322141) Merging. - **Why:** a trace of the save calls, off by default. - **Open nit, left for a follow-up:** the call's own line is logged after `schedule` (from @⁠tiguan26's review). - **Tested on `main` `2859d0c9b` + #2418, #2440, #2432 and #2439**, integrated RDNA2 GPU (RADV, Mesa 26.3.1): - Windows suite under Wine: 425 pass, 25 fail. The only changes against the stored baseline are `xdxr_build_check` (a timeout under load) and `xmem_no_write_watch`, both flaky here. - Linux runtime `ctest`: 115 of 116, the same timeout. - **Not tested:** no game run from this head. Thanks @⁠OreoFR. AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)
This discussion has been locked. Commenting is limited to contributors.
No description provided.