GetStream / stream-chat-android

:speech_balloon: Android Chat SDK ➜ Stream Chat API. UI component libraries for chat apps. Kotlin & Jetpack Compose messaging SDK for Android chat
https://getstream.io/chat/sdk/android/
Other
1.43k stars 268 forks source link

NullPointerException on MutableClientState.setUser #5202

Open donlan opened 5 months ago

donlan commented 5 months ago

Describe the bug

Crash tracks:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Class.isInterface()' on a null object reference
       at java.lang.Class.isAssignableFrom(Class.java:824)
       at java.lang.Class.isInstance(Class.java:774)
       at java.util.concurrent.atomic.AtomicReferenceFieldUpdater$AtomicReferenceFieldUpdaterImpl.accessCheck(AtomicReferenceFieldUpdater.java:421)
       at java.util.concurrent.atomic.AtomicReferenceFieldUpdater$AtomicReferenceFieldUpdaterImpl.get(AtomicReferenceFieldUpdater.java:479)
       at kotlinx.coroutines.flow.StateFlowSlot.makePending(StateFlow.kt:268)
       at kotlinx.coroutines.flow.StateFlowImpl.updateState(StateFlow.kt:345)
       at kotlinx.coroutines.flow.StateFlowImpl.setValue(StateFlow.kt:312)
       at io.getstream.chat.android.client.setup.state.internal.MutableClientState.setUser(MutableClientState.kt:95)
       at io.getstream.chat.android.client.ChatClient.handleEvent(ChatClient.kt:440)
       at io.getstream.chat.android.client.ChatClient.access$getEventMutex$p(ChatClient.kt)
       at io.getstream.chat.android.client.ChatClient.access$handleEvent(ChatClient.kt)
       at io.getstream.chat.android.client.ChatClient$1.onEvent(ChatClient.kt:372)
       at io.getstream.chat.android.client.utils.observable.SuspendSubscription$onNext$2.invokeSuspend(Subscriptions.kt:84)
       at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
       at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
       at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:111)
       at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:99)
       at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:802)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:706)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt)

SDK version

To Reproduce No idea. Crash reported from Firebase.

Expected behavior

Device:

image

Screenshots None.

JcMinarro commented 5 months ago

Hello @donlan This error comes from the Kotlinx Coroutines Library. Digging on their repository, they already have an opened issue related to it, and looks like the root cause is on the Android Runtime code, mainly on Android 12, 13 and 14 :( There is an issue on the Android Issues Tracker as well.