Skip to content

Improve crash log dumping#148

Merged
Goooler merged 5 commits intotrunkfrom
improve-log-dump
Apr 27, 2026
Merged

Improve crash log dumping#148
Goooler merged 5 commits intotrunkfrom
improve-log-dump

Conversation

@Goooler
Copy link
Copy Markdown
Owner

@Goooler Goooler commented Apr 27, 2026

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors crash-log collection so the crash screen can display logs via a lazily-started StateFlow instead of an explicit UI-triggered loadLogs() call.

Changes:

  • Removed the standalone dumpCrash() helper and inlined logcat dumping into AppCrashedViewModel.
  • Reworked crash log loading to be driven by a flow { ... }.stateIn(...) pipeline.
  • Simplified AppCrashedScreen by removing LaunchedEffect-based manual loading.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
app/src/main/kotlin/com/github/kr328/clash/log/util/SystemLogcat.kt Deletes the old logcat-dump utility (functionality moved).
app/src/main/kotlin/com/github/kr328/clash/crash/vm/AppCrashedViewModel.kt Implements lazy crash-log loading via StateFlow and adds a local dumpCrash() using Runtime.exec.
app/src/main/kotlin/com/github/kr328/clash/crash/ui/AppCrashedScreen.kt Removes the manual loadLogs() trigger and relies on collecting the StateFlow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/src/main/kotlin/com/github/kr328/clash/crash/vm/AppCrashedViewModel.kt Outdated
Comment thread app/src/main/kotlin/com/github/kr328/clash/crash/vm/AppCrashedViewModel.kt Outdated
Comment thread app/src/main/kotlin/com/github/kr328/clash/crash/vm/AppCrashedViewModel.kt Outdated
Comment thread app/src/main/kotlin/com/github/kr328/clash/crash/vm/AppCrashedViewModel.kt Outdated
Goooler and others added 3 commits April 27, 2026 11:31
…ViewModel.kt

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ViewModel.kt

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +37 to +52
val process = ProcessBuilder(*crashDumpCommand).redirectErrorStream(true).start()
val result =
process.inputStream
.bufferedReader()
.readLines()
.filterNot { it.startsWith("------") }
.joinToString("\n")
val exitCode = process.waitFor()

if (exitCode != 0) {
error("logcat exited with code $exitCode: ${result.trim()}")
}
result.trim()
}
}
}

Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

process.inputStream...useLines { ... } and process.waitFor() are both unbounded waits. If logcat -d stalls/hangs on a device, the crash screen will never receive an emission (it will stay at the initial "" state). Consider enforcing a timeout (e.g., waitFor(timeout, ...)) and ensuring the process is destroyed in finally on timeout/exception so the UI can always proceed.

Copilot uses AI. Check for mistakes.
@Goooler Goooler enabled auto-merge (squash) April 27, 2026 03:40
@Goooler Goooler merged commit 290c54e into trunk Apr 27, 2026
3 checks passed
@Goooler Goooler deleted the improve-log-dump branch April 27, 2026 03:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants