From 0d2e268dd59c333b1b96c2d139da7c2c5be81818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Resul=20=C3=96v=C3=BCr?= <92828257+ovurrsl@users.noreply.github.com> Date: Fri, 16 Oct 2026 16:50:06 +0300 Subject: [PATCH] fix: store background jobs log a failure instead of ending the app (#898) * fix: store background jobs log a failure instead of ending the app refresh, sign-out, uninstall and the EOS overlay cleanup ran on plain threads. An exception there reaches the crash handler, which ends the process. Run them through one helper that logs the failure; a failed uninstall also clears its row and calls onDone so the UI does not stay on uninstalling. * ci: run the build again The first run failed while installing packages (archive.debian.org returned 404 for libnsl-dev). Nothing in the change differs. --------- Co-authored-by: ovurrsl --- .../droiddeck/launcher/stores/StoresState.kt | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoresState.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoresState.kt index d353b2545e..6b99210e9e 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/StoresState.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/StoresState.kt @@ -71,7 +71,7 @@ object StoresState { fun refresh(context: Context) { val app = context.applicationContext com.droiddeck.launcher.stores.download.SavedQueue.restore(app) - Thread({ + background("stores-refresh") { val found = Store.entries.mapNotNull { store -> StoreAccounts.signedInAs(app, store)?.let { store to it } } val onDisk = StoreInstallRoot.gameFolders(app).mapNotNull { folder -> StoreGameSidecar.read(folder)?.takeIf { it.isInstalled }?.let { InstalledStoreGame(it, folder) } @@ -85,7 +85,7 @@ object StoresState { unfinished = partial engine = version } - }, "stores-refresh").start() + } } fun isSignedIn(store: Store): Boolean = accounts.containsKey(store) @@ -136,7 +136,7 @@ object StoresState { fun signOut(context: Context, store: Store) { val app = context.applicationContext - Thread({ + background("stores-signout") { backends[store]?.signOut(app) if (store == Store.GOG) com.droiddeck.launcher.stores.gog.GogComet.replaceAccount { StoreAccounts.clear(app, store) } else StoreAccounts.clear(app, store) @@ -144,7 +144,7 @@ object StoresState { accounts.remove(store); library.remove(store); status.remove(store); problems.remove(store) logLine("${store.label}: signed out") } - }, "stores-signout").start() + } } var openDownloads by mutableStateOf(false) @@ -199,7 +199,7 @@ object StoresState { val app = context.applicationContext val key = "${game.sidecar.store.id}:${game.sidecar.id}" uninstalling[key] = 0f - Thread({ + background("stores-uninstall", onFailure = { main.post { uninstalling.remove(key); onDone() } }) { runCatching { backends[game.sidecar.store]?.uninstall(app, game) } StoreInstalls.uninstall(app, game, progress = { f -> main.post { if (key in uninstalling) uninstalling[key] = f } }, removed = { main.post { @@ -208,7 +208,7 @@ object StoresState { } }) main.post(onDone) - }, "stores-uninstall").start() + } } @Volatile var libraryListener: (() -> Unit)? = null @@ -231,7 +231,7 @@ object StoresState { appContext = context.applicationContext StoreLogFiles.prune(context) val overlay = java.io.File(com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(context), "root/.local/share/droiddeck/epic-overlay") - if (overlay.exists()) Thread({ overlay.deleteRecursively(); Log.i(TAG, "removed the old EOS overlay download") }, "epic-overlay-cleanup").start() + if (overlay.exists()) background("epic-overlay-cleanup") { overlay.deleteRecursively(); Log.i(TAG, "removed the old EOS overlay download") } val app = context.applicationContext Thread({ runCatching { CloudSaves.uploadAllDirty(app, "recovery") } @@ -241,6 +241,21 @@ object StoresState { internal fun post(block: () -> Unit) = main.post(block) + /** + * A worker thread whose failure is logged. An uncaught exception on a plain Thread reaches the crash + * handler, which ends the whole app, and none of these jobs is worth that. + */ + private fun background(name: String, onFailure: () -> Unit = {}, block: () -> Unit) { + Thread({ + try { + block() + } catch (e: Throwable) { + Log.w(TAG, "$name failed", e) + runCatching(onFailure) + } + }, name).start() + } + private val CLOCK = SimpleDateFormat("HH:mm:ss.SSS", Locale.US) }