nextcloud / nextcloud/talk-android

Issues with conversationMessageListener not being added/added multiple times

Open
#6,126 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

2. developing bug
Dominant language
Kotlin
Stars
739
Forks
321
Avg merge
14h 59m
Merged PRs (30d)
151

Description

Steps to reproduce

Issue 1: conversationMessageListener is not added to ConversationMessageNotifier. I can no longer reproduce this issue. Maybe I wasn't running the latest code.

1. Launch the app on a device or emulator. Ensure it's a completely fresh launch (force kill if needed).
1. Enter a room.
1. send a message
1. Check logcat for WebSocketInstance Receiving : ... message
1. Observe that it didn't print the log message.
1. Exit the room, then re-enter it.
1. send a message
1. Observe that now it prints a log for WebSocketInstance Receiving : ... message

Issue 2: conversationMessageListener is added to ConversationMessageNotifier multiple times

This one is more difficult to reproduce, and I haven't found a consistent way to do it. I usually go in and out of chats, send some messages, upload some files, etc. and eventually I notice that there are multiple logs for received message in ChatActivity for each received WebSocketInstance message.

Expected behaviour

conversationMessageListener is added to ConversationMessageNotifier as needed, and never duplicated.

Actual behaviour

conversationMessageListener is not always added and removed from ConversationMessageNotifier

Device brand and model

Samsung Galaxy S24 + Emulator for Pixel 8a

Android version

16

Nextcloud Talk app version

latest master as of 4/26/2024

Nextcloud server version

33.0.0

Talk version

No response

Custom Signaling server configured

None

Custom TURN server configured

None

Custom STUN server configured

None

Android logs

I added some logs any time a conversationMessageListener is added and removed. You can see here that sometimes it adds one which is not removed, and the count goes up. I've seen it go as high as 3 in random testing.

2026-04-26 11:31:25.914  2665-2665  Conversati...geNotifier com.nextcloud.talk2                  D  remove listener. Listener count = 0
2026-04-26 11:31:27.026  2665-2665  Conversati...geNotifier com.nextcloud.talk2                  D  add conversationMessageListener setupWebsocket currentConversation!!.remoteServer?.isNotEmpty() == false
2026-04-26 11:31:27.026  2665-2665  Conversati...geNotifier com.nextcloud.talk2                  D  add listener. Listener count = 1
2026-04-26 11:31:36.358  2665-2665  Conversati...geNotifier com.nextcloud.talk2                  D  add conversationMessageListener onResume
2026-04-26 11:31:36.934  2665-2665  Conversati...geNotifier com.nextcloud.talk2                  D  add conversationMessageListener setupWebsocket currentConversation!!.remoteServer?.isNotEmpty() == false
2026-04-26 11:31:36.934  2665-2665  Conversati...geNotifier com.nextcloud.talk2                  D  add listener. Listener count = 2
2026-04-26 11:31:40.082  2665-2665  Conversati...geNotifier com.nextcloud.talk2                  D  remove listener. Listener count = 1

This causes received messages to be processed multiple times:

2026-04-26 11:34:56.520  2665-2803  WebSocketInstance       com.nextcloud.talk2                  D  Receiving : okhttp3.internal.ws.RealWebSocket@2a9dec1 {"type":"event","event":{"target":"room","type":"message","message":{"roomid":"tsdtf6ru","data":{"type":"chat","chat":{"comment":{"id":3526,"token":"tsdtf6ru","actorType":"users","actorId":"devjens","actorDisplayName":"Dev Jens","timestamp":1777221298,"message":"Test","messageParameters":[],"systemMessage":"","messageType":"comment","isReplyable":true,"referenceId":"acbbc08544148e5e4238dc64af0e010a99bb15247e9ea490c6bb84f1814b61d3","reactions":{},"expirationTimestamp":0,"markdown":true,"threadId":3526}}}}}}
2026-04-26 11:34:56.529  2665-2803  ChatActivity            com.nextcloud.talk2                  D  received message in ChatActivity. This is the chat message received via HPB. It would be nicer to receive it in the ViewModel or Repository directly. Otherwise it needs to be passed into it from here...
2026-04-26 11:34:56.530  2665-2803  ChatActivity            com.nextcloud.talk2                  D  received message in ChatActivity. This is the chat message received via HPB. It would be nicer to receive it in the ViewModel or Repository directly. Otherwise it needs to be passed into it from here...
Server log

Additional information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read ConversationMessageNotifier and the listener registration paths in ChatActivity, especially setupWebsocket and onResume. Reproduce room and activity lifecycle changes while monitoring the provided logs. Done means conversationMessageListener is registered as needed without duplicates, and each received message is processed once.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.