-
Notifications
You must be signed in to change notification settings - Fork 187
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
Sliding Sync: Handle timeline limit changes (take 2) #17579
Changes from all commits
da5339d
baac6c5
0561c86
c15b8b3
a1b75f7
6b9d244
55feaae
614c0d7
100927d
70d32fb
ee6efa2
009af0e
b23231e
aea946b
33ec15b
768d150
a63261d
891ce47
a4ad443
0e8feed
49c4645
299ab1b
ba4e63b
2bba63e
52f4253
09538c2
733555b
76f882a
bcaf4e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Handle changes in `timeline_limit` in experimental sliding sync. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will need this same room sync config tracking for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Possible edge case: ElementX triggers There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is fine. There are two cases depending on if the timeline limit in the morning is small or high: For the small case:
For the high case:
What EX at least wants is to quickly be able to get enough chunks of history in rooms (in the background) to be able to show a screens worth of data. That way the UX is open the app, see a fast sync, (in the background it preloads the top N rooms with more timeline), the user clicks on one of the rooms and sees a page of timeline, and then the app can paginate in more timeline as usual (via |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1044,6 +1044,11 @@ async def encode_rooms( | |
if room_result.initial: | ||
serialized_rooms[room_id]["initial"] = room_result.initial | ||
|
||
if room_result.unstable_expanded_timeline: | ||
serialized_rooms[room_id][ | ||
"unstable_expanded_timeline" | ||
] = room_result.unstable_expanded_timeline | ||
Comment on lines
+1047
to
+1050
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be better if clients provided the But providing |
||
|
||
# This will be omitted for invite/knock rooms with `stripped_state` | ||
if ( | ||
room_result.required_state is not None | ||
|
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.
This continues to feel horrible especially given new edge cases like this comment. Highly recommend we just update the client to use an initial sync request with
timeline_limit: 20
andrequired_state: []
(which allows us to avoid the extra bytes) to accomplish the exact same thing without introducing any of this bizarre behavior.Previous conversation for context
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.
Talked with @erikjohnston a bit more and was trying to figure out why the initial sync request doesn't solve this completely. I basically asked the opposite question for how/why timeline trickling/
unstable_expanded_timeline
makes this easier. The following question unlocked a better understanding for one complication when trying to use the initial sync route.This is a valid point!
I'm still leaning towards the side of initial sync being possible to use (and better) and just requires some basic timeline stitching logic. ElementX might already have some stitching and event de-duplication logic to handle what the proxy was doing before that would also cover this case.
Since ElementX doesn't have offline support and throws away events, I think we could just do this:
For the timeline stitching logic, the client can store the latest event in timeline before our initial sync, then find that event in the initial sync
timeline
events and spread backwards from that point. That way, the ongoing sync loop can still append to the end of the timeline and continue seamlessly.So if we have a timeline
[103]
already on the client, we storelatest_event_id = 103
, do our initial sync which returns[100, 101, 102, 103, 104]
and we splice/spread in only[100, 101, 102, 103]
accordingly (drop any new events after thelatest_event_id
from the initial sync response). This makes it so that even if the ongoing sync loop sends104
before or after our initial sync does, it still appends like normal and everything is in seamless order.If there are so many new messages sent in the time between us storing the
latest_event_id
and the initial sync responding that we now have a gap, we can just throw away our initial sync events because we have enough events to fill up the timeline just from our normal ongoing sync loop.To be clear, the client doesn't need to be fancy about stitching:
If the client had more timeline like
[98, 99, 100, 101, 102, 103]
, we storelatest_event_id = 103
, we start the initial sync, our ongoing sync loop races us and returns104
which makes our timeline look like[98, 99, 100, 101, 102, 103, 104]
. Then our initial sync responds with[100, 101, 102, 103, 104]
, we find the103
spot in the response to slice at and place it at the103
spot in the client timeline leaving us with[100, 101, 102, 103, 104]
Pseudo code (maybe off-by-one errors):