From 855f806f5699e0aef4705264e75788e7af13d7d6 Mon Sep 17 00:00:00 2001 From: self-similarity <137652432+self-similarity@users.noreply.github.com> Date: Sat, 19 Aug 2023 20:50:41 +0200 Subject: [PATCH] Safer init --- .../lagradost/cloudstream3/NativeCrashHandler.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/NativeCrashHandler.kt b/app/src/main/java/com/lagradost/cloudstream3/NativeCrashHandler.kt index 669c468f..e5cb2702 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/NativeCrashHandler.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/NativeCrashHandler.kt @@ -1,6 +1,7 @@ package com.lagradost.cloudstream3 import com.lagradost.cloudstream3.MainActivity.Companion.lastError +import com.lagradost.cloudstream3.mvvm.logError import com.lagradost.cloudstream3.plugins.PluginManager.checkSafeModeFile import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -28,8 +29,16 @@ object NativeCrashHandler { } fun initCrashHandler() { - System.loadLibrary("native-lib") - initNativeCrashHandler() + try { + System.loadLibrary("native-lib") + initNativeCrashHandler() + } catch (t: Throwable) { + // Make debug crash. + if (BuildConfig.DEBUG) throw t + logError(t) + return + } + initSignalPolling() } } \ No newline at end of file