From 9cb1ef5db7e37ad97b4691b1f0fbb1f8af3e42d4 Mon Sep 17 00:00:00 2001 From: Sergey Sozinov Date: Thu, 11 Apr 2024 10:57:08 +0300 Subject: [PATCH 1/2] MBX-3295: fixed dead lock --- sdk/src/main/java/cloud/mindbox/mobile_sdk/Mindbox.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sdk/src/main/java/cloud/mindbox/mobile_sdk/Mindbox.kt b/sdk/src/main/java/cloud/mindbox/mobile_sdk/Mindbox.kt index 5bcfe6e52..b20179d5c 100644 --- a/sdk/src/main/java/cloud/mindbox/mobile_sdk/Mindbox.kt +++ b/sdk/src/main/java/cloud/mindbox/mobile_sdk/Mindbox.kt @@ -95,6 +95,8 @@ object Mindbox : MindboxLog { private val mutex = Mutex() + private val inAppMutex = Mutex() + private var firstInitCall: Boolean = true /** @@ -522,7 +524,7 @@ object Mindbox : MindboxLog { if (activity != null && lifecycleManager.isCurrentActivityResumed) { inAppMessageManager.registerCurrentActivity(activity) mindboxScope.launch { - mutex.withLock { + inAppMutex.withLock { firstInitCall = false inAppMessageManager.listenEventAndInApp() inAppMessageManager.initLogs() @@ -576,7 +578,7 @@ object Mindbox : MindboxLog { ) if (firstInitCall) { mindboxScope.launch { - mutex.withLock { + inAppMutex.withLock { InitializeLock.await(InitializeLock.State.SAVE_MINDBOX_CONFIG) if (!firstInitCall) return@launch firstInitCall = false From ab762cbdf0f459cc7a60412e9d7de783072d5ece Mon Sep 17 00:00:00 2001 From: Sergey Sozinov Date: Thu, 11 Apr 2024 12:26:25 +0300 Subject: [PATCH 2/2] MBX-3295: removed InitializeLock from inAppMutex --- sdk/src/main/java/cloud/mindbox/mobile_sdk/Mindbox.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/src/main/java/cloud/mindbox/mobile_sdk/Mindbox.kt b/sdk/src/main/java/cloud/mindbox/mobile_sdk/Mindbox.kt index b20179d5c..004759c0a 100644 --- a/sdk/src/main/java/cloud/mindbox/mobile_sdk/Mindbox.kt +++ b/sdk/src/main/java/cloud/mindbox/mobile_sdk/Mindbox.kt @@ -578,8 +578,8 @@ object Mindbox : MindboxLog { ) if (firstInitCall) { mindboxScope.launch { + InitializeLock.await(InitializeLock.State.SAVE_MINDBOX_CONFIG) inAppMutex.withLock { - InitializeLock.await(InitializeLock.State.SAVE_MINDBOX_CONFIG) if (!firstInitCall) return@launch firstInitCall = false inAppMessageManager.listenEventAndInApp()