From d39fd02d0479d164a2d9a54c6892892cf840aa27 Mon Sep 17 00:00:00 2001 From: The412Banner Date: Tue, 22 Sep 2026 11:24:05 -0400 Subject: [PATCH] An ending session takes its log folder with it; the session replacing it gets its own Handing off from the desktop, the new session claimed the folder the desktop was still finishing, and the desktop's collector then stopped the new session's app.log capture. The folder is taken from the shared slot as the session stops and handed to its collector; the next session's beginOrCurrent finds the slot empty and makes a new folder. --- .../launcher/session/SessionPaths.kt | 19 +++++++++++++++---- .../launcher/session/SessionService.kt | 6 +++--- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/steamdeck/launcher/session/SessionPaths.kt b/app/src/main/java/com/steamdeck/launcher/session/SessionPaths.kt index 9f5f1518ae..55c5f99f01 100644 --- a/app/src/main/java/com/steamdeck/launcher/session/SessionPaths.kt +++ b/app/src/main/java/com/steamdeck/launcher/session/SessionPaths.kt @@ -51,16 +51,27 @@ object SessionPaths { /** The current session's folder, or null between sessions. */ fun current(): File? = dir + /** + * The ending session takes its folder with it: the next session (one that replaces this one + * in place) then claims a folder of its own instead of sharing, and this one's collector + * finishes the folder it was handed. Called on the main thread as the session stops. + */ + @Synchronized + fun take(): File? { + val ended = dir + dir = null + return ended + } + /** A file in the current session's folder, or null between sessions. */ fun file(name: String): File? = dir?.let { File(it, name) } /** Let the next session claim a new folder. Called when a session ends. */ @Synchronized fun release(context: Context, ended: File) { - // Only the session that owns the folder lets go of it: the next session may have claimed - // its own by the time the last one's collecting thread gets here. - if (dir != ended) return - dir = null + // Only the session that owns the folder lets go of it (take() usually has already): the + // next session may have claimed its own by the time the last one's collector gets here. + if (dir == ended) dir = null // A folder kept in the cache was never meant to outlive its session. if (ended != null && ended.path.startsWith(context.cacheDir.path)) { com.steamdeck.launcher.core.FileUtils.delete(ended) diff --git a/app/src/main/java/com/steamdeck/launcher/session/SessionService.kt b/app/src/main/java/com/steamdeck/launcher/session/SessionService.kt index 4579be15fa..ba41a0972b 100644 --- a/app/src/main/java/com/steamdeck/launcher/session/SessionService.kt +++ b/app/src/main/java/com/steamdeck/launcher/session/SessionService.kt @@ -99,8 +99,7 @@ class SessionService : Service() { * which is when they matter. The collecting itself is [SessionArtifacts], shared with the * crash handler and the next-start sweep so a folder is finished whichever way it ends. */ - private fun collectSessionArtifacts() { - val dir = SessionPaths.current() ?: return + private fun collectSessionArtifacts(dir: File) { try { SessionArtifacts.collect(this, dir, "session stopped") } finally { @@ -554,7 +553,8 @@ class SessionService : Service() { // every Steam log line by line - 42 files on one measured run - and waiting for logcat to // dump the crash buffer. That was about four and a half seconds of blocked main thread, // and Android ANR'd the app for it: the desktop session that would not let go. - Thread({ collectSessionArtifacts() }, "session-collect").start() + val ended = SessionPaths.take() + if (ended != null) Thread({ collectSessionArtifacts(ended) }, "session-collect").start() components.reversed().forEach { try { it.stop()