fix(logs): app.log keeps the driver loader lines from the start of the session (#2593)

This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-15 09:35:36 -05:00
1 parent 9c349e185e
commit 76aa3771b7
6 files changed
+89 -5

No files matched your search

@@ -18,7 +18,7 @@ object SessionLogCapture {
private var syncer: Thread? = null
@Synchronized
fun start(target: File) {
fun start(target: File, sinceMillis: Long) {
stop()
try {
val out = target.bufferedWriter()
@@ -28,7 +28,7 @@ object SessionLogCapture {
writer = out
this.target = target
pid = HostProcess.start(
"/system/bin/logcat -v threadtime -T 1 --pid=" + Process.myPid(),
command(Process.myPid(), sinceMillis),
null, target.parentFile, null,
) { line ->
synchronized(this) {
@@ -49,6 +49,11 @@ object SessionLogCapture {
}
}
internal fun command(pid: Int, sinceMillis: Long): String {
val since = if (sinceMillis > 0) "%d.%03d".format(java.util.Locale.US, sinceMillis / 1000, sinceMillis % 1000) else "1"
return "/system/bin/logcat -v threadtime -T $since --pid=$pid"
}
@Synchronized
fun stopFor(dir: File) {
val t = target ?: return
@@ -161,8 +161,8 @@ object GraphicsReport {
private fun read(path: String): String? = FileUtils.readString(File(path))?.trim()?.takeIf { it.isNotEmpty() }
/** The compositor's driver lines from the app's own log. */
private val COMPOSITOR = Regex(
"""vk_present|waylandcomp|vk_loader|compositor|vkCreateDevice|extension|adrenotools|TurnipDriver|""" +
internal val COMPOSITOR = Regex(
"""vk_present|waylandcomp|vk_loader|compositor|vkCreateDevice|extension|adrenotools|hook_impl|TurnipDriver|""" +
"""graphics driver|display driver|DD_PRESENT_FAULT|SystemVulkan|vkbridge|VkBridge|mali_gralloc|panvk|PanVK|radv|MESA|native buffer|first frame|present|""" +
"""lsfg|FrameGen|device gates|AAudio|directaudio|pulse|gralloc|dma.?buf|modifier|import""",
RegexOption.IGNORE_CASE,
@@ -23,6 +23,9 @@ object SessionPaths {
@Volatile
private var ended: File? = null
@Volatile
private var startedAt = 0L
@Synchronized
fun beginOrCurrent(context: Context, label: String? = null): File {
dir?.let { if (it.isDirectory) return it }
@@ -38,6 +41,7 @@ object SessionPaths {
var made = File(parent, "$day-${"%02d".format(Locale.US, number)}-$what")
while (made.exists()) made = File(parent, "$day-${"%02d".format(Locale.US, ++number)}-$what")
EnhancedDiagnostics.clearRecordFor(context, made)
startedAt = System.currentTimeMillis()
if (!made.isDirectory && !made.mkdirs()) Log.e(TAG, "could not create $made")
dir = made
if (enhanced && !EnhancedDiagnostics.consumeInto(context, made)) {
@@ -49,6 +53,8 @@ object SessionPaths {
fun current(): File? = dir
fun startedAt(folder: File): Long = if (dir == folder) startedAt else 0L
fun currentSessionLogsRetained(context: Context): Boolean =
dir?.let { it.parentFile == SessionFiles.logDirectory(context) } ?: true
@@ -916,7 +916,7 @@ class SessionService : Service() {
if (EnhancedDiagnostics.isActive(this, sessionDir)) SessionEvents.record("diagnostics.enhanced", mapOf("schema" to 1))
DeviceReport.write(this, File(sessionDir, "device.txt"), SessionState.mode)
NetworkReport.write(this, File(sessionDir, "network.txt"))
SessionLogCapture.start(File(sessionDir, "app.log"))
SessionLogCapture.start(File(sessionDir, "app.log"), SessionPaths.startedAt(sessionDir))
MemoryLog.start()
return sessionDir
}