Fix hard crash loop for unreachable servers
It should be noted that this is a band-aid fix for deeper underlying issues. The code as-was would attempt a login on every init, including when apps like Mihon would recover from the first crash by going to their global crash handler activity. This usually happened whenever a user would be unable to connect to their Kavita instance (server not up, different/no networks, etc) and left the user unable to fix the issue by removing the broken API URL or uninstalling the extension through the app's menus. It doesn't matter if the Kavita instance that is unreachable is disabled in the extension settings, the crash will still occur because the login is performed in the init block, which is called regardless of an extension's specific enable/disable state (to be able to display settings, etc).
This commit is contained in:
@@ -2587,10 +2587,8 @@ class Kavita(private val suffix: String = "") : ConfigurableSource, UnmeteredSou
|
|||||||
try {
|
try {
|
||||||
Log.d(LOG_TAG, "Starting Kavita extension initialization")
|
Log.d(LOG_TAG, "Starting Kavita extension initialization")
|
||||||
|
|
||||||
// First attempt login with timeout
|
|
||||||
val loginJob = async { doLogin() }
|
|
||||||
try {
|
try {
|
||||||
loginJob.await()
|
doLogin()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e(LOG_TAG, "Login failed during initialization", e)
|
Log.e(LOG_TAG, "Login failed during initialization", e)
|
||||||
initializationError = e
|
initializationError = e
|
||||||
|
|||||||
Reference in New Issue
Block a user