From 4399db47164555b57d505491bb173a7a556a97ad Mon Sep 17 00:00:00 2001 From: guohaomin1995-dev Date: Wed, 25 Nov 2026 05:17:17 +0800 Subject: [PATCH] fix(loading): show the arm64 Steam client's update progress in every language (#2651) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(loading): show the arm64 Steam client's update progress in every language The arm64 bootstrapper writes its progress straight into session.log in the client's language and with thousands separators, e.g. "正在下载更新 (已下载 184,557,共 573,070 KB)" or "Downloading update (184,557 of 573,070 KB)". UPDATE_PROGRESS only matched the forwarded x86-64 form without separators, so the loading screen stayed on "Waiting for Steam's first frame" with no percentage for the whole ~570 MB first update. Users took that for a hang and cancelled; after two starts the installer's repair wiped the partial download, so it started over each time. Accept separators, and fall back to the bootstrapper's language-independent "Set percent complete: N" line. * chore: drop the added comment * fix(loading): a zero or post-extract percent line no longer reads as a download * fix(loading): an unknown percent ends the earlier download percent * fix(session): ignore out-of-range percents and clear a percent after an unknown one --------- Co-authored-by: guohaomin1995-dev <321670510+guohaomin1995-dev@users.noreply.github.com> Co-authored-by: maxjivi05 --- .../launcher/session/LoadingState.kt | 35 +++++++-- .../session/LoadingStateUpdateTest.kt | 74 +++++++++++++++++++ 2 files changed, 102 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/session/LoadingState.kt b/app/src/main/java/com/droiddeck/launcher/session/LoadingState.kt index 6e6cfdac61..453e2c4ecd 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/LoadingState.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/LoadingState.kt @@ -67,6 +67,8 @@ class LoadingState(context: Context, private val steam: Boolean = true) { private class Line(val line: String, val percent: Int, val topic: Topic, val readable: Boolean) + private var scriptStep: Line? = null + private fun read(context: Context, log: File?): Line? { if (log == null || !log.isFile) return null val text = try { @@ -89,6 +91,7 @@ class LoadingState(context: Context, private val steam: Boolean = true) { var clientDownloadAt = -1 var clientDownload: String? = null var clientPercent = -1 + var unknownAt = -1 var offset = 0 for (line in text.split('\n')) { val at = offset @@ -103,16 +106,34 @@ class LoadingState(context: Context, private val steam: Boolean = true) { } } else { val m = UPDATE_PROGRESS.find(line) + val p = if (m == null && steam) UPDATE_PERCENT.find(line) else null if (m != null) { downloadAt = at - val done = m.groupValues[1].toLong() - val total = maxOf(1L, m.groupValues[2].toLong()) + val done = m.groupValues[1].replace(",", "").toLong() + val total = maxOf(1L, m.groupValues[2].replace(",", "").toLong()) downloadPercent = (done * 100 / total).toInt() + } else if (p != null) { + val percent = p.groupValues[1].toIntOrNull() ?: continue + if (percent < 0) { + downloadAt = -1 + unknownAt = at + } else if (percent > 0 && applyingAt <= stepAt) { + downloadAt = at + downloadPercent = percent.coerceAtMost(100) + } } else if (steam && UPDATE_APPLYING.matches(line)) { applyingAt = at } } } + val stepLine = when { + clientDownloadAt == stepAt && clientDownload != null -> Line( + context.getString(com.droiddeck.launcher.R.string.loadstate_steam_client, clientDownload), clientPercent, + Topic.STEAM, readable = true, + ) + stepText != null -> Line(stepText, -1, topicOf(stepText, steam), readableScriptStep(stepText)) + else -> null + }?.also { scriptStep = it } return when { applyingAt > stepAt && applyingAt > downloadAt -> Line( context.getString(com.droiddeck.launcher.R.string.loadstate_steam_update_applying), -1, @@ -122,11 +143,10 @@ class LoadingState(context: Context, private val steam: Boolean = true) { context.getString(com.droiddeck.launcher.R.string.loadstate_steam_update, downloadPercent), downloadPercent, Topic.STEAM, readable = true, ) - clientDownloadAt == stepAt && clientDownload != null -> Line( - context.getString(com.droiddeck.launcher.R.string.loadstate_steam_client, clientDownload), clientPercent, - Topic.STEAM, readable = true, + stepLine != null -> stepLine + unknownAt >= 0 -> scriptStep ?: Line( + context.getString(com.droiddeck.launcher.R.string.loadstate_starting), -1, Topic.SESSION, readable = false, ) - stepText != null -> Line(stepText, -1, topicOf(stepText, steam), readableScriptStep(stepText)) else -> null } } @@ -166,7 +186,8 @@ class LoadingState(context: Context, private val steam: Boolean = true) { } private const val TAIL_BYTES = 48L * 1024 - private val UPDATE_PROGRESS = Regex("""Downloading update \((\d+) of (\d+) KB\)""") + private val UPDATE_PROGRESS = Regex("""Downloading update \(([\d,]+) of ([\d,]+) KB\)""") + private val UPDATE_PERCENT = Regex("""^\[[^\]]+\] Set percent complete: (-?\d+)\s*$""") private val UPDATE_APPLYING = Regex("""^\s*(?:\[[^\]]+\]\s*)*(?:Extracting package|Installing update)\.\.\.\s*$""") private val INSTALL_COUNT = Regex("""downloading Steam: (\S+) \((\d+)/(\d+)\)""") private val INSTALL_MEGABYTES = Regex("""^, (\d+) of (\d+) MB""") diff --git a/app/src/test/java/com/droiddeck/launcher/session/LoadingStateUpdateTest.kt b/app/src/test/java/com/droiddeck/launcher/session/LoadingStateUpdateTest.kt index 0ef4ebaeeb..30c273969c 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/LoadingStateUpdateTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/LoadingStateUpdateTest.kt @@ -76,6 +76,80 @@ class LoadingStateUpdateTest { assertEquals(LoadingState.Topic.DESKTOP, state.topic) } + @Test fun bootstrapperProgressWithThousandsSeparatorsIsRead() { + val state = read("[2026-11-15 11:58:51] Downloading update (184,557 of 573,070 KB)...") + assertEquals(32, state.percent) + assertEquals("Downloading the Steam client update · 32%", state.step) + } + + @Test fun translatedBootstrapperProgressUsesItsPercentLine() { + val state = read( + "[2026-11-15 11:58:51] 正在下载更新 (已下载 184,557,共 573,070 KB)...", + "[2026-11-15 11:58:51] Set status message: 正在下载更新 (已下载 184,557,共 573,070 KB)...", + "[2026-11-15 11:58:51] Set percent complete: 32", + ) + assertEquals(32, state.percent) + assertEquals(LoadingState.Topic.STEAM, state.topic) + assertTrue(state.readable) + } + + @Test fun anUnknownPercentDoesNotLookLikeProgress() { + val state = read("[2026-11-15 11:53:37] Set percent complete: -1") + assertEquals(-1, state.percent) + } + + @Test fun aVerificationOnlyPassKeepsTheScriptStep() { + val state = read( + "[2026-11-15 11:53:36] Set percent complete: 0", + "[2026-11-15 11:53:37] Set percent complete: -1", + "[2026-11-15 11:53:37] Verifying installation...", + ) + assertEquals("starting the Steam client", state.step) + assertEquals(-1, state.percent) + } + + @Test fun aPercentLineDoesNotReplaceApplyingInTheSameStep() { + assertApplying(read("Extracting package...", "[2026-11-15 11:58:52] Set percent complete: 100")) + } + + @Test fun anUnknownPercentEndsAnEarlierPercent() { + val state = read( + "[2026-11-15 11:58:51] Set percent complete: 40", + "[2026-11-15 11:58:52] Set percent complete: -1", + ) + assertEquals("starting the Steam client", state.step) + assertEquals(-1, state.percent) + } + + @Test fun aPercentLineCountsAgainAfterANewStep() { + val state = read( + "Installing update...", + "== STEP 12:00:03 starting the Steam client", + "[2026-11-15 11:58:51] Set percent complete: 40", + ) + assertEquals(40, state.percent) + } + + @Test fun aPercentOutsideTheIntRangeIsIgnored() { + val state = read( + "[2026-11-15 11:58:51] Set percent complete: 40", + "[2026-11-15 11:58:52] Set percent complete: 2147483648", + ) + assertEquals(40, state.percent) + } + + @Test fun anUnknownPercentClearsTheDisplayedPercentAfterTheStepLeavesTheTail() { + val context = RuntimeEnvironment.getApplication() + val log = log("[2026-11-15 11:58:51] Set percent complete: 40") + val state = LoadingState(context) + state.update(context, log) + assertEquals(40, state.percent) + log.appendText("\n" + "Loading cached metrics\n".repeat(4096) + "[2026-11-15 11:58:52] Set percent complete: -1") + state.update(context, log) + assertEquals(-1, state.percent) + assertEquals("starting the Steam client", state.step) + } + @Test fun anExistingLoadingStateFollowsUpdatesAcrossPolls() { val context = RuntimeEnvironment.getApplication() val log = log("Downloading update (100 of 100 KB)")