Closed jetaggart closed 4 years ago
Hmm, it's even stranger. My implementation for ChannelActivity
works fine with livestream
channel types, but fails in various ways for these 1-on-1 channels. I went through it again and received this stack trace consistently and can't repro the first stack:
E/AndroidRuntime: FATAL EXCEPTION: DefaultDispatcher-worker-4
Process: io.getstream.thestream, PID: 32075
java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter role
at io.getstream.chat.android.client.models.Member.<init>(Unknown Source:7)
at io.getstream.chat.android.client.models.Member.<init>(Member.kt:19)
at io.getstream.chat.android.livedata.entity.MemberEntity.toMember(MemberEntity.kt:41)
at io.getstream.chat.android.livedata.entity.ChannelEntity.toChannel(ChannelEntity.kt:98)
at io.getstream.chat.android.livedata.ChatDomainImpl.selectAndEnrichChannels$library_release(ChatDomainImpl.kt:657)
at io.getstream.chat.android.livedata.ChatDomainImpl$selectAndEnrichChannels$2.invokeSuspend(Unknown Source:12)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
The createPrivateChannel
method creates the channel just fine, it only crashes when viewing.
Might be dependent on this: https://github.com/GetStream/stream-chat-android/issues/474
Just found this issue: https://github.com/GetStream/stream-chat-android/issues/481
Hi @psylinse i'm going to look into this and get back to you
I just received this error again on 4.2.7
:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: io.getstream.thestream, PID: 3231
java.lang.IllegalStateException: Missing channel config for channel type messaging
at io.getstream.chat.android.livedata.ChatDomainImpl.getChannelConfig(ChatDomainImpl.kt:682)
at io.getstream.chat.android.livedata.controller.ChannelControllerImpl.getConfig(ChannelControllerImpl.kt:164)
at io.getstream.chat.android.livedata.controller.ChannelControllerImpl.toChannel(ChannelControllerImpl.kt:1015)
at com.getstream.sdk.chat.viewmodel.ChannelViewModel.getChannel(ChannelViewModel.java:148)
at com.getstream.sdk.chat.view.MessageListView.getChannel(MessageListView.java:294)
at com.getstream.sdk.chat.view.MessageListView.setAdapterWithStyle(MessageListView.java:124)
at com.getstream.sdk.chat.view.MessageListView.setViewModel(MessageListView.java:282)
at io.getstream.thestream.ChannelActivity$initViewModel$1.onChanged(ChannelActivity.kt:61)
at io.getstream.thestream.ChannelActivity$initViewModel$1.onChanged(ChannelActivity.kt:17)
However, it's inconsistent. I wonder if this is a race condition with how I'm logging in. I don't wait for the setUser
call to come back, I just assume it's good. Would that explain this?
I think it's a race condition. In ChatDomainImpl
there's an initJob
which runs async. If I manage to get to a chat room before this has ran, it'll fail to find any configs. However, it's not with setUser
and is instead on ChatDomain
which I don't see a way of waiting for that to fully initialize.
you can await the initJob. What's the full flow for triggering this? I see 2 solutions:
a. Wait for the init job to complete (on the other hand, on first load the DB will be empty, so this doesn't help) b. reevaluate if we need these configs to begin with (perhaps just default to enabling the features)
Has the same troubles on 4.2.9-beta
I/Chat:ChatDomain EventHandler: Handling event of type notification.added_to_channel for cid messaging:721, event batch size is 1
E/AndroidRuntime: FATAL EXCEPTION: DefaultDispatcher-worker-1
java.lang.IllegalStateException: Missing channel config for channel type messaging
at io.getstream.chat.android.livedata.ChatDomainImpl.getChannelConfig(ChatDomainImpl.kt:687)
at io.getstream.chat.android.livedata.controller.ChannelControllerImpl.getConfig(ChannelControllerImpl.kt:164)
at io.getstream.chat.android.livedata.controller.ChannelControllerImpl.toChannel(ChannelControllerImpl.kt:1030)
at io.getstream.chat.android.livedata.controller.QueryChannelsControllerImpl.addChannels(QueryChannelsControllerImpl.kt:237)
at io.getstream.chat.android.livedata.controller.QueryChannelsControllerImpl.addChannelIfFilterMatches(QueryChannelsControllerImpl.kt:79)
at io.getstream.chat.android.livedata.controller.QueryChannelsControllerImpl.handleEvent(QueryChannelsControllerImpl.kt:86)
at io.getstream.chat.android.livedata.controller.QueryChannelsControllerImpl.handleEvents(QueryChannelsControllerImpl.kt:63)
at io.getstream.chat.android.livedata.EventHandlerImpl.handleEventsInternal$livedata_release(EventHandlerImpl.kt:255)
at io.getstream.chat.android.livedata.EventHandlerImpl$handleEventsInternal$1.invokeSuspend(Unknown Source:12)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
Hi @maxmaxandr do you have some more details on how you replicate this? Does it always crash on notification.added_to_channel? I would expect the configs for messaging
chat type to already be loaded at this point...
@tschellenbach I don't know if this helps but here is a fully working repo with the issue: https://github.com/psylinse/the-stream-android/blob/3-channels
If you log in quickly and get to a chat view, I believe it's a race between ChatDomain
loading channel configs and the user getting to that screen.
Hi @maxmaxandr do you have some more details on how you replicate this? Does it always crash on notification.added_to_channel? I would expect the configs for
messaging
chat type to already be loaded at this point...
I can't catch the reason of this crash. It happens sometimes, maybe there are race conditions while chat is initializing. For me, It happens when the application has cold start.
Alright, I understand the issue and it's actually a pretty easy fix. Will keep you posted.
So there are scenarios where we don't have the configs available yet.
In the master branch of livedata we're now falling back to some sensible defaults for the channel config.
Fixed in 4.2.10-beta https://github.com/GetStream/stream-chat-android/releases/tag/4.2.10-beta
Version:
4.2.6
Source code: https://github.com/psylinse/the-stream-androidIssue with viewing a one-on-one channel with latest:
Here's the code that creates it:
And here's my
ChannelActivity
: