mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
fix(logs): app.log keeps the driver loader lines from the start of the session (#2593)
This commit is contained in:
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
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.droiddeck.launcher.core
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
class SessionLogCaptureTest {
|
||||
@Test fun captureStartsFromTheSessionFolderTime() {
|
||||
assertEquals(
|
||||
"/system/bin/logcat -v threadtime -T 1731100000.007 --pid=42",
|
||||
SessionLogCapture.command(42, 1_731_100_000_007L),
|
||||
)
|
||||
}
|
||||
|
||||
@Test fun withoutAStartTimeOnlyNewLinesAreCaptured() {
|
||||
assertEquals("/system/bin/logcat -v threadtime -T 1 --pid=42", SessionLogCapture.command(42, 0L))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import android.content.Context
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.annotation.Config
|
||||
import java.io.File
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28], manifest = Config.NONE)
|
||||
class SessionStartTimeTest {
|
||||
private lateinit var context: Context
|
||||
|
||||
@Before fun setUp() {
|
||||
context = RuntimeEnvironment.getApplication()
|
||||
SessionPaths.take()?.let { SessionPaths.release(context, it) }
|
||||
context.getSharedPreferences("session", Context.MODE_PRIVATE).edit().putBoolean("logs", false).commit()
|
||||
}
|
||||
|
||||
@After fun tearDown() {
|
||||
SessionPaths.take()?.let { SessionPaths.release(context, it) }
|
||||
context.getSharedPreferences("session", Context.MODE_PRIVATE).edit().remove("logs").commit()
|
||||
}
|
||||
|
||||
@Test fun theCurrentFolderKeepsTheTimeItWasMade() {
|
||||
val before = System.currentTimeMillis()
|
||||
val folder = SessionPaths.beginOrCurrent(context, "start-time")
|
||||
val after = System.currentTimeMillis()
|
||||
val started = SessionPaths.startedAt(folder)
|
||||
assertTrue(started in before..after)
|
||||
Thread.sleep(5)
|
||||
assertEquals(folder, SessionPaths.beginOrCurrent(context, "start-time"))
|
||||
assertEquals(started, SessionPaths.startedAt(folder))
|
||||
}
|
||||
|
||||
@Test fun otherAndEndedFoldersHaveNoStartTime() {
|
||||
val folder = SessionPaths.beginOrCurrent(context, "start-time")
|
||||
assertEquals(0L, SessionPaths.startedAt(File(folder.parentFile, "elsewhere")))
|
||||
SessionPaths.take()?.let { SessionPaths.release(context, it) }
|
||||
assertEquals(0L, SessionPaths.startedAt(folder))
|
||||
}
|
||||
|
||||
@Test fun theDriverLoaderLinesReachTheGraphicsReport() {
|
||||
val loader = "11-09 06:09:04.930 20010 24772 I hook_impl: hook_android_dlopen_ext: hook failed: failed to load custom driver: dlopen failed!"
|
||||
assertTrue(GraphicsReport.COMPOSITOR.containsMatchIn(loader))
|
||||
assertTrue(GraphicsReport.COMPOSITOR.containsMatchIn("11-09 06:09:04.931 20010 24772 E adrenotools: Couldn't preload the hook implementation"))
|
||||
assertFalse(GraphicsReport.COMPOSITOR.containsMatchIn("11-09 06:09:05.563 20010 24802 I SessionService: game thread hints: Odin 3 only"))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user