From 0bb6e1cdc2aa6be54e22ff394b99121d4d2062fe Mon Sep 17 00:00:00 2001 From: arkon Date: Tue, 14 Apr 2020 17:13:45 -0400 Subject: [PATCH] Crash fixes --- app/src/main/java/eu/kanade/tachiyomi/App.kt | 11 +++++++++++ .../java/eu/kanade/tachiyomi/ui/main/MainActivity.kt | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/App.kt b/app/src/main/java/eu/kanade/tachiyomi/App.kt index 7809198e7..8400b3eed 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/App.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/App.kt @@ -3,6 +3,8 @@ package eu.kanade.tachiyomi import android.app.Application import android.content.Context import android.content.res.Configuration +import android.os.Build +import android.webkit.WebView import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleObserver import androidx.lifecycle.OnLifecycleEvent @@ -43,6 +45,14 @@ open class App : Application(), LifecycleObserver { LocaleHelper.updateConfiguration(this, resources.configuration) ProcessLifecycleOwner.get().lifecycle.addObserver(this) + + // Avoid sharing WebView instance across multiple processes + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + val processName = getProcessName() + if (packageName != processName) { + WebView.setDataDirectorySuffix(processName) + } + } } override fun attachBaseContext(base: Context) { @@ -56,6 +66,7 @@ open class App : Application(), LifecycleObserver { } @OnLifecycleEvent(Lifecycle.Event.ON_STOP) + @Suppress("unused") fun onAppBackgrounded() { val preferences: PreferencesHelper by injectLazy() if (preferences.lockAppAfter().getOrDefault() >= 0) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index ba3b489d3..35cb9153a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -59,13 +59,14 @@ class MainActivity : BaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + binding = MainActivityBinding.inflate(layoutInflater) + // Do not let the launcher create a new activity http://stackoverflow.com/questions/16283079 if (!isTaskRoot) { finish() return } - binding = MainActivityBinding.inflate(layoutInflater) setContentView(binding.root) setSupportActionBar(binding.toolbar)