xgameruntime: LEONIDA_TRACE_XGAMESAVE logs every XGameSave call #2432
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!2432
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2432"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@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 UTCClaimed 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=1makes everyXGameSave*andXGameSaveFiles*slot log one[rt] xgamesave:line on stderr. Each line has the call, its handles, container and blob names, sizes and HRESULT, aftert=<ms since the process started>ms tid=<thread>. An async call also logs these lines:schedule: whenbegin()callsXAsyncSchedule.run: when its work starts on the queue, withwaited=for the time it sat there.complete: with its HRESULT and how long the work took....Resultcall: 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 underXGameSaveImplindocs/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:SubmitUpdateAsync/Result;ReadBlobData, then withReadBlobDataAsync/Result;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_*.pypass.scripts/check_no_game_data.pypasses 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
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: runtime only)🤖 Generated with Claude Code
@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 withLEONIDA_TRACE_XGAMESAVE=1(exit 0, including "no trace line holds blob contents"). The docs validators (test_docs_env_vars.pyand 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 byasync=, with the work on another tid andwaited=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/XAsyncCompletecan free the job,container_labelandupdate_labeltake the recursive mutex so calling them under it in CloseContainer is fine, and every*count/*outdereference in a trace line is behindSUCCEEDED(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 afterXAsyncBeginreturns, so it always comes after thescheduleline and sometimes afterrun(in the traced test run,schedulethen the call line thenrun). 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 beforeXAsyncBegin, would settle it.@aslan2142 on GitHub · 2026-11-27 10:48 UTC · original
Merging.
schedule(from @tiguan26's review).main2859d0c9b+ #2418, #2440, #2432 and #2439, integrated RDNA2 GPU (RADV, Mesa 26.3.1):xdxr_build_check(a timeout under load) andxmem_no_write_watch, both flaky here.ctest: 115 of 116, the same timeout.Thanks @OreoFR.
AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)