Skip to content

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

A bug report keeps how the run ended when its log is too long for the URL, the Steam library list is also read from config, and the README's engine id can't go stale.

Gauthier Piarrette1a5a088b4571
diff --git a/README.md b/README.md
index 69c09ed..8f45005 100644
--- a/README.md
+++ b/README.md
@@ -99,7 +99,7 @@ git clone https://github.com/gauthierpiarrette/highball && cd highball #
git clone https://github.com/gauthierpiarrette/highball-db ../highball-db # recipes + game database (CC0)
swift build -c release
.build/release/highball engine install spike/engine-manifest.json
-.build/release/highball engine accept x64-sikarugir10.0_6-r2 apple-gptk-license-2023-08-17 # optional: D3DMetal
+.build/release/highball engine accept <the id install printed> apple-gptk-license-2023-08-17 # optional: D3DMetal
.build/release/highball bottle create play --recipe steam
.build/release/highball run play Steam
```
diff --git a/Sources/HighballKit/Paths.swift b/Sources/HighballKit/Paths.swift
index 9993898..4603e8e 100644
--- a/Sources/HighballKit/Paths.swift
+++ b/Sources/HighballKit/Paths.swift
@@ -417,10 +417,10 @@ public enum BugReport {
/// launch header, the backend banner and the effective configuration; the tail carries how the
/// run ended. A plain `suffix` would drop exactly the head — the content this function exists
/// to preserve — and keep the MoltenVK spam, reinstating the failure it was written to fix.
- static func trim(_ lines: [String]) -> String {
+ static func trim(_ lines: [String], budget: Int = maxDigestCharacters) -> String {
let whole = lines.joined(separator: "\n")
- guard whole.count > maxDigestCharacters else { return whole }
- let headBudget = maxDigestCharacters * 2 / 3
+ guard whole.count > budget else { return whole }
+ let headBudget = budget * 2 / 3
var head: [String] = [], used = 0
for line in lines {
if used + line.count + 1 > headBudget, !head.isEmpty { break }
@@ -428,7 +428,7 @@ public enum BugReport {
}
var tail: [String] = [], tailUsed = 0
for line in lines[head.count...].reversed() {
- if used + tailUsed + line.count + 1 > maxDigestCharacters { break }
+ if used + tailUsed + line.count + 1 > budget { break }
tail.append(line); tailUsed += line.count + 1
}
let dropped = lines.count - head.count - tail.count
@@ -529,13 +529,22 @@ public enum BugReport {
]
return comps.url!
}
- // Shrink from the tail until the encoded URL fits: the head holds the launch header, the
- // backend banner and the effective configuration, which are what triage reads first.
+ // Shrink from the middle until the encoded URL fits, as `trim` does: the head holds the launch
+ // header and the configuration, the tail how the run ended. Cutting the tail here lost the
+ // crash from reports whose digest was long (highball#618, cut 50 repeats before the end).
var result = url(log: logDigest)
while result.absoluteString.count > maxURLCharacters, logDigest.count > 400 {
- logDigest = String(logDigest.prefix(logDigest.count * 3 / 4))
+ logDigest = shortened(logDigest)
result = url(log: logDigest)
}
return result
}
+
+ /// `text` at about three quarters of its length, both ends kept. Always shorter, so the caller's
+ /// loop ends: a text of a few long lines `trim` can't cut between loses its end instead.
+ static func shortened(_ text: String) -> String {
+ let budget = text.count * 3 / 4
+ let cut = trim(text.components(separatedBy: "\n"), budget: budget)
+ return cut.count < text.count ? cut : String(text.prefix(budget))
+ }
}
diff --git a/Sources/HighballKit/SteamLibrary.swift b/Sources/HighballKit/SteamLibrary.swift
index 1b10537..1e52f32 100644
--- a/Sources/HighballKit/SteamLibrary.swift
+++ b/Sources/HighballKit/SteamLibrary.swift
@@ -97,12 +97,14 @@ public enum SteamLibrary {
/// paths (`D:\SteamLibrary`), which the bottle's drive letters turn back into Mac paths; a
/// letter the bottle does not map, or a folder that is not there (an external disk left at
/// home), is skipped. Before this a game installed in a second library folder never reached
- /// the library at all (highball-db#316, a Steam library on /Volumes/MEDIA_DEV).
+ /// the library at all (highball-db#316, a Steam library on /Volumes/MEDIA_DEV). Steam keeps the
+ /// list in `config` too, the only copy left where `steamapps` itself can't be read, such as a
+ /// Finder alias left in its place (highball#603).
static func libraryFolders(steamRoot root: URL, bottleURL: URL) -> [URL] {
var folders = [root.standardizedFileURL]
- let vdf = root.appending(path: "steamapps/libraryfolders.vdf")
- guard let text = try? String(contentsOf: vdf, encoding: .utf8) else { return folders }
- for path in libraryPaths(in: text) {
+ let lists = ["steamapps/libraryfolders.vdf", "config/libraryfolders.vdf"]
+ .compactMap { try? String(contentsOf: root.appending(path: $0), encoding: .utf8) }
+ for path in lists.flatMap(libraryPaths(in:)) {
guard let url = unixURL(windowsPath: path, bottleURL: bottleURL)?.standardizedFileURL,
!folders.contains(url),
FileManager.default.fileExists(atPath: url.appending(path: "steamapps").path) else { continue }
diff --git a/Sources/highball/main.swift b/Sources/highball/main.swift
index 74ea1d4..79f3163 100644
--- a/Sources/highball/main.swift
+++ b/Sources/highball/main.swift
@@ -28,7 +28,10 @@ struct Engine: AsyncParsableCommand {
@Argument var license: String
func run() async throws {
let store = EngineStore()
- let e = try store.accept(license: license, engine: store.engine(engine))
+ guard let installed = try? store.engine(engine) else {
+ fail("engine '\(engine)' is not installed; `highball engine list` shows the ids")
+ }
+ let e = try store.accept(license: license, engine: installed)
print("accepted \(license) for \(e.id); renderers now: \(HighballKit.Renderer.allCases.filter { $0 == .wined3d || e.rendererDir($0.rawValue) != nil }.map(\.rawValue).joined(separator: ","))")
}
}
diff --git a/Tests/HighballKitTests/RegressionTests.swift b/Tests/HighballKitTests/RegressionTests.swift
index 2605d6c..464fa86 100644
--- a/Tests/HighballKitTests/RegressionTests.swift
+++ b/Tests/HighballKitTests/RegressionTests.swift
@@ -1117,6 +1117,17 @@ extension RegressionTests {
// Forza Horizon 6's second route: an environment on the route's line goes by the route, every other by the recipe,
// under one id, so what an environment records for the game stays in one place.
+ /// highball#618: a long digest lost its end to the URL limit, and the end is the crash.
+ func testAReportTooLongForItsURLKeepsBothEnds() throws {
+ let lines = ["# gin engine header"] + (0..<400).map { "0123:err:ole:class \($0) not registered, padded out to make the digest long" } + ["unhandled exception at the very end"]
+ var text = lines.joined(separator: "\n")
+ while text.count > 1500 { text = BugReport.shortened(text) }
+ XCTAssertTrue(text.contains("# gin engine header"))
+ XCTAssertTrue(text.contains("unhandled exception at the very end"))
+ let few = String(repeating: "x", count: 4000)
+ XCTAssertLessThan(BugReport.shortened(few).count, few.count, "a text it can't cut between lines still gets shorter")
+ }
+
func testPreviewRouteAppliesOnlyOnItsOwnLine() throws {
let json = #"""
{"id":"game","kind":"game","title":"Game","renderer":"d3dmetal","engine":"x64-a-r18","minMemoryGB":null,
diff --git a/Tests/HighballKitTests/SteamLibraryFoldersTests.swift b/Tests/HighballKitTests/SteamLibraryFoldersTests.swift
index fec03cf..811e48a 100644
--- a/Tests/HighballKitTests/SteamLibraryFoldersTests.swift
+++ b/Tests/HighballKitTests/SteamLibraryFoldersTests.swift
@@ -65,6 +65,21 @@ final class SteamLibraryFoldersTests: XCTestCase {
external.appending(path: "steamapps/common/BloodySpell").standardizedFileURL.path)
}
+ func testTheLibraryListInConfigIsReadWhenSteamappsCantBe() throws {
+ // highball#603: a Finder alias named steamapps is a file, so the list inside it can't be read.
+ let bottle = tmp.appending(path: "alias-bottle", directoryHint: .isDirectory)
+ let steam = bottle.appending(path: "drive_c/Program Files (x86)/Steam", directoryHint: .isDirectory)
+ let external = tmp.appending(path: "alias-external/SteamLibrary", directoryHint: .isDirectory)
+ try FileManager.default.createDirectory(at: steam.appending(path: "config"), withIntermediateDirectories: true)
+ try FileManager.default.createDirectory(at: external.appending(path: "steamapps"), withIntermediateDirectories: true)
+ try FileManager.default.createDirectory(at: bottle.appending(path: "dosdevices"), withIntermediateDirectories: true)
+ try FileManager.default.createSymbolicLink(at: bottle.appending(path: "dosdevices/d:"), withDestinationURL: external.deletingLastPathComponent())
+ try Data("alias".utf8).write(to: steam.appending(path: "steamapps"))
+ try Data(#""libraryfolders" { "1" { "path" "D:\\\\SteamLibrary" } }"#.utf8).write(to: steam.appending(path: "config/libraryfolders.vdf"))
+ let folders = SteamLibrary.libraryFolders(steamRoot: steam, bottleURL: bottle)
+ XCTAssertEqual(folders.map(\.standardizedFileURL.path).last, external.standardizedFileURL.path)
+ }
+
func testASymlinkedSteamappsFolderIsRead() throws {
// highball-db#316: steamapps moved to an external disk with a symlink left in its place.
let bottle = tmp.appending(path: "bottle", directoryHint: .isDirectory)