Offload messages #16622
flexsurfer
started this conversation in
General
Offload messages
#16622
Replies: 3 comments
-
@flexsurfer still the case on wakuv2? |
Beta Was this translation helpful? Give feedback.
0 replies
-
This is probably best to re-evaluate once development settles as it will need to have some ux/ui input, moving to discussion |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In this PR we've removed messages offloading on viewabe changed
https://github.com/status-im/status-react/pull/11754/files#diff-84be73c73188c18f0e2140a6bd999af01997782bb12ebe7379a74be57a51fe9fL34
Why message offloading was disabled in this PR
it conflicts with endreached event, we offload messages and then endreached event fired and we load 20 messages again. This happens also when sending message, send message, then offload, readd all messages, then endreache, add 20 more, receiving each new messages or sending each new message cause this chain of events
re-adding all messages is really expensive , readding one messages is ±6ms so, if we offload 5 messages in the end of the list and we have 300 messages we just re-add 300 messages , ±1800 ms
Probably we still need to offload messages in one case, when we are in the chat for a long time and receive lots of new messages, we need to find a way how to pop messages from the arrray and do not re-add all messages in that case, but because messages will be offloaded when user switch a chat or just go back to chats list, i guess we can leave with it, and implement properly in another PR, test shows that adding messages time grows not so fast with having more messages, the only place where it grows is subscription, for 300 messages it might take up to 100-200ms on low end android device
My suggestion would be
Remove all messages which older than first-hidden-message-clock + 20 if we have more than first-hidden-message-clock + 40 messages. We need two buffers, first 20 messages buffer for endreached event, if we removed all messages up to first-hidden-message-clock this event will be dispatched and we'll load 20 more, so we don't want that and we keep +20, and we want to check if we have more than +40 so we offload only once per 20 messages and not for every new message.
Also, we need to find a different way of removing messages, because the current way there we readding all messages is too expensive, I believe we could find the index of a message and remove all messages one by one using an iterator, and recalculate only the latest message, this should work
Beta Was this translation helpful? Give feedback.
All reactions