feat: fetch Proton, FEX and the runtimes automatically, and make Linux games run under FEX (#1045)

* fix: x86 Linux games that also ship for Windows run under Proton again

Since #749 the live compatibility helper treated every installed game with
both Windows and x86 Linux builds as a user's native choice, because the
client reports an empty tool for unmapped games. Those games were left on
the Steam Linux Runtime, which cannot start them here (bwrap fails, or FEX
looks for a RootFS that is not shipped), so Valheim, Moonlighter, Half-Life 2,
TF2 and others exited within seconds.

- An unmapped game the helper never managed now gets the default Proton.
  Clearing a mapping the helper set is still kept as a native choice.
- Native choices are stored under "native_choices". The old "native" list
  also held games nobody picked, so it is dropped.

* feat: Linux builds run under FEX by default, with the runtimes fetched automatically

- Steam fetches Proton, FEX, Steam Linux Runtime 3.0 and 4.0 on the first start and keeps them updated instead of leaving them pending.
- Games that ship a Linux build go to FEX once it can run them; Windows-only games and installed Windows builds keep the Proton default.
- FEX runs games on a combined x86 runtime with the newer glibc and libstdc++ the GL and Vulkan thunks need.
- Vulkan display extensions the driver cannot handle are hidden in front of the thunk, without an audit module.
- Mono's incremental garbage collector is turned off under FEX, which stops Unity games crashing.
- x86 Steamworks finds the x86 steamclient.
- 32-bit games read the virtual controller.

* fix: controllers work in Linux Unity games such as Valheim

Joystick ioctls on an event node now fail with EINVAL like the kernel's evdev, so the SDL2 that Unity embeds reads the pad's real ID instead of ignoring it as 0000:0000.

* test: skip the switch script test without node, and the ring tests without gcc

* fix: games with a Linux build keep the Proton default

The Windows build often runs better, so titles that ship both builds stay on the default Proton again. Users can still pick FEX for one, and that choice is kept. Linux-only titles still go to FEX.

* fix: unmapped dual-platform games get Proton even when config.vdf cannot be read
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-10-18 08:59:54 -04:00
1 parent 219548f4b6
commit 69c88aa344
17 files changed
+1035 -144

No files matched your search

+185 -11
View File
@@ -117,6 +117,47 @@ class PageScriptTest(unittest.TestCase):
capture_output=True, text=True, timeout=20)
self.assertEqual(result.returncode, 0, result.stderr)
def test_tool_installs_skip_only_their_own_install_dialog(self):
harness_source = r"""
const assert = require('assert');
globalThis.window = globalThis;
const script = require('fs').readFileSync(process.argv[2], 'utf8');
globalThis.SteamClient = { Installs: {}, Downloads: {} };
assert.throws(() => eval(script), /install calls are not ready/);
const opened = [], queued = [];
let wizard = null, continued = 0;
globalThis.SteamClient = {
Installs: {
OpenInstallWizard(apps, client) { opened.push([apps, client]); },
RegisterForShowInstallWizard(callback) { assert.strictEqual(wizard, null); wizard = callback; return { unregister() {} }; },
ContinueInstall() { continued++; },
},
Downloads: { QueueAppUpdate(app, client) { queued.push([app, client]); } },
};
assert.strictEqual(eval(script), 'installed');
assert.strictEqual(eval(script), 'present');
const tools = window.__droiddeckTools;
wizard({ eInstallState: 7, currentAppID: 4183110 });
assert.strictEqual(continued, 0);
tools.install(4183110);
assert.deepStrictEqual(opened, [[[4183110], '0']]);
wizard({ eInstallState: 8, currentAppID: 4183110 });
wizard({ eInstallState: 7, currentAppID: 892970 });
assert.strictEqual(continued, 0);
wizard({ eInstallState: 7, currentAppID: 4183110 });
wizard({ eInstallState: 7, currentAppID: 4183110 });
assert.strictEqual(continued, 1);
tools.update(4427310);
assert.deepStrictEqual(queued, [[4427310, '0']]);
"""
with tempfile.TemporaryDirectory() as tmp:
script = Path(tmp) / "tools.js"
script.write_text(LIVE["TOOLS_JS"])
harness = Path(tmp) / "harness.js"
harness.write_text(harness_source)
result = subprocess.run(["node", str(harness), str(script)], capture_output=True, text=True, timeout=20)
self.assertEqual(result.returncode, 0, result.stderr)
def test_steamvr_library_launch_uses_binding_and_other_games_pass_through(self):
harness_source = r"""
const assert = require('assert');
@@ -334,19 +375,19 @@ class ReconcileTest(unittest.TestCase):
state = self.reconcile(page)
self.assertEqual(page.sets, [])
self.assertEqual(state["auto"], {})
self.assertEqual(state["native"], [app])
self.assertEqual(state["native_choices"], [app])
self.assertEqual(COMPAT["read_config_mapping"](str(config)), {"0": TOOL})
page.sets.clear()
state = self.reconcile(page)
self.assertEqual(page.sets, [])
self.assertEqual(state["native"], [app])
self.assertEqual(state["native_choices"], [app])
restarted = LIVE["Helper"](str(self.steam), 1)
restarted.page = page
restarted.reconcile()
state = json.loads((self.state / "state.json").read_text())
self.assertEqual(page.sets, [])
self.assertEqual(state["native"], [app])
self.assertEqual(state["native_choices"], [app])
config.write_text(
'"InstallConfigStore" { "Software" { "Valve" { "Steam" { '
@@ -356,13 +397,13 @@ class ReconcileTest(unittest.TestCase):
state = self.reconcile(page)
self.assertEqual(page.mapping[app], "GE-Proton11-7")
self.assertEqual(page.sets, [])
self.assertEqual(state["native"], [])
self.assertEqual(state["native_choices"], [])
for choice in ("steamlinuxruntime", COMPAT["FEX_TOOL"], TOOL_11):
(self.state / "state.json").write_text(json.dumps({
"default": TOOL,
"auto": {},
"native": [app],
"native_choices": [app],
}))
config.write_text(
'"InstallConfigStore" { "Software" { "Valve" { "Steam" { '
@@ -373,7 +414,7 @@ class ReconcileTest(unittest.TestCase):
state = self.reconcile(page)
self.assertEqual(page.mapping[app], choice)
self.assertEqual(page.sets, [])
self.assertEqual(state["native"], [], choice)
self.assertEqual(state["native_choices"], [], choice)
finally:
COMPAT["native_targets"] = original_native_targets
@@ -387,7 +428,7 @@ class ReconcileTest(unittest.TestCase):
(self.state / "state.json").write_text(json.dumps({
"default": TOOL,
"auto": {},
"native": [app],
"native_choices": [app],
}))
original_native_targets = COMPAT["native_targets"]
@@ -396,14 +437,14 @@ class ReconcileTest(unittest.TestCase):
page = FakePage({"0": TOOL, app: "proton"}, [TOOL, TOOL_11])
state = self.reconcile(page)
self.assertNotIn(app, self.helper.installed)
self.assertEqual(state["native"], [app])
self.assertEqual(state["native_choices"], [app])
self.assertNotIn(app, state["auto"])
self.assertNotIn((app, TOOL), page.sets)
self.assertEqual(COMPAT["read_config_mapping"](str(config)), {"0": TOOL})
config.write_text('"InstallConfigStore" { "Software" { "Other" {} } }')
state = self.reconcile(page)
self.assertEqual(state["native"], [app])
self.assertEqual(state["native_choices"], [app])
self.assertNotIn((app, TOOL), page.sets)
config.write_text(
@@ -412,12 +453,72 @@ class ReconcileTest(unittest.TestCase):
'"%s" { "name" "GE-Proton11-7" } } } } } }' % (TOOL, app))
page.mapping[app] = "proton"
state = self.reconcile(page)
self.assertEqual(state["native"], [])
self.assertEqual(state["native_choices"], [])
self.assertNotIn((app, TOOL), page.sets)
self.assertEqual(COMPAT["read_config_mapping"](str(config))[app], "GE-Proton11-7")
finally:
COMPAT["native_targets"] = original_native_targets
def dual_platform_game(self, state):
app = "892970"
(self.steam / ("steamapps/appmanifest_%s.acf" % app)).write_text("")
config = self.steam / "config/config.vdf"
config.parent.mkdir(parents=True)
config.write_text(
'"InstallConfigStore" { "Software" { "Valve" { "Steam" { '
'"CompatToolMapping" { "0" { "name" "%s" } } } } } }' % TOOL)
(self.state / "state.json").write_text(json.dumps(state))
patcher = mock.patch.dict(COMPAT, {"native_targets": lambda _root, apps: {
app: COMPAT["NATIVE_CHOICE"]
} if app in apps else {}})
patcher.start()
self.addCleanup(patcher.stop)
return app, FakePage({"0": TOOL, "10": TOOL, "11": TOOL}, [TOOL, TOOL_11])
def test_unmapped_dual_platform_game_gets_the_default_live(self):
app, page = self.dual_platform_game({"default": TOOL, "auto": {"10": TOOL, "11": TOOL}})
state = self.reconcile(page)
self.assertEqual(page.sets, [(app, TOOL)])
self.assertEqual(state["auto"][app], TOOL)
self.assertEqual(state["native_choices"], [])
page.mapping[app] = ""
page.sets.clear()
state = self.reconcile(page)
self.assertEqual(page.sets, [])
self.assertEqual(state["native_choices"], [app])
def test_unmapped_dual_platform_game_gets_the_default_without_a_readable_config(self):
app, page = self.dual_platform_game({"default": TOOL, "auto": {"10": TOOL}, "native_choices": ["11"]})
(self.steam / "config/config.vdf").unlink()
page.mapping["11"] = ""
state = self.reconcile(page)
self.assertEqual(page.sets, [(app, TOOL)])
self.assertEqual(state["auto"][app], TOOL)
self.assertEqual(state["native_choices"], ["11"])
def test_a_tool_set_live_is_kept_before_the_client_writes_its_config(self):
app, page = self.dual_platform_game({"default": TOOL, "auto": {"10": TOOL, "11": TOOL, "892970": TOOL}})
page.known.append(COMPAT["FEX_TOOL"])
page.mapping[app] = TOOL
config = self.steam / "config/config.vdf"
config.write_text(
'"InstallConfigStore" { "Software" { "Valve" { "Steam" { '
'"CompatToolMapping" { "0" { "name" "%s" } "%s" { "name" "%s" } } } } } }' % (TOOL, app, TOOL))
with mock.patch.dict(COMPAT, {"native_targets": lambda _root, apps: {app: COMPAT["FEX_TOOL"]} if app in apps else {}}):
state = self.reconcile(page)
self.assertEqual(page.sets, [(app, COMPAT["FEX_TOOL"])])
state = self.reconcile(page)
self.assertEqual(page.sets, [(app, COMPAT["FEX_TOOL"])])
self.assertEqual(state["auto"][app], COMPAT["FEX_TOOL"])
def test_native_list_from_earlier_builds_is_not_trusted(self):
app, page = self.dual_platform_game({"default": TOOL, "auto": {"10": TOOL, "11": TOOL}, "native": ["892970"]})
state = self.reconcile(page)
self.assertEqual(page.sets, [(app, TOOL)])
self.assertNotIn("native", state)
self.assertEqual(state["native_choices"], [])
def test_factorio_without_prior_auto_state_uses_the_default_proton(self):
app = "427520"
(self.steam / ("steamapps/appmanifest_%s.acf" % app)).write_text("")
@@ -436,7 +537,7 @@ class ReconcileTest(unittest.TestCase):
state = self.reconcile(page)
self.assertEqual(page.sets, [(app, TOOL)])
self.assertEqual(state["auto"], {app: TOOL})
self.assertEqual(state["native"], [])
self.assertEqual(state["native_choices"], [])
self.assertEqual(COMPAT["read_config_mapping"](str(config)), {"0": TOOL})
finally:
COMPAT["native_targets"] = original_native_targets
@@ -485,6 +586,79 @@ console.log(JSON.stringify({ sent: sent.length, asked: asked.length }));
"""
class ToolPage(FakePage):
def __init__(self, fail=False):
super().__init__({"0": TOOL}, [TOOL])
self.calls = []
self.fail = fail
def tools(self, call):
self.calls.append(call)
if self.fail:
raise RuntimeError("the client's install calls are not ready")
return True
class ToolDownloadTest(unittest.TestCase):
def setUp(self):
tmp = tempfile.TemporaryDirectory()
self.addCleanup(tmp.cleanup)
self.steam = Path(tmp.name) / "Steam"
(self.steam / "steamapps").mkdir(parents=True)
self.helper = LIVE["Helper"](str(self.steam), 1)
self.now = [1000.0]
self.running = [False]
self.requested = []
patcher = mock.patch.dict(COMPAT, {
"game_running": lambda: self.running[0],
"request_fex": lambda root, asked: self.requested.append(root) or ["3127680"],
})
patcher.start()
self.addCleanup(patcher.stop)
clock = mock.patch.object(LIVE["time"], "monotonic", lambda: self.now[0])
clock.start()
self.addCleanup(clock.stop)
def manifest(self, app, flags):
(self.steam / ("steamapps/appmanifest_%s.acf" % app)).write_text('"AppState" { "StateFlags" "%s" }' % flags)
def test_missing_tools_are_installed_and_deferred_ones_queued(self):
self.manifest("4427310", "6")
self.manifest("3127680", "4")
self.manifest("1628350", "1026")
self.helper.page = page = ToolPage()
self.helper.ensure_tools()
self.assertEqual(page.calls, ["update(4427310)", "update(1628350)", "install(4183110)"])
self.now[0] += 30
self.helper.ensure_tools()
self.now[0] += 60
self.helper.ensure_tools()
self.assertEqual(len(page.calls), 3)
self.now[0] += 300
self.manifest("4427310", "4")
self.helper.ensure_tools()
self.assertEqual(page.calls[3:], ["update(1628350)", "install(4183110)"])
self.assertEqual(self.requested, [])
def test_nothing_is_queued_while_a_game_runs(self):
self.running[0] = True
self.helper.page = page = ToolPage()
self.helper.ensure_tools()
self.assertEqual(page.calls, [])
self.running[0] = False
self.now[0] += 60
self.helper.ensure_tools()
self.assertEqual(len(page.calls), 4)
def test_an_install_falls_back_to_the_steam_url(self):
for app in ("4427310", "1628350", "4183110"):
self.manifest(app, "4")
self.helper.page = page = ToolPage(fail=True)
self.helper.ensure_tools()
self.assertEqual(page.calls, ["install(3127680)"])
self.assertEqual(self.requested, [str(self.steam)])
@unittest.skipUnless(shutil.which("node"), "node is not installed")
class SwitchScriptTest(unittest.TestCase):
def test_the_request_is_reported_and_still_sent(self):