mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-25 07:46:01 +00:00
fix(logs): Share logs includes RPCS3's own log from the session (#3130)
This commit is contained in:
1 parent
a573f8b14f
commit
33bdc75a99
5 files changed
+130
-11
No files matched your search
@@ -935,7 +935,7 @@ internal object EnhancedSessionLogShare {
|
||||
|
||||
private fun category(entry: String): Category {
|
||||
val value = entry.lowercase(Locale.US)
|
||||
if (value.startsWith("battlenet/") || value.startsWith("stores/") || value.startsWith("tools/") ||
|
||||
if (value.startsWith("battlenet/") || value.startsWith("stores/") || value.startsWith("tools/") || value.startsWith("rpcs3/") ||
|
||||
value.contains("droiddeck-esync/") || GAME_LOG.matches(value.substringAfterLast('/')) ||
|
||||
listOf("proton", "wine", "dxvk", "vkd3d", "battle.net", "game-debug").any(value::contains)) return Category.GAMES
|
||||
if (listOf("wayland", "gamescope", "xwayland", "vulkan", "gpu", "mesa", "egl", "glx", "drm", "compositor", "frame-trace").any(value::contains)) return Category.GRAPHICS
|
||||
@@ -950,6 +950,7 @@ internal object EnhancedSessionLogShare {
|
||||
"frame-trace.log", "process-trace.log", "game-lifecycle.log", "launches.log", "tools.tsv", "wanted.tsv", "prefixes.json",
|
||||
"battlenet.log", "spawned.log", "flatpak-install.log", "cef_log.txt", "cef_log.previous.txt",
|
||||
"console_log.txt", "webhelper_js.txt", "controller_support.txt", "systemperfmanager.txt",
|
||||
"rpcs3", "RPCS3.log",
|
||||
)
|
||||
private val KNOWN_COMPONENT_PATTERNS = listOf(
|
||||
Regex("[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{2,}-[a-z0-9-]{1,24}"),
|
||||
|
||||
@@ -75,6 +75,7 @@ object SessionArtifacts {
|
||||
LogRedactor.learnFromRuntime(LinuxRuntime.rootDir(context))
|
||||
val record = Record(dir)
|
||||
copySteamLogs(context, dir, record, steamArch)
|
||||
copyRpcs3Log(context, dir, record)
|
||||
VacDiagnostics.collect(context, dir)
|
||||
SessionLogCapture.dumpCrashBuffer(File(dir, "crash.log"))
|
||||
SessionLogCapture.dumpMemoryPressure(File(dir, "memory-pressure.log"))
|
||||
@@ -321,6 +322,9 @@ object SessionArtifacts {
|
||||
runCatching { File(dir, CLIENT_FILE).readText().trim() }.getOrNull()?.takeIf { it == "arm64" || it == "x86_64" }
|
||||
|
||||
private const val LOG_MARKS = "steam-log-marks.txt"
|
||||
private const val RPCS3_LOG_MARKS = "rpcs3-log-marks.txt"
|
||||
private const val RPCS3_LOGS = "root/.cache/rpcs3"
|
||||
private const val RPCS3_LOG = "RPCS3.log"
|
||||
private const val MAX_STEAM_LOG = 8L * 1024 * 1024
|
||||
private const val HEAD = 4096L
|
||||
|
||||
@@ -328,11 +332,19 @@ object SessionArtifacts {
|
||||
private class CopyResult(val files: List<File>, val failed: Boolean, val deferred: Boolean)
|
||||
|
||||
fun markSteamLogs(dir: File, logs: File) {
|
||||
val lines = logs.listFiles { f -> f.isFile }?.mapNotNull { f ->
|
||||
logs.listFiles { f -> f.isFile }?.let { markLogs(dir, LOG_MARKS, it.toList()) }
|
||||
}
|
||||
|
||||
fun markRpcs3Log(dir: File, root: File) {
|
||||
markLogs(dir, RPCS3_LOG_MARKS, listOf(File(root, "$RPCS3_LOGS/$RPCS3_LOG")).filter { it.isFile })
|
||||
}
|
||||
|
||||
private fun markLogs(dir: File, marks: String, files: List<File>) {
|
||||
val lines = files.mapNotNull { f ->
|
||||
val size = f.length()
|
||||
head(f, size)?.let { "$size\t$it\t${f.name}" }
|
||||
} ?: return
|
||||
runCatching { File(dir, LOG_MARKS).writeText(lines.joinToString("") { "$it\n" }) }
|
||||
}
|
||||
runCatching { File(dir, marks).writeText(lines.joinToString("") { "$it\n" }) }
|
||||
}
|
||||
|
||||
private fun head(f: File, length: Long): String? = runCatching {
|
||||
@@ -348,8 +360,8 @@ object SessionArtifacts {
|
||||
java.security.MessageDigest.getInstance("SHA-1").digest(buf).joinToString("") { "%02x".format(it) }
|
||||
}.getOrNull()
|
||||
|
||||
private fun steamLogMarks(dir: File): List<Mark>? = runCatching {
|
||||
File(dir, LOG_MARKS).readLines().mapNotNull { line ->
|
||||
private fun logMarks(dir: File, marks: String): List<Mark>? = runCatching {
|
||||
File(dir, marks).readLines().mapNotNull { line ->
|
||||
val parts = line.split('\t', limit = 3)
|
||||
parts.getOrNull(0)?.toLongOrNull()?.let { size -> parts.getOrNull(1)?.let { Mark(size, it) } }
|
||||
}
|
||||
@@ -371,11 +383,32 @@ object SessionArtifacts {
|
||||
val logs = File(steamArch?.let { SessionPrefs.steamRoot(context, it) } ?: SessionPrefs.activeSteamRoot(context), "logs")
|
||||
if (!logs.isDirectory) return
|
||||
val out = File(dir, "steam").apply { mkdirs() }
|
||||
val result = copySessionLogsResult(logs, dir, out) { stopWhenSessionStarts && SessionState.running }
|
||||
addCopied(record, copySessionLogsResult(logs, dir, out) { stopWhenSessionStarts && SessionState.running })
|
||||
Log.i(TAG, "collected ${out.listFiles()?.size ?: 0} Steam log(s), scrubbed, into $out")
|
||||
}
|
||||
|
||||
private fun copyRpcs3Log(context: Context, dir: File, record: Record, stopWhenSessionStarts: Boolean = false) {
|
||||
val out = File(dir, "rpcs3")
|
||||
val logs = File(LinuxRuntime.rootDir(context), RPCS3_LOGS)
|
||||
val copied = copyRpcs3LogResult(logs, dir, out) { stopWhenSessionStarts && SessionState.running } ?: return
|
||||
addCopied(record, copied)
|
||||
if (copied.files.isNotEmpty()) Log.i(TAG, "collected RPCS3's log, scrubbed, into $out")
|
||||
}
|
||||
|
||||
internal fun copyRpcs3Log(logs: File, dir: File, out: File): List<File> = copyRpcs3LogResult(logs, dir, out) { false }?.files.orEmpty()
|
||||
|
||||
private fun copyRpcs3LogResult(logs: File, dir: File, out: File, shouldStop: () -> Boolean): CopyResult? {
|
||||
if (!File(dir, RPCS3_LOG_MARKS).isFile || !File(logs, RPCS3_LOG).isFile) return null
|
||||
out.mkdirs()
|
||||
val result = copySessionLogsResult(logs, dir, out, marksName = RPCS3_LOG_MARKS, accept = { it.name == RPCS3_LOG }, shouldStop = shouldStop)
|
||||
if (result.files.isEmpty()) out.delete()
|
||||
return result
|
||||
}
|
||||
|
||||
private fun addCopied(record: Record, result: CopyResult) {
|
||||
result.files.forEach { dst -> record.files[dst] = Scrubbed(dst.length(), dst.lastModified()) }
|
||||
record.failed = record.failed || result.failed
|
||||
record.deferred = record.deferred || result.deferred
|
||||
Log.i(TAG, "collected ${out.listFiles()?.size ?: 0} Steam log(s), scrubbed, into $out")
|
||||
}
|
||||
|
||||
internal fun copySessionLogs(
|
||||
@@ -383,20 +416,22 @@ object SessionArtifacts {
|
||||
dir: File,
|
||||
out: File,
|
||||
openWriter: (File) -> Writer = { it.bufferedWriter() },
|
||||
): List<File> = copySessionLogsResult(logs, dir, out, openWriter) { false }.files
|
||||
): List<File> = copySessionLogsResult(logs, dir, out, openWriter = openWriter) { false }.files
|
||||
|
||||
private fun copySessionLogsResult(
|
||||
logs: File,
|
||||
dir: File,
|
||||
out: File,
|
||||
marksName: String = LOG_MARKS,
|
||||
accept: (File) -> Boolean = { true },
|
||||
openWriter: (File) -> Writer = { it.bufferedWriter() },
|
||||
shouldStop: () -> Boolean,
|
||||
): CopyResult {
|
||||
val marks = steamLogMarks(dir)
|
||||
val marks = logMarks(dir, marksName)
|
||||
val copied = ArrayList<File>()
|
||||
var failed = false
|
||||
var deferred = false
|
||||
val sources = logs.listFiles { f -> f.isFile } ?: return CopyResult(copied, true, false)
|
||||
val sources = logs.listFiles { f -> f.isFile && accept(f) } ?: return CopyResult(copied, true, false)
|
||||
for (src in sources) {
|
||||
if (shouldStop()) {
|
||||
failed = true
|
||||
@@ -567,6 +602,7 @@ object SessionArtifacts {
|
||||
steamArch = recordedClient(dir),
|
||||
stopWhenSessionStarts = stopWhenSessionStarts,
|
||||
)
|
||||
copyRpcs3Log(context, dir, record, stopWhenSessionStarts)
|
||||
if (!record.deferred && (!stopWhenSessionStarts || !SessionState.running)) {
|
||||
if (!record.failed && VacDiagnostics.collect(context, dir)) {
|
||||
try {
|
||||
|
||||
@@ -1070,6 +1070,7 @@ class SessionService : Service() {
|
||||
guest.addAll(GpuStatsComponent.guestEnv(LinuxRuntime.rootDir(this)))
|
||||
guest.add("GLIBC_TUNABLES=glibc.pthread.rseq=0:glibc.malloc.top_pad=16777216")
|
||||
if (SessionState.mode == MODE_STEAM) guest.add("DD_MANGOAPP=" + (if (SessionPrefs.mangoapp(this)) "1" else "0"))
|
||||
SessionPaths.current()?.let { SessionArtifacts.markRpcs3Log(it, LinuxRuntime.rootDir(this)) }
|
||||
SessionState.steamClientArch = if (steamHere) SessionPrefs.steamClientArch(this) else null
|
||||
SessionState.steamClientArch?.let { arch ->
|
||||
guest.add("DD_STEAM_CLIENT_ARCH=$arch")
|
||||
|
||||
Reference in new issue
Block a user