diff --git a/app/src/main/java/com/github/libretube/util/ExceptionHandler.kt b/app/src/main/java/com/github/libretube/util/ExceptionHandler.kt index e6ab250df..b521ce167 100644 --- a/app/src/main/java/com/github/libretube/util/ExceptionHandler.kt +++ b/app/src/main/java/com/github/libretube/util/ExceptionHandler.kt @@ -1,11 +1,17 @@ package com.github.libretube.util +import android.os.Looper import com.github.libretube.helpers.PreferenceHelper class ExceptionHandler( private val defaultExceptionHandler: Thread.UncaughtExceptionHandler? ) : Thread.UncaughtExceptionHandler { override fun uncaughtException(thread: Thread, exc: Throwable) { + // if the exception is not on the main thread, the app is still functional and responsive + // hence the app doesn't have to be quit fully + // work around for Cronet spawning different threads with uncaught Exception when used with Coil + if (thread.id != Looper.getMainLooper().thread.id) return + // save the error log PreferenceHelper.saveErrorLog(exc.stackTraceToString()) // throw the exception with the default exception handler to make the app crash