mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-22 06:15:58 +00:00
* perf: fast path resolves links, /proc and glue as proot does, and answers uname, isatty and passwd
The fast path handed back to proot whatever crossed a symlink, /proc or a directory proot
only shows as glue, which is most of what Steam and Wine ask. It now walks a path the way
proot's canonicalize() does, so those calls stay in-process:
- links are followed in guest terms and their text detranslated as detranslate_path() does,
including readlink into a buffer the kernel cut short and /proc's exe, cwd and fd links;
- a binding proot dropped at start is dropped here too, glue above a binding is ENOENT, and a
last component proot cannot stat is left to the kernel;
- pipe and socket dirfds are ENOTDIR, rmdir("dir/") removes dir, and "." and ".." go to proot;
- a blocking accept() with a connection already waiting no longer goes to proot.
Also answered: uname() and gethostname() (proot's utsname never changes), isatty() (glibc
2.43 asks with TCGETS2, which proot rewrites) and getpwnam/getpwuid when nsswitch.conf
sends passwd to files first and the entry is there (Xwayland asks for every client).
equiv.py, equiv2.py and equiv3.py match line for line with and without the fast path
(222, 507 and 924 lines). Per call on the RedMagic: realpath 240 us -> 1.0 us,
realpath /proc/self/fd/N 408 -> 9.9, getpwuid 41.5 -> 4.6, uname 28 -> 0.006.
* perf: LD_AUDIT module skips library lookups proot would fail
ld.so looks each library up along the game's search path, and Proton puts the game's
directory, Steam's runtime and video directories and its own library directories ahead of
/usr/lib: 72% of ld.so's opens in an Among Us launch failed, each a round trip to proot.
libblaudit.so answers la_objsearch() for a candidate proot would certainly fail with ENOENT
(its directory walked as canonicalize() walks it, the name or a directory on the way missing).
It has no libc and maps the fast path's trampoline itself. Each lookup's first candidate is
still opened, since a skipped one fails with ld.so's errno as it stands, and the default
directories are never skipped, so dlerror() reads the same. droiddeck-proton and the extra
wrapper add it to LD_AUDIT when the fast path is on.
* perf: droiddeck-proton checks a tool's components with one sha256sum
Each program the launcher starts pays a dozen traced library lookups under the game's search
path before it does anything. One sha256sum over every listed file replaces one per file;
the check itself is unchanged.
* perf: build a locale archive for C.UTF-8
Every program loads the locale LANG names before main(). glibc ships C.UTF-8 as a directory
it looks for once per category under two spellings, before reading gconv's module lists:
about 30 opens, each a stop in proot, in every process of the session. droiddeck-session
builds /usr/lib/locale/locale-archive (and gconv's cache) once per glibc package, so that is
one open.
localedef names a finished archive by hard link, which Android refuses; with
DROIDDECK_LINK_RENAME=1 libblsession turns a refused link into a rename that will not replace
an existing name.
* perf: library beat starts its helpers only when what they read changed
Every 15 s the session ran droiddeck-seed-redists (some forty programs under proot) and, when
a library directory had changed, steam-compatibility: a burst of thousands of proot stops each
quarter minute, game loads included. The seeder now runs when a library changed or a prefix
(or Proton's template for them) is unmarked, the compat pass when a manifest, depot, tool or
config.vdf changed, both checked from bash without starting anything, and each every five
minutes regardless. The seeder reads its stamp and the time without a subshell each.
* perf: fakeinput opens pad.log on its first line
Every process the library is loaded in opened the session's pad.log at start, a stop in proot
on shared storage, and most never write to it. The file is now opened when there is a line to
write.
* docs: the fast path as it ships, the audit module and measured launch times
* fix: a game the app launches after an idle spell comes to the front
The Steam client brings a game it launched forward only while it counts someone as present,
which it reads from gamescope's input counter. A game the app launched after four or more
minutes without a touch started, mapped its window, and stayed behind the library page until
the next input (device: Palworld, Stardew Valley, Fallout: New Vegas, Mortal Kombat X; the same
on main). The session now watches a requested launch, and when the game's window is focusable
but the interface keeps focus for two polls, counts one input on gamescope's counter, as a key
would. Nothing changes for a launch the client already brings forward.
162 lines
8.0 KiB
Bash
Executable File
162 lines
8.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# Marks Steam's shared redistributables as already run in every Proton prefix, and in the
|
|
# template Proton makes new prefixes from.
|
|
#
|
|
# A game whose depot lists _CommonRedist makes the client run the real installer inside the
|
|
# prefix on first launch. Those are x86 bundles, so they run under FEX, and the 2019 one leaves
|
|
# a task behind every time: its main thread exits while a helper stays blocked reading a pipe it
|
|
# also holds the write end of, so the process never reaps and the client keeps waiting on it.
|
|
#
|
|
# The client skips a "Run Process" block whose HasRunKey is already set, which is the same escape
|
|
# WineUtils.seedVcRedistRegistryIfDllsPresent() takes for the app's own containers. The names and
|
|
# versions come out of the install scripts rather than a list kept here, because Valve revises
|
|
# them; a prefix already carrying the same set is left alone.
|
|
#
|
|
# Games also carry install scripts of their own (<game>/_CommonRedist/vcredist/2022/installscript.vdf
|
|
# and the like), often with another version in the value name; those are read too. And the VC++
|
|
# 2015-2022 runtime is recorded as installed the way Microsoft's installers look for it: on ARM64
|
|
# Proton the x64 bundle otherwise stops with "Microsoft Visual C++ 2015-2022 Redistributable (arm64)
|
|
# is required", while Proton's own msvcp140/vcruntime140 already serve the game.
|
|
set -u
|
|
steam_root=${1:?steam root}
|
|
LIBRARIES=${DROIDDECK_LIBRARIES-/mnt/droiddeck /mnt/droiddeck-sd}
|
|
|
|
redist="$steam_root/steamapps/common/Steamworks Shared/_CommonRedist"
|
|
|
|
# Every process an install script would run, as the registry key and value the client writes once
|
|
# it has run it. Names sit one level inside "Run Process", the key they share a level further in.
|
|
read_scripts() { xargs -0 -r awk '
|
|
# A block whose HasRunKey is set is one process; its name is the key the block opened under, at
|
|
# whatever depth - an install script nests it under "Run Process", the client'"'"'s evaluator script
|
|
# for a game wraps the same blocks once more.
|
|
FNR == 1 { depth = 0; pending = "" }
|
|
/^[[:space:]]*\{/ { depth++; name[depth] = pending; key[depth] = ""; pending = ""; next }
|
|
/^[[:space:]]*\}/ {
|
|
if (depth > 0 && key[depth] != "" && name[depth] != "")
|
|
printf "%s\t%s\n", key[depth], name[depth]
|
|
if (depth > 0) depth--
|
|
next
|
|
}
|
|
{
|
|
n = split($0, part, "\"")
|
|
if (n >= 5 && tolower(part[2]) == "hasrunkey") { key[depth] = part[4]; next }
|
|
if (n == 3) pending = part[2]
|
|
}
|
|
'; }
|
|
pairs=$(find "$redist" -name installscript.vdf -print0 2>/dev/null | sort -z | read_scripts)
|
|
# The client downloads the scripts with the first game that wants them, which is too late for that
|
|
# game; until then the set they held when this was written stands in. (WinNative's list.)
|
|
[ -n "$pairs" ] || pairs=$(sed 's/^\([^ ]*\) /HKEY_LOCAL_MACHINE\\\\Software\\\\Valve\\\\Steam\\\\Apps\\\\CommonRedist\\\\\1\t/' <<'KNOWN'
|
|
DirectX\\Jun2010 dxsetup
|
|
.NET\\4.8 4.8
|
|
vcredist\\2008 x86 SP1
|
|
vcredist\\2008 x64 SP1
|
|
vcredist\\2010 x86
|
|
vcredist\\2010 x64
|
|
vcredist\\2013 x86 12.0.30501
|
|
vcredist\\2013 x64 12.0.30501
|
|
vcredist\\2015 x86 Update 3 14.0.24215.0
|
|
vcredist\\2015 x64 Update 3 14.0.24215.0
|
|
vcredist\\2017 x86 14.10.25008.0
|
|
vcredist\\2017 x64 14.10.25008.0
|
|
vcredist\\2019 x86 14.28.29334.0
|
|
vcredist\\2019 x64 14.28.29334.0
|
|
vcredist\\2022 x86 14.51.36247.0
|
|
vcredist\\2022 x64 14.51.36247.0
|
|
KNOWN
|
|
)
|
|
|
|
# The games' own scripts. Finding them walks every game folder, so the list is kept until a game is
|
|
# installed, updated or removed (its appmanifest changes) - this runs every quarter minute.
|
|
cache="$steam_root/.droiddeck-game-scripts"
|
|
libraries="$steam_root"
|
|
for library in $LIBRARIES; do libraries="$libraries
|
|
$library"; done
|
|
libraries=$(printf '%s\n%s\n' "$libraries" "$(sed -n 's/^[[:space:]]*"path"[[:space:]]*"\(.*\)"[[:space:]]*$/\1/p' "$steam_root/steamapps/libraryfolders.vdf" 2>/dev/null)" | awk 'NF && !seen[$0]++')
|
|
sig=$(while IFS= read -r library; do ls -l --time-style=+%s "$library"/steamapps/appmanifest_*.acf 2>/dev/null; done <<<"$libraries" | cksum)
|
|
if [ "$(head -n 1 "$cache" 2>/dev/null)" != "$sig" ]; then
|
|
{
|
|
printf '%s\n' "$sig"
|
|
while IFS= read -r library; do
|
|
[ -d "$library/steamapps/common" ] || continue
|
|
find "$library/steamapps/common" -mindepth 2 -maxdepth 5 -iname 'installscript*.vdf' \
|
|
-not -path '*/Steamworks Shared/*' 2>/dev/null
|
|
done <<<"$libraries" | sort -u
|
|
} >"$cache.tmp" && mv -f "$cache.tmp" "$cache"
|
|
fi
|
|
game_pairs=$(tail -n +2 "$cache" 2>/dev/null | tr '\n' '\0' | read_scripts)
|
|
# DROIDDECK_SEED_SCRIPTS: more scripts, one path a line - droiddeck-game-env passes the client's
|
|
# evaluator script for the game about to run its installers, read before the client looks.
|
|
if [ -n "${DROIDDECK_SEED_SCRIPTS:-}" ]; then
|
|
game_pairs=$(printf '%s\n%s\n' "$game_pairs" "$(printf '%s\n' "$DROIDDECK_SEED_SCRIPTS" | tr '\n' '\0' | read_scripts)")
|
|
fi
|
|
[ -n "$(printf '%s' "$game_pairs" | tr -d '[:space:]')" ] && pairs=$(printf '%s\n%s\n' "$pairs" "$game_pairs" | sort -u | sed '/^$/d')
|
|
|
|
# The VC++ 2015-2022 runtime as its installers check for it, for each architecture and both registry
|
|
# views. The version is the newest the scripts above know, so any 2015-2022 bundle finds itself
|
|
# already installed and exits without asking for anything.
|
|
VCRT_MAJOR=14 VCRT_MINOR=51 VCRT_BUILD=36247
|
|
vcrt() {
|
|
local view arch
|
|
for view in 'Software' 'Software\\Wow6432Node'; do
|
|
for arch in x86 x64 arm64; do
|
|
printf '\n[%s\\\\Microsoft\\\\VisualStudio\\\\14.0\\\\VC\\\\Runtimes\\\\%s] %d\n' "$view" "$arch" "$1"
|
|
printf '"Bld"=dword:%08x\n"Installed"=dword:00000001\n"Major"=dword:%08x\n"Minor"=dword:%08x\n"Rbld"=dword:00000000\n' \
|
|
"$VCRT_BUILD" "$VCRT_MAJOR" "$VCRT_MINOR"
|
|
printf '"Version"="v%d.%d.%d.00"\n' "$VCRT_MAJOR" "$VCRT_MINOR" "$VCRT_BUILD"
|
|
done
|
|
done
|
|
}
|
|
|
|
# The stamp is the set of names, taken before the block below dates its keys: stamped from the
|
|
# dated block it never matched, and every prefix had the whole block appended again on every beat.
|
|
stamp=$(printf '%s vcrt %s.%s.%s' "$pairs" "$VCRT_MAJOR" "$VCRT_MINOR" "$VCRT_BUILD" | cksum)
|
|
|
|
printf -v now '%(%s)T' -1
|
|
block=$(printf '%s\n' "$pairs" | awk -F'\t' -v now="$now" '
|
|
{
|
|
path = $1
|
|
sub(/^HKEY_LOCAL_MACHINE\\\\/, "", path)
|
|
if (path == $1)
|
|
next
|
|
printf "\n[%s] %d\n\"%s\"=dword:00000001\n", path, now, $2
|
|
# The client writes these from 32-bit steam.exe, so its own copy lands under Wow6432Node;
|
|
# both spellings are seeded because the reader picks by its own word size.
|
|
# Joined rather than sub()stituted: gawk and mawk read backslashes in a replacement differently.
|
|
if (substr(path, 1, 10) != "Software\\\\")
|
|
next
|
|
printf "\n[%s] %d\n\"%s\"=dword:00000001\n", "Software\\\\Wow6432Node\\\\" substr(path, 11), now, $2
|
|
}
|
|
')
|
|
block="$block
|
|
$(vcrt "$now")"
|
|
|
|
# Proton builds a new prefix from its template, and the client runs the install scripts in that
|
|
# prefix moments later, so the template carries the markers too. Its date is kept: Proton reads a
|
|
# changed one as a new template and upgrades every prefix made from the old.
|
|
for reg in "$steam_root"/steamapps/common/Proton*/files/share/default_pfx*/system.reg \
|
|
/mnt/droiddeck-sd/steamapps/common/Proton*/files/share/default_pfx*/system.reg \
|
|
/root/Games/*/steamapps/common/Proton*/files/share/default_pfx*/system.reg \
|
|
"$steam_root"/compatibilitytools.d/*/files/share/default_pfx*/system.reg \
|
|
"$steam_root"/steamapps/compatdata/*/pfx/system.reg \
|
|
/mnt/droiddeck-sd/steamapps/compatdata/*/pfx/system.reg \
|
|
/root/Games/*/steamapps/compatdata/*/pfx/system.reg; do
|
|
[ -f "$reg" ] || continue
|
|
seeded=${reg%/*}/.droiddeck-redists
|
|
legacy=${reg%/*}/.bannerlator-redists
|
|
if [ -f "$legacy" ] && [ ! -f "$seeded" ]; then
|
|
mv -f "$legacy" "$seeded"
|
|
fi
|
|
have=
|
|
[ -f "$seeded" ] && read -r have < "$seeded"
|
|
[ "$have" = "$stamp" ] && continue
|
|
dated=$(mktemp) || continue
|
|
touch -r "$reg" "$dated"
|
|
if printf '%s\n' "$block" >>"$reg"; then
|
|
printf '%s\n' "$stamp" >"$seeded"
|
|
echo "== seeded redist markers into $reg"
|
|
fi
|
|
touch -r "$dated" "$reg"
|
|
rm -f "$dated"
|
|
done
|