fix: native Linux games under FEX reach FEXServer, and a refused compat app no longer loops the sync (#1213)

FEX launched through a script (Valve's _v2-entry-point) was judged 32-bit, so the
fast path stayed off in the FEX client while FEXServer bound its socket through it.
The fast path now follows #! lines before judging the program.

The live compat sync drops apps the client refuses GetCompatTools for instead of
reattaching forever.
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-10-20 14:58:30 -04:00
1 parent 1f71cbd117
commit 1e33eee3f2
3 files changed
+67 -13

No files matched your search

@@ -105,7 +105,7 @@ INSTALL_JS = r"""
const body = [];
uint(1, appid, body);
const r = await send("CompatManager.GetCompatTools#1", body);
if (!r.ok) throw new Error("GetCompatTools " + appid + " failed (" + r.eresult + " " + r.error + ")");
if (!r.ok) throw Object.assign(new Error("GetCompatTools " + appid + " failed (" + r.eresult + " " + r.error + ")"), { eresult: r.eresult });
return { selected: text(r.body, 3), fallback: text(r.body, 4), tools: (r.body[1] || []).map((t) => text(parse(t), 1)) };
};
self.set = async (appid, name) => {
@@ -119,7 +119,13 @@ INSTALL_JS = r"""
};
self.many = async (apps) => {
const out = {};
for (const app of apps) out[app] = (await self.get(Number(app))).selected;
for (const app of apps) {
try {
out[app] = (await self.get(Number(app))).selected;
} catch (e) {
if (e.eresult !== 128) throw e;
}
}
return out;
};
window.__droiddeckCompat = self;
@@ -560,6 +566,17 @@ class Helper:
COMPAT["game_requests"](), catalog, [t["name"] for t in live])
apps = sorted(set(apps) | set(overrides), key=COMPAT["app_order"])
current = dict(page.compat("many(%s)" % json.dumps(apps)) or {})
refused = set(apps) - set(current)
refused_native = native_choices & refused
if refused:
apps = [app for app in apps if app not in refused]
installed = [app for app in installed if app not in refused]
picks = [app for app in picks if app not in refused]
prior_auto = {app: tool for app, tool in prior_auto.items() if app not in refused}
if isinstance(state.get("auto"), dict):
state["auto"] = prior_auto
native_choices -= refused
overrides = {app: tool for app, tool in overrides.items() if app not in refused}
current["0"] = top["selected"]
native = COMPAT["native_targets"](self.steam_root, apps)
raw_mapping = COMPAT["read_config_mapping"](
@@ -590,7 +607,7 @@ class Helper:
tool if tool is not None else "Steam native default"))
state.update(
auto={app: tool for app, tool in auto.items() if tool is not COMPAT["NATIVE_CHOICE"]},
native_choices=sorted(app for app, tool in auto.items() if tool is COMPAT["NATIVE_CHOICE"]),
native_choices=sorted(refused_native | {app for app, tool in auto.items() if tool is COMPAT["NATIVE_CHOICE"]}),
tools=catalog, live=True)
state.pop("native", None)
if waiting:
+22 -6
View File
@@ -141,6 +141,27 @@ static int traced_by_match(const char *key) {
return found;
}
static int program_32bit(const char *prog, int scripts) {
char head[256];
long fd = syscall(SYS_openat, AT_FDCWD, prog, O_RDONLY | O_CLOEXEC);
if (fd < 0) return 1;
long n = syscall(SYS_read, fd, head, sizeof head - 1);
syscall(SYS_close, fd);
if (n < 0) return 1;
head[n] = 0;
if (n >= 2 && head[0] == '#' && head[1] == '!') {
if (scripts <= 0) return 1;
char *p = head + 2;
while (*p == ' ' || *p == '\t') p++;
char *e = p;
while (*e && *e != ' ' && *e != '\t' && *e != '\n' && *e != '\r') e++;
if (e == p || (!*e && n == (long)sizeof head - 1)) return 1;
*e = 0;
return program_32bit(p, scripts - 1);
}
return !(n >= 5 && memcmp(head, "\x7f" "ELF", 4) == 0 && head[4] == 2);
}
static int fex_runs_32bit(void) {
if (strcmp(program_invocation_short_name, "FEX") != 0 && strcmp(program_invocation_short_name, "FEXInterpreter") != 0)
return 0;
@@ -153,12 +174,7 @@ static int fex_runs_32bit(void) {
args[n] = 0;
const char *prog = args + strlen(args) + 1;
if (prog >= args + n || !*prog) return 1;
unsigned char ident[5];
fd = syscall(SYS_openat, AT_FDCWD, prog, O_RDONLY | O_CLOEXEC);
if (fd < 0) return 1;
n = syscall(SYS_read, fd, ident, sizeof ident);
syscall(SYS_close, fd);
return !(n == 5 && memcmp(ident, "\x7f" "ELF", 4) == 0 && ident[4] == 2);
return program_32bit(prog, 4);
}
static int in_tracer(struct bind *bd) {
+25 -4
View File
@@ -54,6 +54,7 @@ class FakeSocket {
state.authed = dec.decode(h[40][0]) === "secret" && dec.decode(body[1][0]) === "secret";
result = state.authed ? 1 : 5;
} else if (!state.authed) result = 5;
else if (method === "CompatManager.GetCompatTools#1" && ["16", "128"].includes(String(body[1][0]))) result = Number(body[1][0]);
else if (method === "CompatManager.GetCompatTools#1") {
const app = String(body[1] ? body[1][0] : 0n);
for (const name of state.known) { const t = []; lenField(1, enc.encode(name), t); lenField(2, enc.encode(name + " shown"), t); lenField(1, t, out); }
@@ -79,17 +80,19 @@ const install = require("fs").readFileSync(process.argv[4], "utf8");
const before = await c.get(0);
await c.set(0, "droiddeck-proton-11-arm64");
await c.set(42, "");
const after = await c.many(["0", "42", "43"]);
const after = await c.many(["0", "42", "43", "128"]);
const timedOut = await c.many(["0", "16"]).then(() => null, (e) => e.eresult);
await new Promise((r) => setTimeout(r, 10));
console.log(JSON.stringify({ before, after, log: state.log, notify: state.notify, url: state.socket.url }));
console.log(JSON.stringify({ before, after, timedOut, log: state.log, notify: state.notify, url: state.socket.url }));
})().catch((e) => { console.error(e.stack || String(e)); process.exit(1); });
"""
class FakePage:
def __init__(self, mapping, known):
def __init__(self, mapping, known, refused=()):
self.mapping = dict(mapping)
self.known = list(known)
self.refused = set(refused)
self.sets = []
def compat(self, call):
@@ -98,8 +101,10 @@ class FakePage:
if name == "get":
return {"selected": self.mapping.get(str(args[0]), ""), "fallback": "proton_experimental", "tools": self.known}
if name == "many":
return {app: self.mapping.get(app, "") for app in args[0]}
return {app: self.mapping.get(app, "") for app in args[0] if app not in self.refused}
if name == "set":
if str(args[0]) in self.refused:
raise RuntimeError("SpecifyCompatTool %s failed (128)" % args[0])
self.mapping[str(args[0])] = args[1]
self.sets.append((str(args[0]), args[1]))
return True
@@ -202,6 +207,7 @@ assert.deepStrictEqual(calls, [['611670', 'custom args', -1, 100], ['2508200', '
self.assertEqual(out["url"], "ws://127.0.0.1:4242/transportsocket/")
self.assertEqual(out["before"], {"selected": TOOL, "fallback": "proton_experimental", "tools": [TOOL, TOOL_11, "proton_experimental"]})
self.assertEqual(out["after"], {"0": TOOL_11, "42": "", "43": ""})
self.assertEqual(out["timedOut"], 16)
self.assertEqual(out["log"], ["0=" + TOOL_11, "42="])
self.assertEqual(out["notify"], ["1", "2"])
@@ -264,6 +270,21 @@ class ReconcileTest(unittest.TestCase):
self.assertTrue(state["live"])
self.assertEqual(self.helper.installed, ["10", "11"])
def test_an_app_the_client_refuses_is_dropped_instead_of_failing_the_sync(self):
page = FakePage({"0": TOOL, "10": TOOL, "11": "proton_experimental"}, [TOOL, TOOL_11], refused={"1628350"})
(self.state / "state.json").write_text(json.dumps({"default": TOOL, "auto": {"10": TOOL, "1628350": TOOL}}))
(self.state / "games.json").write_text(json.dumps({"version": 1, "games": {"1628350": {"valve": True, "dir": "Proton 11.0 (ARM64)"}}}))
state = self.reconcile(page)
self.assertEqual(page.sets, [("11", TOOL)])
self.assertEqual(state["auto"], {"10": TOOL, "11": TOOL})
def test_a_refused_apps_native_choice_is_kept(self):
page = FakePage({"0": TOOL, "10": TOOL, "11": TOOL}, [TOOL, TOOL_11], refused={"20"})
(self.state / "state.json").write_text(json.dumps({"default": TOOL, "auto": {"10": TOOL, "11": TOOL}, "native_choices": ["20"]}))
state = self.reconcile(page)
self.assertEqual(page.sets, [])
self.assertEqual(state["native_choices"], ["20"])
def test_app_request_moves_the_default_and_followers(self):
page = FakePage({"0": TOOL, "10": TOOL, "11": "GE-Proton11-7"}, [TOOL, TOOL_11])
(self.state / "state.json").write_text(json.dumps({"default": TOOL, "auto": {"10": TOOL}}))