mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-11 19:11:08 +00:00
fix: Steam can restart more than twice in a session (#754)
* fix: Steam can restart more than twice in a session Every exit 42 counted toward the cap that stops an update which will not install, and the count was never cleared, so the third restart of a session ended it however far apart they were. A client that ran for a minute before asking is not that loop: the count starts again. * fix: measure the client's run time as it exits The time spent collecting logs and checking FEX after the client exits counted toward its run, so a slow cleanup could make a quick exit 42 look like a long one and clear the count. --------- Co-authored-by: Kirk <12691869+KirkPatrickJunsay@users.noreply.github.com> Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
This commit is contained in:
1 parent
704e95edb3
commit
8f4e0ac011
2 files changed
+43
-2
No files matched your search
@@ -56,6 +56,12 @@ clear_stale_tmp() {
|
||||
}
|
||||
[ -z "${BL_INSIDE:-}" ] && clear_stale_tmp
|
||||
|
||||
steam_update_stuck() {
|
||||
[ "$1" -lt 60 ] || steam_updates=0
|
||||
steam_updates=$((steam_updates + 1))
|
||||
[ "$steam_updates" -ge 3 ]
|
||||
}
|
||||
|
||||
collect_steam_logs() {
|
||||
[ -n "${BL_DEBUG_DIR:-}" ] || return 0
|
||||
local steam_root=${XDG_DATA_HOME:-$HOME/.local/share}/Steam
|
||||
@@ -839,9 +845,11 @@ BUSCONF
|
||||
/usr/local/bin/droiddeck-steam-desktop-ui &
|
||||
desktop_ui_pid=$!
|
||||
fi
|
||||
steam_started=$SECONDS
|
||||
"$steam_root/steamrtarm64/steam" "${_bl_ui[@]}" "${_bl_cdp[@]}" "${_bl_lang[@]}" -clientbeta "$steam_channel" \
|
||||
-no-cef-sandbox -cef-ozone-platform=x11 "${_bl_cef[@]}" "$@"
|
||||
rc=$?
|
||||
steam_ran=$((SECONDS - steam_started))
|
||||
if [ -n "$desktop_ui_pid" ]; then
|
||||
kill "$desktop_ui_pid" 2>/dev/null || true
|
||||
wait "$desktop_ui_pid" 2>/dev/null || true
|
||||
@@ -876,8 +884,7 @@ BUSCONF
|
||||
continue
|
||||
fi
|
||||
[ "$rc" -eq 42 ] || break
|
||||
steam_updates=$((steam_updates + 1))
|
||||
if [ "$steam_updates" -ge 3 ]; then
|
||||
if steam_update_stuck "$steam_ran"; then
|
||||
echo "== steam: asked to restart for an update $steam_updates times and it is not installing; the session stops here rather than loop"
|
||||
break
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import re
|
||||
import subprocess
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
SESSION = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin/droiddeck-session"
|
||||
|
||||
|
||||
def stuck_function():
|
||||
match = re.search(r"^steam_update_stuck\(\) \{\n.*?^\}\n", SESSION.read_text(), re.M | re.S)
|
||||
return match.group(0) if match else None
|
||||
|
||||
|
||||
class SteamRestartCapTest(unittest.TestCase):
|
||||
def restarts(self, *seconds_up):
|
||||
function = stuck_function()
|
||||
self.assertIsNotNone(function, "droiddeck-session has no steam_update_stuck()")
|
||||
script = function + "steam_updates=0\nfor up in %s; do\n" % " ".join(map(str, seconds_up))
|
||||
script += " if steam_update_stuck \"$up\"; then echo stop; else echo restart; fi\ndone\n"
|
||||
return subprocess.run(["bash", "-c", script], capture_output=True, text=True, timeout=30,
|
||||
check=True).stdout.split()
|
||||
|
||||
def test_an_update_that_keeps_asking_at_once_is_stopped_on_the_third(self):
|
||||
self.assertEqual(["restart", "restart", "stop"], self.restarts(11, 13, 9))
|
||||
|
||||
def test_restarts_of_a_client_that_stayed_up_are_never_stopped(self):
|
||||
self.assertEqual(["restart"] * 5, self.restarts(75, 4000, 90, 600, 61))
|
||||
|
||||
def test_a_run_that_stayed_up_starts_the_count_again(self):
|
||||
self.assertEqual(["restart", "restart", "restart", "restart", "stop"], self.restarts(12, 10, 300, 14, 8))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user