stream-chat-android icon indicating copy to clipboard operation
stream-chat-android copied to clipboard

Random Crash on loading new channel

Open Chikrix opened this issue 6 years ago • 1 comments

I'm using version 4.2.4 and I get the following error when I open a channel detail and just stay on the screen after the channel is loaded and displayed. This doesn't happen everytime, it happens randomly

    kotlin.UninitializedPropertyAccessException: lateinit property me has not been initialized
        at io.getstream.chat.android.client.events.ConnectedEvent.getMe(ConnectedEvent.kt:10)
        at io.getstream.chat.android.client.ChatClientImpl$1.invoke(ChatClientImpl.kt:49)
        at io.getstream.chat.android.client.ChatClientImpl$1.invoke(ChatClientImpl.kt:29)
        at io.getstream.chat.android.client.utils.observable.Subscription.deliver(Subscription.kt:43)
        at io.getstream.chat.android.client.utils.observable.Subscription.onNext(Subscription.kt:23)
        at io.getstream.chat.android.client.utils.observable.ChatObservableImpl.onNext(ChatObservableImpl.kt:17)
        at io.getstream.chat.android.client.utils.observable.ChatObservableImpl$EventsMapper.onConnected(ChatObservableImpl.kt:93)
        at io.getstream.chat.android.client.socket.ChatSocketServiceImpl$updateState$3.run(ChatSocketServiceImpl.kt:174)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

My code for loading channel detail is

private fun loadChannelMessages(channelType: String, channelId: String) {
        if (channelVm == null) {
            channelVm = ViewModelProvider(this,
                    ChannelViewModelFactory(requireActivity().application, channelType, channelId))[ChannelViewModel::class.java]
        }
        chatDetailBinding.messageInput.setPermissionRequestListener(this)

        with(chatDetailBinding) {
            viewModel = channelVm
            messageList.setViewModel(channelVm, viewLifecycleOwner)
            messageInput.setViewModel(channelVm, viewLifecycleOwner)
        }

        val channelController = Chat.getInstance().client.channel(channelVm.channel.cid)
        channelController.events().subscribe {event ->
            when (event) {
                is ChannelDeletedEvent -> {
                    val previousUser = Chat.getInstance().client.getCurrentUser()
                    val notCurrentUser = event.user != previousUser
                    ...
                }
            }
        }
    }

Also, don't know if I should create a new card for this, but when I load the channel details and send a message, it shows on the left hand side instead of the right hand side (as the sender). Don't know what I'm doing wrong here

Chikrix avatar May 15 '20 15:05 Chikrix

The issue was indeed floating, sometimes backend sent unexpected socket event, so client was crashing. Fixed is in 4.2.9-beta-2.

but when I load the channel details and send a message That is UI issue. Currently it's under refactoring.

elevenetc avatar May 27 '20 18:05 elevenetc