firebase-kotlin-sdk icon indicating copy to clipboard operation
firebase-kotlin-sdk copied to clipboard

IOS Firestore Transaction IncorrectDereferenceException

Open alperenbabagil opened this issue 3 years ago • 2 comments
trafficstars

When I use firestore transaction I get an Uncaught Kotlin exception. Full output is like this:

Uncaught Kotlin exception: kotlin.native.IncorrectDereferenceException: illegal attempt to access non-shared <object>@325c7a8 from other thread
    at 0...

I used it in a suspend function launched in a coroutine that uses Dispatchers.Main. Even if its lambda is empty I get the same error. The usage is simply like this:

fireStore.runTransaction {
    ...
}

My environment and library versions are:

IOS simulator - iPhone 13 - IOS 15

kotlin version = 1.5.30 coroutinesVersion = "1.5.2-native-mt" fireStoreVersion = "1.4.3"

alperenbabagil avatar Dec 28 '21 17:12 alperenbabagil

IncorrectDereferenceException most of the time means that you've run the KMM code from non-main thread inside iOS.

suntrix avatar Mar 31 '22 01:03 suntrix

IncorrectDereferenceException most of the time means that you've run the KMM code from non-main thread inside iOS.

Thanks for the reply, but I'm calling it from the main thread in IOS

alperenbabagil avatar Apr 19 '22 12:04 alperenbabagil