status-im / status-mobile

a free (libre) open source, mobile OS for Ethereum
https://status.app
Mozilla Public License 2.0
3.92k stars 984 forks source link

Loaded messages appear for a Receiver chaotically in 1-1 chat #21460

Open mariia-skrypnyk opened 1 month ago

mariia-skrypnyk commented 1 month ago

Bug Report

Follow up of https://github.com/status-im/status-mobile/pull/21411

Problem

When we, as the receiver, expect a batch of new messages, they often appear chaotically in our chat. The last message may show up first, followed by the initial messages, and only then the ones in the middle of the conversation.

Reproduction

  1. Login to app as a Receiver (a member of Status community)
  2. Login to another device as a Sender (a member of Status community)
  3. As a Receiver do a logout and close the app.
  4. As a Sender wait till Receiver status become offline and send 20+ messages to 1-1 chat with a Receiver.
  5. As a Receiver login and open chat with a Sender.

Actual behavior

Chaotic behavior starts from the 00:05 sec

https://github.com/user-attachments/assets/20f0d3e3-38c5-439c-9645-48f7ff693519

Receiver_chaotic.zip Sender_chaotic.zip

Expected behavior

Messages appear from the eldest to the newest logically

Additional Information

ilmotta commented 1 month ago

@mariia-skrypnyk We can close this issue because there's no guarantee of message ordering, as far as I understand. The behavior is like this by design, so it's probably the same behavior in the desktop app.

mariia-skrypnyk commented 3 weeks ago

Hey @ilmotta !

Thanks for your comment. Are you talking regarding an implementation design? As I am not sure I saw such logic in Figma or somewhere. Sorry but just wanted to be sure I know the source of the expected result.

ilmotta commented 2 weeks ago

Hey @mariia-skrypnyk, sorry I used the word "by design" but I meant engineering design. Here's one reference https://github.com/vacp2p/rfc-index/blob/main/status/62/payloads.md/#clock-vs-timestamp-and-message-ordering

It would be better if we double-checked what happens in the desktop app. Maybe they do something different to minimize this problem, but I believe the problem can never be fully eliminated without much deeper changes. @Samyoul please correct me if I'm saying something wrong.