fix(steam-x64): keep the session's GL thunk for the x86 web helper (#3027)

* fix(steam-x64): keep the session's GL thunk for the x86 web helper

FEX's global AppConfig for steamwebhelper turns the GL thunk off and is
read after FEX_THUNKCONFIG, so the x86 helper used the rootfs's x86 Mesa.
Steam's browser compositor creates its window through SDL3 and GLX in
the helper's browser process, x86 Mesa faulted in driCreateNewScreen3
(SIGSEGV) about 11 s after each start, and the client restarted the
helper every 12 s.

For every global FEX AppConfig that turns off a thunk the session uses,
the launcher writes a local AppConfig with the session's thunk set. It
leaves local files with other content alone and removes its own files
when the client runs in software.

* fix(steam-x64): write FEX AppConfig overrides atomically

* fix(steam-x64): stage AppConfig overrides in a unique temporary file

* fix(steam-x64): publish AppConfig overrides without replacing a newer file
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-22 14:16:34 -05:00
1 parent 1a29c65d4f
commit b891019b87
3 files changed
+159 -2

No files matched your search

@@ -713,14 +713,67 @@ x64_webhelper_gpu() {
x64_gpu && [ "${DD_X64_CLIENT_SOFTWARE:-0}" != 1 ] && [ "${DD_X64_CEF_GPU:-1}" != 0 ]
}
x64_thunk_appconfigs() {
python3 - "$1" "$2" "$3" "$4" <<'PY' || true
import json, os, sys, tempfile
src, dst, cfg, on = sys.argv[1:5]
want = json.loads(cfg)
try:
names = sorted(os.listdir(src))
except OSError:
names = []
for name in names:
if not name.endswith(".json"):
continue
try:
db = json.load(open(os.path.join(src, name), encoding="utf-8")).get("ThunksDB") or {}
if not any(k in want["ThunksDB"] and not v for k, v in db.items()):
continue
except (OSError, ValueError, AttributeError):
continue
path = os.path.join(dst, name)
try:
cur = json.load(open(path, encoding="utf-8"))
except FileNotFoundError:
cur = None
except (OSError, ValueError):
continue
if cur is not None and cur != want:
continue
if on == "1" and cur is None:
try:
os.makedirs(dst, exist_ok=True)
fd, tmp = tempfile.mkstemp(dir=dst, prefix=".fex", suffix=".tmp")
except OSError:
continue
try:
with os.fdopen(fd, "w", encoding="utf-8") as f:
f.write(cfg + "\n")
os.link(tmp, path)
except OSError:
pass
finally:
try:
os.remove(tmp)
except OSError:
pass
elif on != "1" and cur is not None:
try:
os.remove(path)
except OSError:
pass
PY
}
x64_env() {
export -p | grep -v -E '^declare -x (PWD|OLDPWD|SHLVL|_)=' > "$X64_HOME/arm-session.env.new" || true
mv -f "$X64_HOME/arm-session.env.new" "$X64_HOME/arm-session.env"
unset LD_LIBRARY_PATH LD_PRELOAD STEAM_RUNTIME STEAM_RUNTIME_PREFER_HOST_LIBRARIES
gpu_vars="GALLIUM_DRIVER MESA_LOADER_DRIVER_OVERRIDE VK_ICD_FILENAMES VK_DRIVER_FILES LIBGL_KOPPER_DRI2 ZINK_DEBUG ZINK_DESCRIPTORS TU_DEBUG MESA_NO_ERROR mesa_glthread"
thunk_cfg='{"ThunksDB": {"GL": 1, "Vulkan": 1}}'
rm -f "$X64_HOME/game-gpu.env"
if x64_gpu; then
printf '{"ThunksDB": {"GL": 1, "Vulkan": 1}}\n' > "$X64_HOME/thunks.json"
printf '%s\n' "$thunk_cfg" > "$X64_HOME/thunks.json"
{
echo "export FEX_THUNKCONFIG='$X64_HOME/thunks.json'"
echo "unset LIBGL_ALWAYS_SOFTWARE LIBGL_DRI3_DISABLE GALLIUM_DRIVER"
@@ -729,7 +782,10 @@ if x64_gpu; then
done
} > "$X64_HOME/game-gpu.env"
fi
if x64_gpu && [ "${DD_X64_CLIENT_SOFTWARE:-0}" != 1 ]; then
client_thunks=0
x64_gpu && [ "${DD_X64_CLIENT_SOFTWARE:-0}" != 1 ] && client_thunks=1
x64_thunk_appconfigs /usr/local/share/fex-emu/AppConfig "$X64_HOME/.config/fex-emu/AppConfig" "$thunk_cfg" "$client_thunks"
if [ "$client_thunks" = 1 ]; then
export FEX_THUNKCONFIG=$X64_HOME/thunks.json
unset LIBGL_ALWAYS_SOFTWARE LIBGL_DRI3_DISABLE
else