From d629f83b8ccb9d613ffe938047bba2c85990c245 Mon Sep 17 00:00:00 2001 From: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> Date: Sat, 28 Nov 2026 02:18:42 -0500 Subject: [PATCH] fix(agent): tag handed-off game windows outside the reaper --- docs/phantom-processes.md | 8 +++++++- tools/linuxfs/overlay/usr/local/bin/droiddeck-agent | 6 ++++-- tools/tests/test_droiddeck_agent.py | 9 +++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/docs/phantom-processes.md b/docs/phantom-processes.md index d207421f90..4bce618e85 100644 --- a/docs/phantom-processes.md +++ b/docs/phantom-processes.md @@ -237,6 +237,11 @@ vfork-safe (Python's subprocess execs under `vfork`). Details that mattered: walking its process's parents) and its utility processes (the client refuses its transport — "no transport is available" — from processes that are not its children). The web helper's renderers hand off fine. +- **Game windows outside the reaper:** gamescope finds a window's app by walking its process up to + Steam's `reaper`, which a handed-off Wine process is not under. Proton sets `STEAM_GAME` itself + from `SteamGameId`, but a store game's is a 64-bit id and is not set: Splinter Cell (Ubisoft) + ran without ever taking focus. The agent now tags such a window from its process's `SteamAppId` + also on the arm64 client. - One-shot programs cost a worker start (~100 ms) each, so the list names long-lived programs only (`xprop+-spy`: `name+prefix` matches only when an argument starts with prefix). - **Near the limit, a shell's children too.** Once 20 of the app's processes are counted (the hook @@ -442,7 +447,8 @@ the old behavior and the old requirement. - ~~more games and configurations~~ done on the Thor with the stock limit on, no kills in any: Bully on GE-Proton, Proton Experimental ARM64 and DroidDeck-Proton 11 (11–14 counted), Bomb Rush Cyberfunk (14), MGSV Ground Zeroes (13), Sekiro (13), zero-copy off (11), the x86-64 - Steam client under FEX (14, against 55 without the handoff), the desktop at rest (17–20) and + Steam client under FEX (14, against 55 without the handoff), Splinter Cell through Ubisoft + Connect (14, against 65), the desktop at rest (17–20) and with a terminal's 40 background jobs (20). PRoot sessions keep the old behavior and still need the developer option: with the limit on, Android killed 30 of their processes and the session failed; diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-agent b/tools/linuxfs/overlay/usr/local/bin/droiddeck-agent index df0f4cedf1..6e3b9e9da2 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-agent +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-agent @@ -282,8 +282,10 @@ def sandboxed_apps(proc=Path("/proc")): def window_steam_app(win, flatpaks, proc=Path("/proc")): match = STEAM_APP_CLASS.match(win.get("class") or "") - if match: - return match.group(1) if os.environ.get("DD_STEAM_CLIENT_ARCH") == "x86_64" else None + if match and os.environ.get("DD_STEAM_CLIENT_ARCH") == "x86_64": + return match.group(1) + # Gamescope finds the app of a window whose process runs under Steam's reaper. A game the + # session runs in a worker process (GuestWorkers) is not under it, whatever its class. pid = win.get("pid") if pid: if under_reaper(pid, proc): diff --git a/tools/tests/test_droiddeck_agent.py b/tools/tests/test_droiddeck_agent.py index 72931860b7..0e055df0a2 100644 --- a/tools/tests/test_droiddeck_agent.py +++ b/tools/tests/test_droiddeck_agent.py @@ -247,6 +247,15 @@ class AgentTest(unittest.TestCase): {"window": 13, "map": "viewable", "class": "steam_app_550", "pid": None}] self.assertEqual(self.tag(wins), (False, [])) + def test_a_proton_window_run_in_a_worker_takes_its_process_app_id(self): + # a store game's Wine process handed to a worker: its parent is zygote, not the reaper + self.fake_proc(50, 1, "SplinterCell.exe", {"SteamAppId": "2565121641", "SteamGameId": "11017113558390407168"}) + self.fake_proc(20, 1, "reaper", {}) + self.fake_proc(21, 20, "Bully.exe", {"SteamAppId": "12200"}) + wins = [{"window": 14, "map": "viewable", "class": "steam_app_2565121641", "pid": 50}, + {"window": 15, "map": "viewable", "class": "steam_app_12200", "pid": 21}] + self.assertEqual(self.tag(wins), (True, ["2565121641"])) + def test_the_x86_client_still_tags_its_game_classes(self): win = {"window": 13, "map": "viewable", "class": "steam_app_550", "pid": None} self.assertEqual(self.tag([win], arch="x86_64"), (True, ["550"]))