mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
* fix: Red Dead Redemption 2 launches again, its Vulkan runtime installer is left to run droiddeck-seed-redists marked every process in every game's install script as already run, Red Dead Redemption 2's VulkanRT-1.1.108.0 installer included. Steam's compat config for the game says nativevulkanloader, so Proton loads vulkan-1.dll native only, and Khronos' loader is in the prefix only once that installer has run. Without it the Rockstar launcher starts RDR2.exe and it exits with STATUS_DLL_NOT_FOUND (0xc0000135) before it opens a window. A Vulkan runtime installer is now left out of the seeding, and a marker an earlier seeding wrote for one comes out of each prefix and Proton template once (dates kept), so the client runs the installer on the next launch. The installer finishes in a few seconds under FEX. * fix: Steam's screensaver no longer covers a running game The client's defaults show screensavers while a game runs, after 300 s on AC power without a button press - and a held stick or trigger is no press. Red Dead Redemption 2's intro runs longer than that: the slideshow covered the game, and the button that woke it reached the game too (B asked to quit to the desktop). Customization/Screensaver/WhileInGame is seeded "0" in config.vdf once, like the UI scale and native resolution, so turning it back on in Settings stays the user's choice. On the RedMagic: 18 minutes from the last button press through the intro and riding, focus never left the game and no screensaver was created. * fix: Rockstar's hidden launcher no longer takes cores from its game The Rockstar Games Launcher keeps drawing its Chromium interface (SocialClubHelper.exe: renderers, and a GPU process compositing through DXVK) for as long as the game runs, hidden behind it - and Wine passes Chromium's priorities on, so those threads ran above the game's (the GPU process at nice -10), across every core. With Red Dead Redemption 2 in front that was 1.3 to 2.5 cores under FEX for a page nobody sees. droiddeck-launcher-cores follows gamescope's focus from the agent's focus.json: while a game window has it, every SocialClubHelper thread runs on the last core of the slowest cluster at nice 19; when the launcher's own window has focus again each thread gets its own mask and priority back (also on exit). Stopping the helpers would not hold - proot resumes a stopped tracee. Started for Steam sessions; BL_LAUNCHER_CORES=0 turns it off. RedMagic, RDR2 all Low, riding at the thermal limit, same spot and session: released 46.5 fps, 1% low 27.5, p99 31.8 ms, CPU 89%, 2200 MHz; held 48.7 fps, 1% low 32.6, p99 27.6 ms, CPU 79%, 2638 MHz. * fix: sessions clean up what earlier ones left in /tmp The guest's /tmp is a directory in the rootfs that no boot ever empties, and Android ends sessions by killing them. Every session left a /tmp/mangohud.XXXXXXXX (mktemp, never removed), and the Steam client, its web helper, Chromium apps, dbus-run-session, AppImage runs and KDE their own temporary files and sockets: 1,422 entries on the RedMagic. mangoapp's config is now one fixed file rewritten each session, and the session's first pass sweeps each kind of leftover while nothing that could own one is running, with a single find. On the device that cleared 1,391 entries over two sessions, leaving 38.
221 lines
8.1 KiB
Python
221 lines
8.1 KiB
Python
import json
|
|
import os
|
|
from pathlib import Path
|
|
import runpy
|
|
import tempfile
|
|
import unittest
|
|
|
|
|
|
BIN = Path(__file__).resolve().parents[1] / 'linuxfs/overlay/usr/local/bin'
|
|
MODULE = runpy.run_path(str(BIN / 'droiddeck-launcher-cores'))
|
|
Holder = MODULE['Holder']
|
|
Governor = MODULE['Governor']
|
|
NICE = MODULE['NICE']
|
|
|
|
HELPER = 'C:\\Program Files\\Rockstar Games\\Social Club\\SocialClubHelper.exe'
|
|
LAUNCHER = 'C:\\Program Files\\Rockstar Games\\Launcher\\Launcher.exe'
|
|
GAME = 'S:\\steamapps\\common\\Red Dead Redemption 2\\RDR2.exe'
|
|
ALL = set(range(8))
|
|
|
|
|
|
class FakeCores:
|
|
"""Per-thread masks and priorities, with every change recorded."""
|
|
|
|
def __init__(self):
|
|
self.state = {}
|
|
self.calls = []
|
|
|
|
def own(self):
|
|
return set(ALL)
|
|
|
|
def get(self, tid):
|
|
if tid not in self.state:
|
|
raise ProcessLookupError(tid)
|
|
return self.state[tid]
|
|
|
|
def set(self, tid, cpus, nice):
|
|
if tid not in self.state:
|
|
raise ProcessLookupError(tid)
|
|
self.calls.append((tid, set(cpus), nice))
|
|
self.state[tid] = (set(cpus), nice)
|
|
|
|
|
|
class LauncherCoresTest(unittest.TestCase):
|
|
def setUp(self):
|
|
temp = tempfile.TemporaryDirectory()
|
|
self.addCleanup(temp.cleanup)
|
|
self.root = Path(temp.name)
|
|
self.proc = self.root / 'proc'
|
|
self.proc.mkdir()
|
|
cpufreq = self.root / 'cpu'
|
|
for cpu in ALL: # 0-5 one cluster, 6-7 the fast one
|
|
(cpufreq / f'cpu{cpu}/cpufreq').mkdir(parents=True)
|
|
(cpufreq / f'cpu{cpu}/cpufreq/cpuinfo_max_freq').write_text('3532800\n' if cpu < 6 else '4320000\n')
|
|
self.cores = FakeCores()
|
|
self.holder = Holder(self.proc, cpufreq, self.cores)
|
|
self.focus = self.root / 'focus.json'
|
|
self.now = 0.0
|
|
self.governor = Governor(self.focus, self.holder, clock=lambda: self.now)
|
|
|
|
def process(self, pid, argv0, threads=(), cpus=ALL, nice=0):
|
|
directory = self.proc / str(pid)
|
|
(directory / 'task').mkdir(parents=True)
|
|
(directory / 'cmdline').write_bytes(argv0.encode() + b'\0--type=renderer\0')
|
|
for tid in (pid, *threads):
|
|
self.thread(pid, tid, cpus, nice)
|
|
|
|
def thread(self, pid, tid, cpus=ALL, nice=0):
|
|
(self.proc / str(pid) / 'task' / str(tid)).mkdir()
|
|
self.cores.state[tid] = (set(cpus), nice)
|
|
|
|
def end(self, pid):
|
|
for tid in os.listdir(self.proc / str(pid) / 'task'):
|
|
self.cores.state.pop(int(tid), None)
|
|
(self.proc / str(pid) / 'task' / tid).rmdir()
|
|
(self.proc / str(pid) / 'task').rmdir()
|
|
(self.proc / str(pid) / 'cmdline').unlink()
|
|
(self.proc / str(pid)).rmdir()
|
|
|
|
def focus_on(self, pid, app=1174180):
|
|
stamp = getattr(self, 'stamp', 1_000_000_000) + 1_000_000_000
|
|
self.stamp = stamp
|
|
self.focus.write_text(json.dumps({
|
|
'focusedApp': app, 'focusedWindow': 0x200001,
|
|
'focusableWindows': [{'window': 0x100001, 'appId': 769, 'pid': 9},
|
|
{'window': 0x200001, 'appId': app, 'pid': pid}]}))
|
|
os.utime(self.focus, ns=(stamp, stamp))
|
|
|
|
def held(self, tid):
|
|
return self.cores.state[tid] == ({5}, NICE)
|
|
|
|
def test_helpers_held_on_the_slow_clusters_last_core_while_the_game_has_focus(self):
|
|
self.process(100, LAUNCHER, (101,))
|
|
self.process(200, HELPER, (201, 202), nice=-2)
|
|
self.process(300, HELPER, (301,))
|
|
self.process(400, GAME, (401,))
|
|
self.focus_on(400)
|
|
self.governor.tick()
|
|
for tid in (200, 201, 202, 300, 301):
|
|
self.assertTrue(self.held(tid), tid)
|
|
for tid in (100, 101, 400, 401):
|
|
self.assertEqual((ALL, 0), self.cores.state[tid])
|
|
|
|
def test_launcher_focus_gives_each_thread_its_own_mask_and_priority_back(self):
|
|
self.process(100, LAUNCHER)
|
|
self.process(200, HELPER, (201,), cpus={0, 1, 2, 3}, nice=-2)
|
|
self.cores.state[201] = ({6, 7}, 4)
|
|
self.process(400, GAME)
|
|
self.focus_on(400)
|
|
self.governor.tick()
|
|
self.assertTrue(self.held(201))
|
|
self.focus_on(100)
|
|
self.governor.tick()
|
|
self.assertEqual(({0, 1, 2, 3}, -2), self.cores.state[200])
|
|
self.assertEqual(({6, 7}, 4), self.cores.state[201])
|
|
self.assertEqual({}, self.holder.held)
|
|
|
|
def test_nothing_is_touched_before_a_game_has_focus(self):
|
|
self.process(100, LAUNCHER)
|
|
self.process(200, HELPER)
|
|
self.process(9, '/root/.local/share/Steam/steamrtarm64/steam')
|
|
self.governor.tick() # no focus file yet
|
|
self.focus_on(9, app=769)
|
|
self.governor.tick()
|
|
self.focus_on(100)
|
|
self.governor.tick()
|
|
self.assertEqual([], self.cores.calls)
|
|
|
|
def test_a_launcher_left_after_its_game_stays_held_behind_the_client(self):
|
|
self.process(200, HELPER)
|
|
self.process(400, GAME)
|
|
self.process(9, '/root/.local/share/Steam/steamrtarm64/steam')
|
|
self.focus_on(400)
|
|
self.governor.tick()
|
|
self.end(400)
|
|
self.focus_on(9, app=769)
|
|
self.governor.tick()
|
|
self.assertTrue(self.held(200))
|
|
|
|
def test_a_thread_inheriting_the_hold_is_released_to_what_its_process_had(self):
|
|
self.process(200, HELPER, cpus={0, 1, 2, 3, 4, 5}, nice=1)
|
|
self.process(400, GAME)
|
|
self.focus_on(400)
|
|
self.governor.tick()
|
|
# A new thread, and a new helper process the held one started: both born held.
|
|
self.thread(200, 203, {5}, NICE)
|
|
self.process(500, HELPER, (501,), cpus={5}, nice=NICE)
|
|
self.now += 10
|
|
self.governor.tick()
|
|
self.focus_on(200)
|
|
self.governor.tick()
|
|
for tid in (200, 203, 500, 501):
|
|
self.assertEqual(({0, 1, 2, 3, 4, 5}, 1), self.cores.state[tid], tid)
|
|
|
|
def test_a_held_thread_the_program_moves_back_is_held_again_on_the_next_look(self):
|
|
self.process(200, HELPER, (201,))
|
|
self.process(400, GAME)
|
|
self.focus_on(400)
|
|
self.governor.tick()
|
|
self.cores.state[201] = (ALL, -5) # the program raised a thread's priority itself
|
|
self.now += 5
|
|
self.governor.tick()
|
|
self.assertFalse(self.held(201)) # not looked at again before the rescan
|
|
self.now += 5
|
|
self.governor.tick()
|
|
self.assertTrue(self.held(201))
|
|
self.focus_on(200)
|
|
self.governor.tick()
|
|
self.assertEqual((ALL, 0), self.cores.state[201]) # its first state, not the program's
|
|
|
|
def test_a_steady_hold_is_not_rewritten(self):
|
|
self.process(200, HELPER, (201,))
|
|
self.process(400, GAME)
|
|
self.focus_on(400)
|
|
self.governor.tick()
|
|
calls = len(self.cores.calls)
|
|
for _ in range(5):
|
|
self.now += 10
|
|
self.governor.tick()
|
|
self.assertEqual(calls, len(self.cores.calls))
|
|
|
|
def test_threads_that_end_are_skipped_and_ended_helpers_forgotten(self):
|
|
self.process(200, HELPER, (201,))
|
|
self.process(300, HELPER)
|
|
self.process(400, GAME)
|
|
del self.cores.state[201] # ended between the listing and the call
|
|
self.focus_on(400)
|
|
self.governor.tick()
|
|
self.assertNotIn(201, self.holder.held[200])
|
|
self.end(300)
|
|
self.now += 10
|
|
self.governor.tick()
|
|
self.assertEqual([200], list(self.holder.held))
|
|
|
|
def test_stop_releases(self):
|
|
self.process(200, HELPER)
|
|
self.process(400, GAME)
|
|
self.focus_on(400)
|
|
self.governor.tick()
|
|
with self.assertRaises(SystemExit):
|
|
self.governor.stop()
|
|
self.assertEqual((ALL, 0), self.cores.state[200])
|
|
|
|
def test_unreadable_focus_is_ignored(self):
|
|
self.process(200, HELPER)
|
|
self.focus.write_text('{"focusedApp": 1174')
|
|
self.governor.tick()
|
|
self.focus.write_text('[]')
|
|
os.utime(self.focus, ns=(5, 5))
|
|
self.governor.tick()
|
|
self.assertEqual([], self.cores.calls)
|
|
|
|
def test_window_without_a_pid_is_left_alone(self):
|
|
self.process(200, HELPER)
|
|
self.focus.write_text(json.dumps({'focusedApp': 1174180, 'focusedWindow': 7, 'focusableWindows': []}))
|
|
self.governor.tick()
|
|
self.assertEqual([], self.cores.calls)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|