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

+24
View File
@@ -19,6 +19,30 @@ def run_bash(script, env=None):
class ClientZramFocusTest(unittest.TestCase):
def test_the_hidden_epic_launcher_is_compressed_with_the_client(self):
with tempfile.TemporaryDirectory() as tmp:
proc = Path(tmp)
def task(pid, argv, env=()):
folder = proc / str(pid)
folder.mkdir()
(folder / 'cmdline').write_bytes(b''.join(arg.encode() + b'\0' for arg in argv))
(folder / 'environ').write_bytes(b''.join(item.encode() + b'\0' for item in env))
fex = '/s/FEX-Emu/usr/bin/FEX'
task(5000010, ['/s/steamrtarm64/steam', '-gamepadui'])
task(5000011, [fex, '/e/usr/bin/EpicGamesLauncher'], ['HOME=/root', 'DROIDDECK_EPIC_HIDDEN=1'])
task(5000012, [fex, './/lib/webkit2gtk-4.1/WebKitWebProcess', '4'], ['DROIDDECK_EPIC_HIDDEN=1', 'LANG=C'])
task(5000013, [fex, '/e/usr/bin/EpicGamesLauncher'], ['HOME=/root'])
task(5000014, ['/e/WebKitWebProcess', '4'], ['DROIDDECK_EPIC_HIDDEN=1'])
task(5000015, [fex, '/e/usr/bin/EpicGamesLauncher'], ['DROIDDECK_EPIC_HIDDEN=10'])
task(5000016, ['/s/reaper', 'SteamLaunch', 'AppId=413150', '--', 'game'])
source = function_source('bl_zram_scan').replace('/proc/[0-9]*', tmp + '/[0-9]*')
result = run_bash(source + '\nbl_zram_scan\necho "${_bl_pids[*]}|${_bl_others[*]}|$_bl_game|$_bl_apps"')
self.assertEqual(0, result.returncode, result.stderr)
self.assertEqual('', result.stderr)
self.assertEqual('5000010 5000011 5000012|5000013 5000014 5000015|1| 413150', result.stdout.strip())
def test_refocus_restarts_the_delay_and_game_exit_restores_a_packed_client(self):
source = SCRIPT.read_text()
start = source.index(' if [ "$_bl_game" = 1 ] && bl_game_focused; then')
+23
View File
@@ -326,6 +326,15 @@ class SignInHandoffTest(EpicTestCase):
self.assertEqual((None, None, "unix:abstract=a11y"),
(carried.get("NO_AT_BRIDGE"), carried.get("GTK_A11Y"), carried.get("AT_SPI_BUS_ADDRESS")))
def test_only_the_hidden_launcher_skips_the_store_and_fab_pages(self):
with mock.patch.dict(G, {"fex_environment": lambda fex, files, base: {}}):
visible = G["client_environment"]({}, None, None, ":0", "bus", "broker")
hidden = G["client_environment"]({}, None, None, ":2", "bus", "broker", hidden=True)
self.assertNotIn("DROIDDECK_EPIC_HIDDEN", visible)
self.assertNotIn("EGL_DISABLE_STORE_PREWARM", visible)
self.assertEqual(("1", "1"), (hidden.get("DROIDDECK_EPIC_HIDDEN"), hidden.get("EGL_DISABLE_STORE_PREWARM")))
self.assertEqual(visible["WEBKIT_SKIA_ENABLE_CPU_RENDERING"], hidden["WEBKIT_SKIA_ENABLE_CPU_RENDERING"])
def session(self):
session = G["Session"]("visible")
session.carried = True
@@ -906,6 +915,20 @@ class BrokerTest(EpicTestCase):
self.assertNotIn(G["STEAM_PRELOAD"], envs[0])
self.assertNotIn("LD_PRELOAD", envs[1])
def test_a_game_started_by_the_hidden_launcher_does_not_inherit_its_page_switches(self):
folder = self.tmp / "Fig"
folder.mkdir()
envs = []
def popen(command, env=None, cwd=None, start_new_session=False):
envs.append(env)
return mock.Mock(wait=mock.Mock(return_value=0))
with mock.patch.object(subprocess, "Popen", popen):
G["run_game"]({"exe": str(folder / "Fig.exe"), "args": []}, dict(G["HIDDEN_ENV"], PATH="/usr/bin"))
self.assertFalse(set(G["HIDDEN_ENV"]) & set(envs[0]))
self.assertEqual("/usr/bin", envs[0]["PATH"])
def test_an_owner_gone_ends_a_game_the_open_launcher_handed_to_steam(self):
broker, _ = self.broker("visible")
session = G["Session"]("visible")
+74
View File
@@ -0,0 +1,74 @@
import os
import platform
import shutil
import subprocess
import tempfile
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
SOURCE = ROOT / "tools/linuxfs/fex/webkitinput.c"
WEBKIT = r"""
#include <stdio.h>
#include <stdlib.h>
const char *g_getenv(const char *name) { return getenv(name); }
void webkit_web_view_load_uri(void *view, const char *uri) { (void)view; printf("%s\n", uri); }
"""
LOADER = r"""
void webkit_web_view_load_uri(void *view, const char *uri);
int main(int argc, char **argv) {
for (int i = 1; i < argc; i++) webkit_web_view_load_uri(0, argv[i]);
return 0;
}
"""
URIS = [
"https://www.fab.com",
"https://fab.com/listings/1",
"http://www.fab.com?x=1",
"https://www.fab.com:443/",
"https://store.epicgames.com/en-US/",
"https://www.fab.community/",
"https://notfab.com/",
"tauri://localhost",
]
@unittest.skipUnless(platform.machine() == "x86_64" and shutil.which("gcc"), "webkitinput is built for x86_64 guests")
class WebKitInputTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.tmp = Path(tempfile.mkdtemp())
(cls.tmp / "webkit.c").write_text(WEBKIT)
(cls.tmp / "loader.c").write_text(LOADER)
subprocess.run(["gcc", "-m64", "-shared", "-fPIC", "-O2", "-Wall", "-Wextra", "-nostdlib", "-fno-stack-protector",
"-fno-builtin", "-fvisibility=hidden", "-o", str(cls.tmp / "libwebkitinput.so"), str(SOURCE)], check=True)
subprocess.run(["gcc", "-shared", "-fPIC", "-o", str(cls.tmp / "libfakewebkit.so"), str(cls.tmp / "webkit.c")], check=True)
subprocess.run(["gcc", "-o", str(cls.tmp / "loader"), str(cls.tmp / "loader.c"), "-L" + str(cls.tmp),
"-Wl,--no-as-needed", "-lwebkitinput", "-lfakewebkit", "-ldl", "-Wl,-rpath," + str(cls.tmp)], check=True)
@classmethod
def tearDownClass(cls):
shutil.rmtree(cls.tmp, ignore_errors=True)
def load(self, hidden):
env = {k: v for k, v in os.environ.items() if k != "DROIDDECK_EPIC_HIDDEN"}
if hidden is not None:
env["DROIDDECK_EPIC_HIDDEN"] = hidden
result = subprocess.run([str(self.tmp / "loader")] + URIS, env=env, capture_output=True, text=True, timeout=10)
self.assertEqual(0, result.returncode, result.stderr)
return result.stdout.splitlines()
def test_the_hidden_launcher_loads_a_blank_page_for_fab(self):
self.assertEqual(["about:blank"] * 4 + URIS[4:], self.load("1"))
def test_the_visible_launcher_loads_every_page(self):
self.assertEqual(URIS, self.load(None))
self.assertEqual(URIS, self.load("0"))
self.assertEqual(URIS, self.load("10"))
if __name__ == "__main__":
unittest.main()