matrix-org / matrix-org/matrix-rust-sdk

A new room created by a new user sometimes contains duplicated timeline items

Open
#4,758 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
2.3k
Forks
500
Avg merge
1d 16h
Merged PRs (30d)
106

Description

* 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:

![Image](https://github.com/user-attachments/assets/6a86fe14-0be5-4054-aa04-2200d1decd27)

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.)

![Image](https://github.com/user-attachments/assets/3237ef3a-3850-418a-b8ea-afe386145c0b)

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 .)

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

Reproduce the issue with a new Element Web user and an existing Element X Android or iOS user, then inspect matrix_sdk_ui::timeline::controller::TimelineController::subscribe and the TimelineSubscriber initial_values path. Trace how state.items is populated during room creation and accepting the invitation; done means the initial timeline contains no duplicated items.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.