Play Windows games on Apple Silicon Macs. Free, open-source app that installs the official Battle.net, Steam, Epic and GOG launchers and lists your games in one library.
HTML apple-siliconbattle-netcrossover-alternatived3dmetaldiablo-ii-resurrecteddxmtea-appepic-gamesgame-porting-toolkitgogmac-gamingmacosmacos-gamingrockstar-gamessteamubisoft-connectwhisky-alternativewindows-gameswinewine-wrapper
Play stats: a Blizzard game's own crash report says why it closed (#204)
Mikek3e44c4a248b1
diff --git a/scripts/play-stats.py b/scripts/play-stats.pyindex 9b4e4d01ecc..2978cbb8090 100755--- a/scripts/play-stats.py+++ b/scripts/play-stats.py@@ -244,6 +244,31 @@ def launcher_state(launcher, table=None):return "launcher_open" if exe in text else "launcher_closed"+def blizzard_crash(path, since):+ """(word, name) from the crash report a Blizzard game writes itself (errors/<time>/Crash.txt in its+ folder) when it caught its own crash: the exception and the module it happened in, nothing else.+ Wine says nothing then, because the game handles the crash and only its reporter runs."""+ try:+ root = Path(path) / "errors"+ reports = [d for d in root.iterdir() if d.is_dir() and d.stat().st_mtime >= since - 5]+ except (OSError, TypeError):+ return "", ""+ for d in sorted(reports, key=lambda d: d.stat().st_mtime, reverse=True):+ try:+ text = (d / "Crash.txt").read_text(encoding="utf-8", errors="replace")+ except OSError:+ continue+ m = re.search(r"<BlizzardError\.Summary:>\s*([A-Z][A-Z0-9_]+)", text)+ if not m:+ continue+ # The first module on the stack that is not Windows' own (kernelbase raises most exceptions).+ modules = [x for x in re.findall(r'DBG-ADDR<[0-9A-Fa-f]+>\("([^"]+)"\)', text)+ if x.lower() not in ("kernelbase.dll", "ntdll.dll", "kernel32.dll", "ucrtbase.dll", "msvcrt.dll")]+ name = m.group(1) + ("+" + modules[0] if modules else "")+ return "crash", SAFE.sub("_", name)[:40]+ return "", ""++def reason(started, minutes, marks, found, path, launcher="", game=""):"""What to add to a start that did not run; nothing for one that ran."""if outcome(started, minutes) == "ran":@@ -272,6 +297,11 @@ def reason(started, minutes, marks, found, path, launcher="", game=""):# Battle.net started it and the game was never seen: what Wine said, if anything, goes along.if word == "bnet_launched":name = "_".join(x for x in why(text, found) if x)[:40]+ if launcher == "battlenet" and isinstance(marks, dict) and marks.get("_t"):+ # The game caught its own crash and wrote a report: that says more than anything above.+ crash = blizzard_crash(path, marks["_t"])+ if crash[0]:+ word, name = crashif not word:word, name = why(text, found)if not word and not started:diff --git a/tests/test_play_stats.py b/tests/test_play_stats.pyindex d9046a9a545..54563de0d9f 100644--- a/tests/test_play_stats.py+++ b/tests/test_play_stats.py@@ -249,3 +249,22 @@ class PlayStats(unittest.TestCase):if __name__ == '__main__':unittest.main()+++class BlizzardCrashTests(unittest.TestCase):+ def test_reads_the_crash_report_the_game_wrote(self):+ import tempfile, time+ from pathlib import Path+ with tempfile.TemporaryDirectory() as d:+ report = Path(d) / "errors/2026-11-25 09.00.00 abcd1234"+ report.mkdir(parents=True)+ (report / "Crash.txt").write_text(+ "<BlizzardError.ProjectId>4\r\n<BlizzardError.Summary:>\r\n"+ "ACCESS_VIOLATION (Failed to write address 0x00006FFFFF9F0F00 at instruction 0x00006FFFFF3D7455)\r\n"+ "<:BlizzardError.Summary>\r\n<BlizzardError.Assertion:>\r\nThread 0x24 \"Main Thread\"\r\n"+ 'DBG-ADDR<00006FFFFF3D7455>("kernelbase.dll")\r\nDBG-ADDR<00006FFFF9E87BCF>("D3DMetal.dll")\r\n')+ self.assertEqual(ps.blizzard_crash(d, time.time() - 60), ("crash", "ACCESS_VIOLATION+D3DMetal.dll"))+ self.assertEqual(ps.blizzard_crash(d, time.time() + 3600), ("", "")) # older than this start+ self.assertEqual(ps.blizzard_crash(Path(d) / "missing", 0), ("", ""))+ (report / "Crash.txt").write_text("") # an empty report says nothing+ self.assertEqual(ps.blizzard_crash(d, 0), ("", ""))