A new room created by a new user sometimes contains duplicated timeline items
- Existing user on Element X Android
- In Element Web:
- register a new user
- create a DM with the existing user
- send 2 messages
- In Element X Android, accept the invitation. The timeline will be displayed.
- Sometimes, there are duplicate items in the timeline:
Note: this only happens sometimes. I estimate about 50% of the time.
(The same thing happens if you use Element X iOS instead of Element X Android.)
I investigated this a bit and found that the duplicated items are provided via the initial_values from TimelineSubscriber, so they must be part of state.items within matrix_sdk_ui::timeline::controller::TimelineController::subscribe. I don't know why they appear, but I suspect we are updating the timeline in 2 different ways simultaneously, and some kind of race is happening.
(Found while testing https://github.com/element-hq/crypto-internal/issues/398 .)
Thanks, can you give us something actionable at the SDK level, since it's unclear this is a SDK bug, at this point: rageshake, Rust logs, or even better, a regression (integration) test?
Here are the logs from my dev Android Studio.
Small-Phone-API-35-Android-15_2025-03-07_091140.txt
In the above log, I start a chat with one user test1027 and EXA shows the timeline correctly with no repeats, and then I start another with test1028 and I see duplicated items in the timeline.
I can't provide anything directly actionable: I don't know whether this is an SDK bug, but it seems likely since the behaviour is identical in EXA and EXI. Further, when I tried to track this in the debugger, I found that the initial_values from TimelineSubscriber contained the duplicated items, so it seems plausible that something is wrong in the SDK.
When I thought that my change had caused this problem, I wrote test_new_users_first_messages_dont_warn_about_insecure_device_if_it_is_secure in https://github.com/matrix-org/matrix-rust-sdk/pull/4644 to try and reproduce it, but I didn't see this bug there. That test might be a good starting point.
(Feel free to move this item somewhere else if it's more appropriate)
A rageshake from my dev Android build is at https://github.com/element-hq/element-x-android-rageshakes/issues/4623
I've experienced that on iOS so it seems to be a bug in the SDK