[Android] DebugLogs: fix ANR

Duncan McNamara git at videolan.org
Tue Jul 7 12:39:13 UTC 2026


vlc-android | branch: master | Duncan McNamara <dcn.mcnamara at gmail.com> | Thu Jun 18 17:58:22 2026 +0200| [76a75cacffdce39a4876bf2cadd66c65e144d508] | committer: Duncan McNamara

DebugLogs: fix ANR

The stop locks logcat while the UI is still trying to read, that way we
release it before joining.

> https://code.videolan.org/videolan/vlc-android/commit/76a75cacffdce39a4876bf2cadd66c65e144d508
---

 application/vlc-android/src/org/videolan/vlc/DebugLogService.kt | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/DebugLogService.kt b/application/vlc-android/src/org/videolan/vlc/DebugLogService.kt
index 360770e6b1..f609bbf95d 100644
--- a/application/vlc-android/src/org/videolan/vlc/DebugLogService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/DebugLogService.kt
@@ -179,10 +179,13 @@ class DebugLogService : Service(), Logcat.Callback, Runnable {
         sendMessage(MSG_STARTED, null)
     }
 
-    @Synchronized
     fun stop() {
-        logcat!!.stop()
-        logcat = null
+        val stoppedLogcat = synchronized(this) {
+            val localLogcat = logcat ?: return
+            logcat = null
+            localLogcat
+        }
+        stoppedLogcat.stop()
         sendMessage(MSG_STOPPED, null)
         stopForegroundCompat()
         stopSelf()



More information about the Android mailing list