perf(epic): keep the hidden launcher from loading its store and Fab pages, and compress it while games run (#1764)

* perf(epic): keep the hidden launcher from loading its store and Fab pages, and compress it while games run

The hidden Epic Games Launcher that stays up for sign-in while a game runs pre-warmed its store and Fab pages on a display nobody sees. Under FEX each page used about one core and grew past a gigabyte, crashing and reloading in a loop. The hidden instance now skips the store pre-warm, gets a blank page in place of Fab, and is paged out to zRAM with the Steam client once a game has focus. The visible launcher is unchanged.

* test(zram): keep the scan fixture PIDs above the kernel PID range
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-10-29 10:01:25 -04:00
1 parent 29c83976d0
commit 9f7f6d821d
7 files changed
+184 -8

No files matched your search

+1 -1
View File
@@ -45,7 +45,7 @@ lib=$out/x86_64/libwebkitinput.so
gcc -m64 -shared -fPIC -O2 -Wall -Wextra -nostdlib -fno-stack-protector -fno-builtin -fvisibility=hidden \
-o "$lib" tools/linuxfs/fex/webkitinput.c
strip --strip-unneeded "$lib"
if objdump -p "$lib" | grep -q NEEDED || [ "$(nm -D --undefined-only "$lib" | awk '{print $1 $2}' | LC_ALL=C sort | tr '\n' ' ')" != "wdlsym wg_object_get_data wg_object_set wg_object_set_data wg_type_check_instance_is_a wgtk_container_forall wgtk_container_get_type wgtk_key_snooper_install wgtk_widget_get_toplevel wwebkit_user_script_new wwebkit_user_script_unref wwebkit_web_view_get_type wwebkit_web_view_get_uri wwebkit_web_view_run_javascript " ]; then
if objdump -p "$lib" | grep -q NEEDED || [ "$(nm -D --undefined-only "$lib" | awk '{print $1 $2}' | LC_ALL=C sort | tr '\n' ' ')" != "wdlsym wg_getenv wg_object_get_data wg_object_set wg_object_set_data wg_type_check_instance_is_a wgtk_container_forall wgtk_container_get_type wgtk_key_snooper_install wgtk_widget_get_toplevel wwebkit_user_script_new wwebkit_user_script_unref wwebkit_web_view_get_type wwebkit_web_view_get_uri wwebkit_web_view_run_javascript " ]; then
echo "$lib must need nothing but weak GLib, GTK and WebKit calls" >&2
exit 1
fi
+43
View File
@@ -22,6 +22,7 @@ extern void webkit_web_view_run_javascript(void *view, const char *script, void
extern WebKitUserScript *webkit_user_script_new(const char *source, int frames, int time,
const char *const *allow, const char *const *block) __attribute__((weak));
extern void webkit_user_script_unref(WebKitUserScript *script) __attribute__((weak));
extern const char *g_getenv(const char *name) __attribute__((weak));
static const char NAV_SCRIPT[] =
"(()=>{let open=-1e9,arrowAt=-1e9,ringed=null,ringOutline='',ringOffset='',settleTimer=0,settling=false,redirecting=false;"
@@ -196,3 +197,45 @@ __attribute__((visibility("default"))) void webkit_user_content_manager_add_scri
}
next(manager, script);
}
static int starts(const char *text, const char *prefix)
{
while (*prefix)
if (*text++ != *prefix++)
return 0;
return 1;
}
static int fab_uri(const char *uri)
{
if (!uri)
return 0;
if (starts(uri, "https://"))
uri += 8;
else if (starts(uri, "http://"))
uri += 7;
else
return 0;
if (starts(uri, "www."))
uri += 4;
if (!starts(uri, "fab.com"))
return 0;
uri += 7;
return !*uri || *uri == '/' || *uri == '?' || *uri == '#' || *uri == ':';
}
static int hidden_launcher(void)
{
const char *hidden = g_getenv ? g_getenv("DROIDDECK_EPIC_HIDDEN") : 0;
return hidden && hidden[0] == '1' && !hidden[1];
}
__attribute__((visibility("default"))) void webkit_web_view_load_uri(void *view, const char *uri)
{
static void (*next)(void *, const char *);
if (!next && dlsym)
next = (void (*)(void *, const char *))dlsym((void *)-1l, "webkit_web_view_load_uri");
if (!next)
return;
next(view, hidden_launcher() && fab_uri(uri) ? "about:blank" : uri);
}
@@ -100,6 +100,10 @@ CLIENT_ENV = {
"JSC_useDFGJIT": "0",
"JSC_useFTLJIT": "0",
}
HIDDEN_ENV = {
"DROIDDECK_EPIC_HIDDEN": "1",
"EGL_DISABLE_STORE_PREWARM": "1",
}
KEPT_ENV = ("HOME", "USER", "LOGNAME", "LANG", "LANGUAGE", "LC_ALL", "LC_MESSAGES", "TZ", "XDG_RUNTIME_DIR", "BL_LAUNCH_DIR")
LAUNCH_VERBS = ("waitforexitandrun", "run", "runinprefix")
EPIC_ARGS = ("-auth_", "-epic")
@@ -725,7 +729,7 @@ def fex_environment(fex, files, env):
return result
def client_environment(base, fex, files, display, bus, broker, a11y=None):
def client_environment(base, fex, files, display, bus, broker, a11y=None, hidden=False):
env = {name: base[name] for name in KEPT_ENV if base.get(name)}
env.setdefault("HOME", HOME)
env.setdefault("LANG", "C.UTF-8")
@@ -734,6 +738,8 @@ def client_environment(base, fex, files, display, bus, broker, a11y=None):
env["DBUS_SESSION_BUS_ADDRESS"] = bus
env[BROKER_ENV] = broker
env.update(CLIENT_ENV)
if hidden:
env.update(HIDDEN_ENV)
if a11y:
for name in A11Y_OFF:
env.pop(name, None)
@@ -1248,7 +1254,7 @@ class Session:
path = broker_path()
self.broker = Broker(path, self.mode, base)
write_json(instance_file(), {"pid": os.getpid(), "mode": self.mode, "bus": bus, "broker": path})
env = client_environment(base, fex, files, display, bus, path, self.a11y)
env = client_environment(base, fex, files, display, bus, path, self.a11y, hidden=self.mode == "hidden")
self.command = [fex["bin"], os.path.join(app_dir, "AppRun")]
self.env = env
say("starting the Epic Games Launcher %s (%s, display %s)" % (current.get("app"), self.mode, display))
@@ -511,7 +511,7 @@ case $mode in
fi
if [ "${BL_ZRAM:-0}" = 1 ]; then
step "zRAM compression: on"
[ "${BL_ZRAM_CLIENT:-1}" = 1 ] || step "zRAM: Steam is not compressed while games run (turned off in Performance)"
[ "${BL_ZRAM_CLIENT:-1}" = 1 ] || step "zRAM: Steam and the hidden Epic Games Launcher are not compressed while games run (turned off in Performance)"
_bl_ram_cap=0
case ${BL_RAM_CAP_MB:-} in
''|0) ;;
@@ -521,16 +521,16 @@ case $mode in
(
bl_zram_scan() {
_bl_game=0 _bl_pids=() _bl_others=() _bl_apps=
local _d _c _args _name _a _id
local _d _c _args _name _a _id _fex
for _d in /proc/[0-9]*; do
[ "${_d##*/}" != "$BASHPID" ] || continue
_args=()
# Under FEX the program is FEX's first argument. AppId= is its own argument.
while IFS= read -r -d '' _c; do _args+=("$_c"); done 2>/dev/null < "$_d/cmdline" || true
[ "${#_args[@]}" -gt 0 ] || continue
_name=${_args[0]}
_name=${_args[0]} _fex=0
if [ "${#_args[@]}" -gt 1 ]; then
case ${_name##*/} in FEX|FEXInterpreter) _name=${_args[1]} ;; esac
case ${_name##*/} in FEX|FEXInterpreter) _name=${_args[1]} _fex=1 ;; esac
fi
case ${_name##*/} in
reaper)
@@ -545,7 +545,13 @@ case $mode in
done
;;
steam|steamwebhelper) _bl_pids+=("${_d##*/}") ;;
*) _bl_others+=("${_d##*/}") ;;
*)
if [ "$_fex" = 1 ] && grep -qz '^DROIDDECK_EPIC_HIDDEN=1$' "$_d/environ" 2>/dev/null; then
_bl_pids+=("${_d##*/}")
else
_bl_others+=("${_d##*/}")
fi
;;
esac
done
}