Skip to content

Run Windows games on Apple Silicon — free, open source, with an open compatibility database that tells you what actually works.

Report samples a frozen game's stack automatically (#21)

Gauthier Piarrette9293785420f9
diff --git a/Sources/HighballKit/Paths.swift b/Sources/HighballKit/Paths.swift
index f10bea1..8626a31 100644
--- a/Sources/HighballKit/Paths.swift
+++ b/Sources/HighballKit/Paths.swift
@@ -96,6 +96,53 @@ public enum BugReport {
static let maxHeadBytes = 1 << 20
static let maxTailBytes = 256 << 10
+ /// Wine infrastructure and launcher processes that are never the frozen game. Anything
+ /// else running from a bottle's drive_c with an .exe suffix is a candidate.
+ static let infraExes: Set<String> = [
+ "steam.exe", "steamwebhelper.exe", "steamservice.exe", "steamerrorreporter.exe",
+ "services.exe", "svchost.exe", "winedevice.exe", "plugplay.exe", "rpcss.exe",
+ "explorer.exe", "wineboot.exe", "conhost.exe", "rundll32.exe", "reg.exe",
+ "gameoverlayui.exe", "gameoverlayui64.exe", "x86launcher.exe", "cmd.exe",
+ "epicgameslauncher.exe", "epicwebhelper.exe", "unrealcefsubprocess.exe",
+ ]
+
+ /// Parses `ps -Ao pid=,command=` output into candidate game processes: anything running
+ /// out of a bottle's drive_c that isn't wine plumbing or a launcher. Pure for testability.
+ public static func gameProcesses(fromPS ps: String) -> [(pid: Int32, exe: String)] {
+ var out: [(Int32, String)] = []
+ for line in ps.split(separator: "\n") {
+ let trimmed = line.trimmingCharacters(in: .whitespaces)
+ guard let sp = trimmed.firstIndex(of: " "), let pid = Int32(trimmed[..<sp]) else { continue }
+ let command = String(trimmed[trimmed.index(after: sp)...])
+ guard command.contains("/drive_c/") else { continue }
+ // The executable path ends at ".exe"; what follows are the game's own arguments.
+ guard let range = command.range(of: ".exe", options: [.caseInsensitive]) else { continue }
+ let exePath = String(command[..<range.upperBound])
+ let exe = (exePath as NSString).lastPathComponent.lowercased()
+ guard !infraExes.contains(exe) else { continue }
+ out.append((pid, exe))
+ }
+ return out
+ }
+
+ /// The issue #21 lesson, made permanent: a frozen game produces no crash, no exit and no
+ /// fresh log lines, so a report filed DURING the freeze used to contain nothing at all —
+ /// five diagnostic rounds to learn where one stack trace would have answered it. Now the
+ /// report button samples any live game process (macOS `sample`, 5 s) into the logs
+ /// directory, and the digest names the file so the user attaches it.
+ static func sampleRunningGames(paths: HighballPaths) -> [String] {
+ guard let ps = try? Shell.capture("/bin/ps", ["-Ao", "pid=,command="]) else { return [] }
+ var written: [String] = []
+ for (pid, exe) in gameProcesses(fromPS: ps).prefix(2) {
+ let stamp = ISO8601DateFormatter().string(from: Date()).replacingOccurrences(of: ":", with: "")
+ let file = paths.logs.appending(path: "\(stamp)-sample-\(exe).txt")
+ if (try? Shell.run("/usr/bin/sample", [String(pid), "5", "-f", file.path])) != nil {
+ written.append(file.lastPathComponent)
+ }
+ }
+ return written
+ }
+
/// Where a launch can leave a log: Highball's own directory, plus the per-process files DXVK
/// writes inside each bottle (DXVK_LOG_PATH, set in `Bottle.environment`). The DXVK files
/// matter because they survive the one case Highball cannot otherwise observe — a game
@@ -280,15 +327,23 @@ public enum BugReport {
return fallback ?? bootFallback
}
- public static func url(version: String, paths: HighballPaths = HighballPaths()) -> URL {
+ /// `samplingLiveGames: false` skips the live-process sample (tests; callers that must not
+ /// block for the ~5 s a sample takes).
+ public static func url(version: String, paths: HighballPaths = HighballPaths(), samplingLiveGames: Bool = true) -> URL {
let chip = (try? Shell.capture("/usr/sbin/sysctl", ["-n", "machdep.cpu.brand_string"]))?
.trimmingCharacters(in: .whitespacesAndNewlines) ?? "unknown chip"
let macos = (try? Shell.capture("/usr/bin/sw_vers", ["-productVersion"]))?
.trimmingCharacters(in: .whitespacesAndNewlines) ?? "?"
var logDigest = ""
+ // A game frozen right now is the one moment its stack is capturable — grab it first.
+ let samples = samplingLiveGames ? sampleRunningGames(paths: paths) : []
+ if !samples.isEmpty {
+ logDigest += "Live game sampled during this report — PLEASE ATTACH from ~/Library/Application Support/Highball/logs/:\n"
+ + samples.map { " \($0)" }.joined(separator: "\n") + "\n\n"
+ }
if let found = mostInformativeLog(in: logDirectories(paths)) {
// Name the full file too: the digest is a summary, and triage may want the original.
- logDigest = "\(redactHome(found.url.path)):\n\(digest(found.text))"
+ logDigest += "\(redactHome(found.url.path)):\n\(digest(found.text))"
}
func url(log: String) -> URL {
var comps = URLComponents(string: "https://github.com/gauthierpiarrette/highball/issues/new")!
diff --git a/Tests/HighballKitTests/RegressionTests.swift b/Tests/HighballKitTests/RegressionTests.swift
index 5d8ed07..bab8224 100644
--- a/Tests/HighballKitTests/RegressionTests.swift
+++ b/Tests/HighballKitTests/RegressionTests.swift
@@ -208,7 +208,7 @@ extension RegressionTests {
ofItemAtPath: game.path)
try FileManager.default.setAttributes([.modificationDate: Date()], ofItemAtPath: boot.path)
- let body = BugReport.url(version: "0.7.17", paths: paths).absoluteString.removingPercentEncoding ?? ""
+ let body = BugReport.url(version: "0.7.17", paths: paths, samplingLiveGames: false).absoluteString.removingPercentEncoding ?? ""
XCTAssertTrue(body.contains("DXVK-Kegworks"), "the game's own output must be attached")
XCTAssertFalse(body.contains("wineboot -u"), "a prefix-boot log must never win over a real log")
}
@@ -226,7 +226,7 @@ extension RegressionTests {
.write(to: paths.logs.appending(path: "2026-08-29T211442Z-CS-wineboot.log"),
atomically: true, encoding: .utf8)
- let body = BugReport.url(version: "0.7.17", paths: paths).absoluteString.removingPercentEncoding ?? ""
+ let body = BugReport.url(version: "0.7.17", paths: paths, samplingLiveGames: false).absoluteString.removingPercentEncoding ?? ""
XCTAssertTrue(body.contains("wineboot -u"), "with nothing else on disk it is still the best evidence")
}
@@ -331,7 +331,7 @@ extension RegressionTests {
.write(to: paths.logs.appending(path: "2026-08-30T000000Z-b-steam.exe.log"),
atomically: true, encoding: .utf8)
- let url = BugReport.url(version: "0.7.17", paths: paths)
+ let url = BugReport.url(version: "0.7.17", paths: paths, samplingLiveGames: false)
XCTAssertLessThanOrEqual(url.absoluteString.count, BugReport.maxURLCharacters)
XCTAssertTrue(url.absoluteString.contains("template=bug.yml"))
}
@@ -367,6 +367,49 @@ extension RegressionTests {
}
}
+extension RegressionTests {
+ // Issue #21 cost five diagnostic rounds because a frozen game leaves no evidence: no crash,
+ // no exit, no fresh log lines. The report flow now samples live game processes. The parser
+ // must find the game and never the wine plumbing or launchers around it.
+ func testGameProcessParserFindsTheGameNotThePlumbing() {
+ let ps = """
+ 312 /Users/u/Library/Application Support/Highball/bottles/B/drive_c/Program Files (x86)/Steam/steam.exe -silent
+ 410 /Users/u/Library/Application Support/Highball/bottles/B/drive_c/Program Files (x86)/Steam/steamapps/common/csgo legacy/csgo.exe -steam -novid
+ 411 C:\\windows\\system32\\winedevice.exe
+ 500 /Users/u/Library/Application Support/Highball/bottles/B/drive_c/windows/system32/rundll32.exe d3d9.dll,Direct3DCreate9
+ 600 /Users/u/.build/debug/highball run B something
+ 700 /bin/zsh -c grep csgo.exe somewhere
+ 801 /Users/u/Library/Application Support/Highball/bottles/B/drive_c/Games/Some Game/Game.exe -windowed
+ """
+ let found = BugReport.gameProcesses(fromPS: ps)
+ XCTAssertEqual(found.map(\.pid), [410, 801])
+ XCTAssertEqual(found.map(\.exe), ["csgo.exe", "game.exe"])
+ }
+
+ // Launch args are DATA (db), and a workaround gated to one macOS must not leak onto
+ // versions where the game already works (#21: windowed only on macOS 26+).
+ func testLaunchArgsRespectTheOSGate() throws {
+ let json = """
+ {"id":"csgo-legacy","title":"CS:GO Legacy","steam_appid":4465480,"status":"community",
+ "launchArgs":["-windowed","-noborder"],"launchArgsMinMacOS":"26.0"}
+ """
+ let entry = try JSONDecoder().decode(GameDBEntry.self, from: Data(json.utf8))
+ XCTAssertEqual(entry.effectiveLaunchArgs(osMajor: 26), ["-windowed", "-noborder"])
+ XCTAssertEqual(entry.effectiveLaunchArgs(osMajor: 27), ["-windowed", "-noborder"])
+ XCTAssertEqual(entry.effectiveLaunchArgs(osMajor: 14), [], "must not change working setups")
+
+ // Ungated args apply everywhere; absent args apply nowhere.
+ let ungated = try JSONDecoder().decode(GameDBEntry.self, from: Data("""
+ {"id":"x","title":"X","steam_appid":1,"status":"community","launchArgs":["-novid"]}
+ """.utf8))
+ XCTAssertEqual(ungated.effectiveLaunchArgs(osMajor: 14), ["-novid"])
+ let none = try JSONDecoder().decode(GameDBEntry.self, from: Data("""
+ {"id":"y","title":"Y","steam_appid":2,"status":"community"}
+ """.utf8))
+ XCTAssertEqual(none.effectiveLaunchArgs(osMajor: 26), [])
+ }
+}
+
extension RegressionTests {
// Reproduced on this machine 2026-08-30: legacy CS:GO on a bottle using the DEFAULT renderer
// (dxmt) died with "Your graphics hardware does not support all features (CSM)". Neither the