diff --git a/docs/development/game-environment.md b/docs/development/game-environment.md index fafc802f9d..456e66cc6a 100644 --- a/docs/development/game-environment.md +++ b/docs/development/game-environment.md @@ -19,6 +19,15 @@ per-app compatibility mapping, including while Steam is running when its live compatibility helper is attached. A newly installed Proton that the running client has not discovered yet applies when Steam next starts. +For **Start without Steam**, `droiddeck-proton-run --app` decodes only the requested +game's `appinfo.vdf` records to choose its executable and arguments. The reader still +supports formats 27-29 and reads the file/string table; this is not a reduction in +disk-read bytes. Repeated queries reuse a process-local cache, with partial coverage +kept distinct from a complete decode. Partial queries share one immutable byte +snapshot; a complete decode drops that byte snapshot, and a file timestamp change +invalidates the cache. Bulk callers still request all entries. Launch selection, +prefix/Proton choices and saved settings are unchanged. + Each game can also override the stored FEX, DXVK and VKD3D-Proton package used by its selected Proton. The launch wrapper applies that game’s component files immediately before Proton starts, removes managed files that are absent from the diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-proton-run b/tools/linuxfs/overlay/usr/local/bin/droiddeck-proton-run index 410f1654d1..237457d947 100644 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-proton-run +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-proton-run @@ -351,7 +351,7 @@ def steam_launch(appid, root): library, install = steam_install(appid, root) if not install or not os.path.isdir(install): return None - entry = compat()["appinfo_entries"](os.path.join(root, "appcache", "appinfo.vdf")).get(str(appid), {}) + entry = compat()["appinfo_entries"](os.path.join(root, "appcache", "appinfo.vdf"), wanted={str(appid)}).get(str(appid), {}) options = [option for option in entry.get("launch_options", ()) if not option["betakey"] and (not option["oslist"] or "windows" in option["oslist"])] options.sort(key=lambda option: (option["type"] not in ("", "default", "none"), @@ -376,7 +376,7 @@ def shortcut_target(appid, program, start, root): def steam_launches(target, program, root): if target.kind != "steam": return False - entry = compat()["appinfo_entries"](os.path.join(root, "appcache", "appinfo.vdf")).get(target.appid, {}) + entry = compat()["appinfo_entries"](os.path.join(root, "appcache", "appinfo.vdf"), wanted={target.appid}).get(target.appid, {}) return os.path.relpath(program, target.install).replace(os.sep, "/").lower() in entry.get("launch", ()) diff --git a/tools/linuxfs/overlay/usr/local/bin/steam-compatibility b/tools/linuxfs/overlay/usr/local/bin/steam-compatibility index 397a19d73d..acacb0e17d 100755 --- a/tools/linuxfs/overlay/usr/local/bin/steam-compatibility +++ b/tools/linuxfs/overlay/usr/local/bin/steam-compatibility @@ -777,20 +777,32 @@ def launch_options(config): return found -def appinfo_entries(path): +def appinfo_entries(path, wanted=None): + """Read metadata for all apps, or only the requested app-id strings.""" import struct + if wanted is not None: + wanted = set(wanted) + if not wanted: + return {} try: stamp = os.stat(path).st_mtime_ns except OSError: return {} cached = APPINFO_CACHE.get(path) if cached and cached[0] == stamp: - return cached[1] - try: - with open(path, "rb") as f: - data = f.read() - except OSError: - return {} + covered = cached[2] + if covered is None or (wanted is not None and wanted <= covered): + return cached[1] if wanted is None else {app: cached[1][app] for app in wanted if app in cached[1]} + data = cached[3] + needed = None if wanted is None else wanted - covered + else: + cached = None + needed = wanted + try: + with open(path, "rb") as f: + data = f.read() + except OSError: + return {} if len(data) < 8: return {} magic = struct.unpack_from("= 0x07564428 else 40) + offset += 8 + size + assert payload is not None + data[payload] = 0xFF + self.path.write_bytes(data) + COMPAT["APPINFO_CACHE"].clear() + full = self.lookup() + COMPAT["APPINFO_CACHE"].clear() + selected = self.lookup({"1"}) + self.assertEqual(selected, {"1": full["1"]}) + self.assertEqual(selected["1"]["launch"][0], "last.exe" if corrupt_last else "final.exe") + + def test_requested_steam_play_manifest_keeps_extended_mappings(self): + manifests = COMPAT["STEAM_PLAY_MANIFESTS"] + record = {"common": {"type": "Tool"}, "extended": {"app_mappings": { + "0": {"appid": "42", "tool": "proton_experimental"}, + }}} + for magic in FORMATS: + with self.subTest(magic=magic): + COMPAT["APPINFO_CACHE"].clear() + self.write({1: entry("One"), manifests: record}, magic) + self.assertEqual(self.lookup({str(manifests)})[str(manifests)]["app_mappings"], + {"42": "proton_experimental"}) + + def test_empty_requests_do_not_read_or_stat_the_file(self): + with mock.patch("builtins.open", side_effect=AssertionError("no file should be read")): + with mock.patch.object(COMPAT["os"], "stat", side_effect=AssertionError("no stat is needed")): + self.assertEqual(self.lookup(set()), {}) + self.assertEqual(COMPAT["APPINFO_CACHE"], {}) + + def test_missing_and_invalid_files_keep_empty_results(self): + self.assertEqual(self.lookup({"1"}), {}) + for data in (b"", b"\x29", struct.pack("