Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit
Swift apple-silicond3dmetaldxmtdxvkgame-porting-toolkitgptkmac-gamingmacosmetalfxrosetta-2steamsteam-playwinewinecx
feat(report): ask what went wrong, and send the Mac's model, thermal state, power and Retina mode
raymondchinsce273c112620
diff --git a/app/Sources/BridgeplayApp/Model/GameReport.swift b/app/Sources/BridgeplayApp/Model/GameReport.swiftindex f870e3f..a54f61d 100644--- a/app/Sources/BridgeplayApp/Model/GameReport.swift+++ b/app/Sources/BridgeplayApp/Model/GameReport.swift@@ -1,4 +1,5 @@import AppKit+import IOKit.psimport SystemConfiguration// What a compatibility report says about this Mac and the game's last launch, and the@@ -18,6 +19,7 @@ enum GameReport {var memoryBytes: UInt64var macOS: Stringvar bridgeplay: String+ var model: String? = nilvar setup: [String: String] = [:]// A newer release the updater found, "0.7.38 (55)".var newerRelease: String?@@ -27,11 +29,21 @@ enum GameReport {Machine(chip: SetupChecks.chipName, memoryBytes: ProcessInfo.processInfo.physicalMemory,macOS: SetupChecks.macOSDisplay,bridgeplay: ProductVersion.build.map { "\(ProductVersion.short) (\($0))" } ?? ProductVersion.short,+ model: sysctl("hw.model"),newerRelease: LatestRelease.newer(than: ProductVersion.build))}+ private static func sysctl(_ name: String) -> String? {+ var size = 0+ guard sysctlbyname(name, nil, &size, nil, 0) == 0, size > 0 else { return nil }+ var value = [CChar](repeating: 0, count: size)+ guard sysctlbyname(name, &value, &size, nil, 0) == 0 else { return nil }+ return String(cString: value)+ }+// Facts about the Mac when the report is made, which is soon after the game ran:- // displays: "2: built-in 3456x2234 120 Hz, 2560x1440 60 Hz", lowPower: "on"/"off".+ // displays: "2: built-in 3456x2234 120 Hz, 2560x1440 60 Hz", lowPower: "on"/"off",+ // thermal: "nominal"…"critical", power: "battery"/"plugged in", gpuCores: "16".@MainActor static func setup() -> [String: String] {let screens = NSScreen.screens.map { screen -> String inlet pixels = screen.convertRectToBacking(screen.frame).size@@ -41,9 +53,39 @@ enum GameReport {}var setup = ["lowPower": ProcessInfo.processInfo.isLowPowerModeEnabled ? "on" : "off"]if !screens.isEmpty { setup["displays"] = "\(screens.count): " + screens.joined(separator: ", ") }+ setup["thermal"] = switch ProcessInfo.processInfo.thermalState {+ case .nominal: "nominal"+ case .fair: "fair"+ case .serious: "serious"+ case .critical: "critical"+ @unknown default: "unknown"+ }+ if let info = IOPSCopyPowerSourcesInfo()?.takeRetainedValue(),+ let type = IOPSGetProvidingPowerSourceType(info)?.takeUnretainedValue() as String? {+ setup["power"] = type == kIOPSBatteryPowerValue ? "battery" : "plugged in"+ }+ let gpu = IOServiceGetMatchingService(kIOMainPortDefault, IOServiceMatching("AGXAccelerator"))+ if gpu != 0 {+ defer { IOObjectRelease(gpu) }+ if let cores = IORegistryEntryCreateCFProperty(gpu, "gpu-core-count" as CFString, kCFAllocatorDefault, 0)?+ .takeRetainedValue() as? Int {+ setup["gpuCores"] = String(cores)+ }+ }return setup}+ // Whether the game's prefix runs in Retina mode, so a game can render at the display's full+ // pixel size (displays) instead of half: the biggest resolution factor behind a low frame rate.+ static func retina(_ userReg: String) -> String {+ var inDriver = false+ for line in userReg.split(whereSeparator: \.isNewline) {+ if line.hasPrefix("[") { inDriver = line.hasPrefix(#"[Software\\Wine\\Mac Driver]"#) }+ else if inDriver, line.hasPrefix(#""RetinaMode"="#) { return line.lowercased().contains(#"="y""#) ? "on" : "off" }+ }+ return "off"+ }+// "Apple M5 Max" → "M5 Max"; a chip the form doesn't list is "Other".static func chip(_ brand: String) -> String {let name = brand.replacingOccurrences(of: "Apple ", with: "").trimmingCharacters(in: .whitespaces)diff --git a/app/Sources/BridgeplayApp/Model/GameSession.swift b/app/Sources/BridgeplayApp/Model/GameSession.swiftindex 6f8733c..ede68b5 100644--- a/app/Sources/BridgeplayApp/Model/GameSession.swift+++ b/app/Sources/BridgeplayApp/Model/GameSession.swift@@ -123,3 +123,9 @@ struct GameSession: Equatable, Sendable {enum ReportStatus: String, Codable, Sendable {case platinum, gold, silver, bronze, borked}++// The main problem behind a Has Issues answer. Must match ISSUES in bridgeplay-web's+// api/_lib/github.mjs; performance lets the site tell a slow Mac from a Bridgeplay bug.+enum ReportIssue: String, Codable, Sendable, CaseIterable {+ case performance, crash, graphics, sound, controls, launcher+}diff --git a/app/Sources/BridgeplayApp/Model/PlayReports.swift b/app/Sources/BridgeplayApp/Model/PlayReports.swiftindex 180e6b5..794de81 100644--- a/app/Sources/BridgeplayApp/Model/PlayReports.swift+++ b/app/Sources/BridgeplayApp/Model/PlayReports.swift@@ -23,6 +23,8 @@ struct ReportPayload: Codable, Equatable, Sendable {// What the player wrote after Has Issues or Didn't Run, and a few facts about the Mac// (GameReport.setup). Older endpoints ignore both.var note: String?+ var issue: ReportIssue?+ var model: String?var setup: [String: String]?var log: String?var wineLog: String?@@ -33,7 +35,7 @@ struct ReportPayload: Codable, Equatable, Sendable {static func make(name: String, appID: String, status: ReportStatus, source: Source, session: GameSession,log: String?, wineLog: String?, machine: GameReport.Machine, install: String,- note: String? = nil) -> ReportPayload {+ note: String? = nil, issue: ReportIssue? = nil) -> ReportPayload {let launch: (engine: String?, backend: String?) = log.map(GameReport.lastLaunch) ?? (nil, nil)var summary = session.summary(log: log, wineLog: wineLog)if let newer = machine.newerRelease { summary += ". A newer Bridgeplay was out: \(newer)" }@@ -44,6 +46,8 @@ struct ReportPayload: Codable, Equatable, Sendable {macos: machine.macOS, version: machine.bridgeplay, engine: launch.engine, backend: launch.backend,session: summary,note: note.map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }.flatMap { $0.isEmpty ? nil : String($0.prefix(1000)) },+ issue: status == .bronze ? issue : nil,+ model: machine.model,setup: machine.setup.isEmpty ? nil : machine.setup,log: log.map { String(GameReport.redacted($0).suffix(logLimit)) },wineLog: wineLog.map { GameReport.wineTail(GameReport.redacted($0), limit: wineLogLimit) })@@ -139,7 +143,7 @@ final class PlayReports {// What the consent sheet is for: one answer, several from Report Your Games…, or// turning auto-share on.- enum ConsentRequest: Equatable { case answer(ReportStatus, note: String?), bulk([String], ReportStatus), autoShare }+ enum ConsentRequest: Equatable { case answer(ReportStatus, note: String?, issue: ReportIssue? = nil), bulk([String], ReportStatus), autoShare }private(set) var nudges: [Nudge] = []var consentRequest: ConsentRequest?@@ -241,15 +245,15 @@ final class PlayReports {}// The player picked an answer on the card; the first one asks for consent.- func answer(_ status: ReportStatus, note: String? = nil) {+ func answer(_ status: ReportStatus, note: String? = nil, issue: ReportIssue? = nil) {guard let nudge else { return }guard hasConsent else {- consentRequest = .answer(status, note: note)+ consentRequest = .answer(status, note: note, issue: issue)return}advance(past: nudge)recordAsked(nudge.prefix.appID, answer: status)- send(nudge, status: status, source: .tap, note: note)+ send(nudge, status: status, source: .tap, note: note, issue: issue)thanksGeneration += 1let generation = thanksGenerationthanking = true@@ -264,7 +268,7 @@ final class PlayReports {let request = consentRequestconsentRequest = nilif alsoAutoShare || request == .autoShare { setAutoShare(true) }- if case .answer(let status, let note) = request { answer(status, note: note) }+ if case .answer(let status, let note, let issue) = request { answer(status, note: note, issue: issue) }if case .bulk(let appIDs, let status) = request { answerBulk(appIDs, status) }}@@ -406,7 +410,8 @@ final class PlayReports {}}- private func send(_ nudge: Nudge, status: ReportStatus, source: ReportPayload.Source, note: String? = nil) {+ private func send(_ nudge: Nudge, status: ReportStatus, source: ReportPayload.Source, note: String? = nil,+ issue: ReportIssue? = nil) {let prefix = nudge.prefix, session = nudge.sessionTask {let logs = await Task.detached {@@ -414,7 +419,7 @@ final class PlayReports {try? String(contentsOf: PrefixLog.wine.url(for: prefix), encoding: .utf8))}.valuesubmitAll([(Found(prefix: prefix, session: session, log: logs.0 ?? "", wineLog: logs.1), status)],- source: source, note: note)+ source: source, note: note, issue: issue)}}@@ -424,16 +429,21 @@ final class PlayReports {// Redacting a large log takes a moment, so payloads are built off the main thread, and// sent one after another so a batch stays within the endpoint's rate limits.- private func submitAll(_ items: [(Found, ReportStatus)], source: ReportPayload.Source, note: String? = nil) {+ private func submitAll(_ items: [(Found, ReportStatus)], source: ReportPayload.Source, note: String? = nil,+ issue: ReportIssue? = nil) {var machine = GameReport.thisMacmachine.setup = GameReport.setup()let sender = sender(), install = installIDTask.detached {for (item, status) in items {+ var machine = machine+ if let reg = try? String(contentsOf: item.prefix.pfx.appending(path: "user.reg"), encoding: .utf8) {+ machine.setup["retina"] = GameReport.retina(reg)+ }let payload = ReportPayload.make(name: item.prefix.title, appID: item.prefix.appID, status: status, source: source, session: item.session,log: item.log.isEmpty ? nil : item.log, wineLog: item.wineLog, machine: machine, install: install,- note: note)+ note: note, issue: issue)let outcome = await sender.submit(payload)AppLog.note("play report: \(payload.appid) \(payload.status.rawValue) (\(payload.source.rawValue)): \(outcome)")}diff --git a/app/Sources/BridgeplayApp/Resources/Localization/Localizable.xcstrings b/app/Sources/BridgeplayApp/Resources/Localization/Localizable.xcstringsindex 11a36d3..7fa0038 100644--- a/app/Sources/BridgeplayApp/Resources/Localization/Localizable.xcstrings+++ b/app/Sources/BridgeplayApp/Resources/Localization/Localizable.xcstrings@@ -3055,6 +3055,22 @@}}},+ "Controller, keyboard or mouse" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Controller, tastiera o mouse"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "手柄、键盘或鼠标"+ }+ }+ }+ },"Controllers" : {"localizations" : {"it" : {@@ -3279,6 +3295,22 @@}}},+ "Crashes or freezes" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Si chiude o si blocca"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "崩溃或卡死"+ }+ }+ }+ },"CrossOver" : {"shouldTranslate" : false},@@ -4466,6 +4498,22 @@}}},+ "Graphics glitches" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Difetti grafici"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "画面异常"+ }+ }+ }+ },"Guide" : {"localizations" : {"it" : {@@ -5106,6 +5154,22 @@}}},+ "Launcher, sign-in or anti-cheat" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Launcher, accesso o anti-cheat"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "启动器、登录或反作弊"+ }+ }+ }+ },"Let games read controllers directly (Recommended on Mac. Turn off only for Steam Input remapping)" : {"localizations" : {"it" : {@@ -5314,6 +5378,38 @@}}},+ "Low frame rate or stutter" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Frame rate basso o scatti"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "帧率低或卡顿"+ }+ }+ }+ },+ "Main problem" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Problema principale"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "主要问题"+ }+ }+ }+ },"Make WineCX Steam's default" : {"localizations" : {"it" : {@@ -8114,6 +8210,22 @@}}},+ "Sound problems" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Problemi audio"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "声音问题"+ }+ }+ }+ },"Staging components" : {"localizations" : {"it" : {diff --git a/app/Sources/BridgeplayApp/Views/PlayReportCard.swift b/app/Sources/BridgeplayApp/Views/PlayReportCard.swiftindex acb9ee6..98064c7 100644--- a/app/Sources/BridgeplayApp/Views/PlayReportCard.swift+++ b/app/Sources/BridgeplayApp/Views/PlayReportCard.swift@@ -2,11 +2,12 @@ import SwiftUIimport BridgeplayUI// Asks how the last game session ran. Smooth sends at once; Has Issues and Didn't Run first-// offer an optional note on what went wrong.+// offer an optional note on what went wrong, and Has Issues an optional main problem.struct PlayReportCard: View {let nudge: PlayReports.Nudge@State private var pending: ReportStatus?@State private var note = ""+ @State private var issue: ReportIssue?private var reports: PlayReports { .shared }var body: some View {@@ -20,6 +21,7 @@ struct PlayReportCard: View {.onChange(of: nudge.id) {pending = nilnote = ""+ issue = nil}}@@ -30,21 +32,46 @@ struct PlayReportCard: View {.accessibilityHidden(true)VStack(alignment: .leading, spacing: 4) {Text("What went wrong? Optional, and public with the report.").font(BP.sans(13, .semibold))- TextField("For example: no sound, crashes when a level loads", text: $note)- .textFieldStyle(.roundedBorder)- .onSubmit { send(status) }+ HStack(spacing: 8) {+ if status == .bronze {+ Picker("Main problem", selection: $issue) {+ Text("Main problem").tag(ReportIssue?.none)+ ForEach(ReportIssue.allCases, id: \.self) { Text(Self.label($0)).tag(Optional($0)) }+ }+ .labelsHidden()+ .fixedSize()+ }+ TextField("For example: no sound, crashes when a level loads", text: $note)+ .textFieldStyle(.roundedBorder)+ .onSubmit { send(status) }+ }}Spacer(minLength: 12)- Button("Back") { pending = nil }+ Button("Back") {+ pending = nil+ issue = nil+ }Button("Send") { send(status) }.buttonStyle(.borderedProminent)}}private func send(_ status: ReportStatus) {- reports.answer(status, note: note)+ reports.answer(status, note: note, issue: issue)pending = nilnote = ""+ issue = nil+ }++ static func label(_ issue: ReportIssue) -> String {+ switch issue {+ case .performance: String(localized: "Low frame rate or stutter")+ case .crash: String(localized: "Crashes or freezes")+ case .graphics: String(localized: "Graphics glitches")+ case .sound: String(localized: "Sound problems")+ case .controls: String(localized: "Controller, keyboard or mouse")+ case .launcher: String(localized: "Launcher, sign-in or anti-cheat")+ }}private var answerRow: some View {diff --git a/app/Tests/BridgeplayAppTests/PlayReportsTests.swift b/app/Tests/BridgeplayAppTests/PlayReportsTests.swiftindex 99996b6..f3d7108 100644--- a/app/Tests/BridgeplayAppTests/PlayReportsTests.swift+++ b/app/Tests/BridgeplayAppTests/PlayReportsTests.swift@@ -216,6 +216,28 @@ struct PlayReportsTests {install: "0F8FAD5B-D9CB-469F-A165-70867728950E")#expect(payload.session == "Session 27 min, exit status 0. A newer Bridgeplay was out: 0.7.38 (55)")}++ @Test("Retina mode is read from the prefix's Mac Driver key")+ func retinaFromUserReg() {+ let on = "WINE REGISTRY Version 2\r\n[Software\\\\Wine\\\\Mac Driver] 1791551861\r\n#time=1dd\r\n\"RetinaMode\"=\"y\"\r\n\r\n[Software\\\\Wine\\\\X] 1\r\n\"RetinaMode\"=\"n\"\r\n"+ #expect(GameReport.retina(on) == "on")+ #expect(GameReport.retina(on.replacingOccurrences(of: "=\"y\"", with: "=\"n\"")) == "off")+ #expect(GameReport.retina("[Software\\\\Wine\\\\X] 1\n\"RetinaMode\"=\"y\"\n") == "off", "another key's RetinaMode doesn't count")+ }++ @Test("Only a Has Issues payload carries its main problem")+ func payloadIssue() {+ let machine = GameReport.Machine(chip: "Apple M1", memoryBytes: 8 * 1_073_741_824,+ macOS: "macOS 27.0", bridgeplay: "0.7.39 (56)")+ let make = { (status: ReportStatus) in+ ReportPayload.make(name: "CS2", appID: "730", status: status, source: .tap, session: .byHand(),+ log: nil, wineLog: nil, machine: machine, install: "0F8FAD5B-D9CB-469F-A165-70867728950E",+ issue: .performance)+ }+ #expect(make(.bronze).issue == .performance)+ #expect(make(.platinum).issue == nil)+ #expect(make(.borked).issue == nil)+ }}// Answers https://report.invalid/<status> with that status; /offline fails like no network.