From d27560cf45aac5e6cfb90969159fc643a3784b71 Mon Sep 17 00:00:00 2001 From: sydney-0o <215686885+sydney-0o@users.noreply.github.com> Date: Tue, 24 Nov 2026 16:59:48 +0500 Subject: [PATCH 1/2] tooling: report frame heartbeats without guessing draw status --- .github/workflows/windows.yml | 1 + AGENTS.md | 1 + tests/startup_live_view_check.py | 34 ++++++++++++++++++++++++++++++++ tools/startup/live_view.py | 5 +++-- 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 tests/startup_live_view_check.py diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index b73d82490e..cb04139fca 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -111,6 +111,7 @@ jobs: python -B tests/startup_image_load_mip_check.py python -B tests/startup_image_2d_array_check.py python -B tests/startup_host_cpu_check.py + python -B tests/startup_live_view_check.py python -B tests/startup_translator_check.py python -B tests/startup_flat_param_check.py python -B tests/startup_inline_sampler_check.py diff --git a/AGENTS.md b/AGENTS.md index 8123a2110f..85d31089b8 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -145,6 +145,7 @@ python3 -m venv out/pe-env ./out/pe-env/bin/python -B tests/startup_image_load_mip_check.py ./out/pe-env/bin/python -B tests/startup_image_2d_array_check.py ./out/pe-env/bin/python -B tests/startup_host_cpu_check.py +./out/pe-env/bin/python -B tests/startup_live_view_check.py ./out/pe-env/bin/python -B tests/startup_translator_check.py ./out/pe-env/bin/python -B tests/startup_flat_param_check.py ./out/pe-env/bin/python -B tests/startup_inline_sampler_check.py diff --git a/tests/startup_live_view_check.py b/tests/startup_live_view_check.py new file mode 100644 index 0000000000..0317788c95 --- /dev/null +++ b/tests/startup_live_view_check.py @@ -0,0 +1,34 @@ +"""Check that the live viewer reports only what a frame heartbeat establishes.""" + +import contextlib +import io +from pathlib import Path +import runpy +import sys +import tempfile +import unittest +from unittest import mock + + +class LiveViewCheck(unittest.TestCase): + def test_frame_heartbeat_does_not_claim_draws_were_dropped(self): + viewer = Path(__file__).resolve().parents[1] / "tools" / "startup" / "live_view.py" + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + (root / "trap.log").write_text( + "x2w-d3d12 heartbeat: 60 frames presented in 2.0 s (30.0 fps overall)\n", + encoding="utf-8", + ) + (root / "finished.txt").write_text("finished\n", encoding="utf-8") + output = io.StringIO() + with mock.patch.object(sys, "argv", [str(viewer), directory]), \ + mock.patch("os.system"), mock.patch("time.sleep"), \ + contextlib.redirect_stdout(output): + runpy.run_path(str(viewer), run_name="__main__") + + self.assertIn("60 frames presented, 30.0 fps", output.getvalue()) + self.assertNotIn("every draw dropped", output.getvalue()) + + +if __name__ == "__main__": + unittest.main() diff --git a/tools/startup/live_view.py b/tools/startup/live_view.py index eef06ef426..231780fef9 100644 --- a/tools/startup/live_view.py +++ b/tools/startup/live_view.py @@ -92,7 +92,7 @@ def on_shim(line): m = re.search(r"heartbeat: (\d+) frames presented in ([\d.]+) s \(([\d.]+) fps", line) if m: frames = m.group(1) - say("frames", f"{m.group(1)} frames presented, {m.group(3)} fps (every draw dropped: no GPU translation yet)") + say("frames", f"{m.group(1)} frames presented, {m.group(3)} fps") elif "title main state" in line: m = re.search(r"state (-?\d+) -> (-?\d+)", line) if m: @@ -157,7 +157,8 @@ def on_shim(line): time.sleep(0.25) print("-" * 110) try: - print(open(finished, encoding="utf-8", errors="replace").read().strip()) + with open(finished, encoding="utf-8", errors="replace") as handle: + print(handle.read().strip()) except OSError: pass print("\nRun ended. Full logs are in " + os.path.abspath(rundir) + " (events.txt, files.txt, trap.log).") From 941510be1a4520c22215e396a09331f2fea3fb70 Mon Sep 17 00:00:00 2001 From: sydney-0o <215686885+sydney-0o@users.noreply.github.com> Date: Tue, 24 Nov 2026 17:17:11 +0500 Subject: [PATCH 2/2] tooling: show startup storage and render summaries --- docs/startup-runtime.md | 8 +++++ tests/startup_live_view_check.py | 51 +++++++++++++++++++++++++------- tools/startup/live_view.py | 9 +++++- 3 files changed, 57 insertions(+), 11 deletions(-) diff --git a/docs/startup-runtime.md b/docs/startup-runtime.md index 9ff8d97c16..1bfb15b321 100644 --- a/docs/startup-runtime.md +++ b/docs/startup-runtime.md @@ -588,6 +588,14 @@ write) until its grant is released; `xmem.dll` publishes that count through the `x2w_xmem_page_stats` export. The heartbeat also prints while the request counters are unchanged when either memory value changed, so the cost of a stalled load is visible. +The live log window also shows DirectStorage heartbeat lines and `x2w-render totals` as they +arrive. It reports frame counts and FPS from the graphics heartbeat without inferring whether +draws were executed. Network refusals are shown when observed; the window does not establish +that all network activity is blocked. To check this presentation with generated logs, run +`python -B tests/startup_live_view_check.py`. See [#1199](https://github.com/R0Y00/Xbox2Windows/issues/1199) +for memory accounting and [#1281](https://github.com/R0Y00/Xbox2Windows/issues/1281) for +the launcher's concurrent-hook limitation. + ```powershell cmake --build --preset release --target xmem_shim startup_stub_xcrdapi ctest --preset release --no-tests=error -R '^(xmem_page_stats|startup_heartbeat_commit)$' -V diff --git a/tests/startup_live_view_check.py b/tests/startup_live_view_check.py index 0317788c95..7f42258525 100644 --- a/tests/startup_live_view_check.py +++ b/tests/startup_live_view_check.py @@ -1,4 +1,4 @@ -"""Check that the live viewer reports only what a frame heartbeat establishes.""" +"""Check the live viewer with generated startup log lines.""" import contextlib import io @@ -11,23 +11,54 @@ class LiveViewCheck(unittest.TestCase): - def test_frame_heartbeat_does_not_claim_draws_were_dropped(self): + def view_log(self, first_chunk, second_chunk=None): viewer = Path(__file__).resolve().parents[1] / "tools" / "startup" / "live_view.py" with tempfile.TemporaryDirectory() as directory: root = Path(directory) - (root / "trap.log").write_text( - "x2w-d3d12 heartbeat: 60 frames presented in 2.0 s (30.0 fps overall)\n", - encoding="utf-8", - ) - (root / "finished.txt").write_text("finished\n", encoding="utf-8") + log = root / "trap.log" + log.write_text(first_chunk, encoding="utf-8") + finished = root / "finished.txt" + + def finish_run(_seconds): + if not finished.exists(): + if second_chunk is not None: + with log.open("a", encoding="utf-8", newline="\n") as handle: + handle.write(second_chunk) + finished.write_text("finished\n", encoding="utf-8") + + if second_chunk is None: + finish_run(0) output = io.StringIO() with mock.patch.object(sys, "argv", [str(viewer), directory]), \ - mock.patch("os.system"), mock.patch("time.sleep"), \ + mock.patch("os.system"), mock.patch("time.sleep", side_effect=finish_run), \ contextlib.redirect_stdout(output): runpy.run_path(str(viewer), run_name="__main__") + return output.getvalue() + + def test_frame_heartbeat_does_not_claim_draws_were_dropped(self): + output = self.view_log("x2w-d3d12 heartbeat: 60 frames presented in 2.0 s (30.0 fps overall)\n") + self.assertIn("60 frames presented, 30.0 fps", output) + self.assertNotIn("every draw dropped", output) + self.assertNotIn("game runs offline", output) + + def test_storage_and_render_totals_are_preserved(self): + storage = ("x2w-dstorage heartbeat 10 s: requests done=12 inflated=7 failed=2 bcpack-blank=1; " + "page tokens 0 at enqueue=3, still 0 at run=1; commit peak=900 MiB current=800 MiB, " + "live physical-page sections=42") + render = ("x2w-render totals: resets 2 (failed 0), closes 2, clears 1, executes 2, " + "draws 4 (skipped 1), translated draws 3 (not drawn 2), pipelines translated 4 / missing 1, " + "null bindings 5 (entry 1, buffer 1, token 1, wrapper 1, dimension 1), " + "textures uploaded 2 (16 KiB, unreadable 1)") + output = self.view_log(storage + "\n" + render + "\n") + self.assertIn(storage, output) + self.assertIn(render, output) + self.assertIn("7 chunks decompressed", output) - self.assertIn("60 frames presented, 30.0 fps", output.getvalue()) - self.assertNotIn("every draw dropped", output.getvalue()) + def test_unknown_and_split_heartbeat(self): + first = "x2w-dstorage heartbeat 20 s: requests done=0 inflated=0 failed=0 bcpack-blank=0; " + second = "page tokens 0 at enqueue=0, still 0 at run=0; commit unknown, live physical-page sections=unknown\n" + output = self.view_log(first, second) + self.assertEqual(output.count(first + second.strip()), 1) if __name__ == "__main__": diff --git a/tools/startup/live_view.py b/tools/startup/live_view.py index 231780fef9..026ef2758c 100644 --- a/tools/startup/live_view.py +++ b/tools/startup/live_view.py @@ -88,6 +88,13 @@ def on_shim(line): say("storage", f"read batch complete: {m.group(1)} compressed chunks decompressed so far, {m.group(2)} failed") elif "EnqueueRequest" in line or "options=" in line or "Queue::Submit" in line or "IsComplete" in line: return + elif line.startswith("x2w-dstorage heartbeat "): + m = re.search(r"\binflated=(\d+)", line) + if m: + counts["chunks"] = int(m.group(1)) + say("storage", line) + elif line.startswith("x2w-render totals:"): + say("render", line) elif "heartbeat" in line: m = re.search(r"heartbeat: (\d+) frames presented in ([\d.]+) s \(([\d.]+) fps", line) if m: @@ -119,7 +126,7 @@ def on_shim(line): positions = {name: 0 for name in sources} partial = {name: "" for name in sources} print("Xbox2Windows local startup experiment: live log of " + os.path.abspath(rundir)) -print("Columns: time since this window opened, category, detail. The game runs offline (network opens are refused).") +print("Columns: time since this window opened, category, detail. Network refusals are shown when observed.") print("-" * 110, flush=True) finished = os.path.join(rundir, "finished.txt") ended = False