-
Notifications
You must be signed in to change notification settings - Fork 767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Potential fix stuck local echo events at the bottom of the screen #4928
Conversation
roomEntity.sendingTimelineEvents.filter { timelineEvent -> | ||
timelineEvent.root?.sendState == SendState.SENT | ||
}.forEach { | ||
roomEntity.sendingTimelineEvents.remove(it) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great explanation of the scenario! 💯
are the sendingTimelineEvents
the local echos?
I'm wondering if we could clean up when we set the sendState
to SENT
(or is that what this logic is acting on?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes and I guess yes we can, but if we do that we will remove the echos at once. So until the user is back online echos will not be visible.
According to your great explanation and videos, it seems to work! I am even wondering if we should remove the existing local echo cleanup @ganfra can you share your thoughts? |
Thanks for the explanation! |
@bmarty I think it's ok to delete it, there will be no difference without it. However, we have an optimisation logic there that passes the decrypted event at once without the need to decrypt it again. So we should keep the logic there at least @ganfra To my understanding, yes in a very slow |
As discussed IRL, lets merge the PR! |
This PR will try to fix issues like #516 that report stuck local echo events. The fix not only prevent this from happening again but after a user update its device, stuck local echos will be cleared
Why this is happening?
The issue can happen when a message is SENT but not received back from the
/sync
.Until now we use
unsignedData.transactionId
to determine whether or not the localevent should be deleted on every
/sync
. However, this is partially correct, lets have a lookat the following scenario:
There is no Internet connection
→10 Messages are sent
→cant be sent so the 10 messages are in the queue
→internet comes back for 1 second
→3 messages are sent to the homeserver
→Internet drops again
→No /sync response is triggered | home server can even replied with /sync but never arrived while we are offline
So the state until now is that we have 7 pending events to send and 3 sent but not received them back from /sync
Subsequently, those 3 local messages will not be deleted from the device while there is no transactionId from the /sync
lets continue:
Now lets assume that in the same room another user sent 15 events
→We are finally back online!
→we will receive the 10 latest events for the room and of course sent the pending 7 messages
→Now /sync response will NOT contain the 3 local messages so our events will stuck in the device.
Someone can say, yes but it will come with the
rooms/{roomId}/messages
while paginating, so the problem will be solved. No that is not the case for two reasons:rooms/{roomId}/messages
response do not contain theunsignedData.transactionId
so we cannot know which event to delete (in the doc says it should but, it does not)transactionId
was there, currently we are not deleting it from the paginationWhile we cannot know when a specific event arrived from the pagination (no transactionId included), after each room
/sync
a solution is to clear all SENT events, and we are sure that we will receive it from/sync
orpagination
Before the fix
https://user-images.githubusercontent.com/60798129/149152854-76a0aff6-5925-4e1c-bbf2-b7c96282869c.mp4
After the fix
https://user-images.githubusercontent.com/60798129/149153207-94e54325-8c2b-49cd-b7d9-39534620ae6c.mp4