@@ -20,8 +20,9 @@ import com.duckduckgo.app.global.exception.UncaughtExceptionRepository
2020import com.duckduckgo.app.global.exception.UncaughtExceptionSource
2121import com.duckduckgo.app.statistics.store.OfflinePixelCountDataStore
2222import kotlinx.coroutines.Dispatchers
23- import kotlinx.coroutines.runBlocking
24- import kotlinx.coroutines.withContext
23+ import kotlinx.coroutines.GlobalScope
24+ import kotlinx.coroutines.NonCancellable
25+ import kotlinx.coroutines.launch
2526
2627class AlertingUncaughtExceptionHandler (
2728 private val originalHandler : Thread .UncaughtExceptionHandler ,
@@ -31,14 +32,12 @@ class AlertingUncaughtExceptionHandler(
3132
3233 override fun uncaughtException (t : Thread ? , originalException : Throwable ? ) {
3334
34- // block until the exception has been fully processed
35- runBlocking {
36- withContext( Dispatchers . IO ) {
37- uncaughtExceptionRepository.recordUncaughtException(originalException, UncaughtExceptionSource . GLOBAL )
38- offlinePixelCountDataStore.applicationCrashCount + = 1
39- }
35+ GlobalScope .launch( Dispatchers . IO + NonCancellable ) {
36+ uncaughtExceptionRepository.recordUncaughtException(originalException, UncaughtExceptionSource . GLOBAL )
37+ offlinePixelCountDataStore.applicationCrashCount + = 1
38+
39+ // wait until the exception has been fully processed before propagating exception
40+ originalHandler.uncaughtException(t, originalException)
4041 }
41- originalHandler.uncaughtException(t, originalException)
4242 }
43-
4443}
0 commit comments