From 3d9383ce674dd4046b5f46eea70d5fddb61e193c Mon Sep 17 00:00:00 2001 From: arkon Date: Fri, 28 May 2021 22:34:26 -0400 Subject: [PATCH] Try to avoid some Webview-related crashes Related to #5218 --- app/src/main/java/eu/kanade/tachiyomi/App.kt | 7 +++++++ .../tachiyomi/network/interceptor/CloudflareInterceptor.kt | 1 + 2 files changed, 8 insertions(+) diff --git a/app/src/main/java/eu/kanade/tachiyomi/App.kt b/app/src/main/java/eu/kanade/tachiyomi/App.kt index ec7960a8bc..ff9fc2b958 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/App.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/App.kt @@ -9,6 +9,7 @@ import android.content.Intent import android.content.IntentFilter import android.content.res.Configuration import android.os.Build +import android.webkit.WebView import androidx.core.app.NotificationManagerCompat import androidx.core.content.getSystemService import androidx.lifecycle.Lifecycle @@ -56,6 +57,12 @@ open class App : Application(), LifecycleObserver, ImageLoaderFactory { Security.insertProviderAt(Conscrypt.newProvider(), 1) } + // Avoid potential crashes + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + val process = getProcessName() + if (packageName != process) WebView.setDataDirectorySuffix(process) + } + Injekt.importModule(AppModule(this)) setupAcra() diff --git a/app/src/main/java/eu/kanade/tachiyomi/network/interceptor/CloudflareInterceptor.kt b/app/src/main/java/eu/kanade/tachiyomi/network/interceptor/CloudflareInterceptor.kt index ab1666b222..2849d3ed2d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/network/interceptor/CloudflareInterceptor.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/network/interceptor/CloudflareInterceptor.kt @@ -153,6 +153,7 @@ class CloudflareInterceptor(private val context: Context) : Interceptor { webView?.stopLoading() webView?.destroy() + webView = null } // Throw exception if we failed to bypass Cloudflare