Commit 6e080a7c35

6e080a7c352e835c2b1716972b868cdea382ac7b

parent: 3b444ddcb3

Unsigned

Darafei Praliaskouski <me@komzpa.net> · 2026-07-31 12:16 UTC
committer: <strk@kbt.io>

fix: release Matrix history lock after initial page

(cherry picked from commit 96038e9265a52a39694081be348b373fa988cfad)

Layout: unified · split

src/room/mod.rs +7 −5
@@ -143,7 +143,10 @@ const HISTORY_PAGE_TAGS: [&str; 2] =
143 ["matrix_history_page", "matrix_smart_filter"]; 143 ["matrix_history_page", "matrix_smart_filter"];
144const RESTORED_HISTORY_BATCH_SIZE: u16 = 25; 144const RESTORED_HISTORY_BATCH_SIZE: u16 = 25;
145const INTERACTIVE_HISTORY_BATCH_SIZE: u16 = 25; 145const INTERACTIVE_HISTORY_BATCH_SIZE: u16 = 25;
146const RESTORED_HISTORY_TARGET_LINES: i32 = 100; 146// Restore one current page eagerly. Further pages are user-driven so a noisy
147// room cannot monopolize its history lock while the GUI is asking for older
148// messages in the room the user is actually viewing.
149const RESTORED_HISTORY_TARGET_LINES: i32 = 1;
147const RESTORED_HISTORY_MAX_PAGES: usize = 10; 150const RESTORED_HISTORY_MAX_PAGES: usize = 10;
148 151
149fn restored_prev_batch(_prev_batch: Option<String>) -> Option<PrevBatch> { 152fn restored_prev_batch(_prev_batch: Option<String>) -> Option<PrevBatch> {
@@ -3278,10 +3281,9 @@ mod tests {
3278 } 3281 }
3279 3282
3280 #[test] 3283 #[test]
3281 fn restored_history_keeps_paging_until_it_is_useful() { 3284 fn restored_history_releases_the_lock_after_one_useful_page() {
3282 assert!(should_continue_restored_history(0, 13, true)); 3285 assert!(!should_continue_restored_history(0, 13, true));
3283 assert!(should_continue_restored_history(87, 99, true)); 3286 assert!(!should_continue_restored_history(87, 99, true));
3284 assert!(!should_continue_restored_history(99, 112, true));
3285 assert!(!should_continue_restored_history(13, 13, true)); 3287 assert!(!should_continue_restored_history(13, 13, true));
3286 assert!(!should_continue_restored_history(0, 13, false)); 3288 assert!(!should_continue_restored_history(0, 13, false));
3287 } 3289 }