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

UTD Hook | UTD will never be reported if the timeline controller is dropped before the `max_delay`

Open
#4,267 6 comments 0 reactions 0 assignees View on GitHub
A-Encryption
Dominant language
Rust
Stars
2.3k
Forks
500
Avg merge
1d 16h
Merged PRs (30d)
106

Description

When a UTD is reported, the hook manager will spawn a task to be executed after `max_delay`:

https://github.com/matrix-org/matrix-rust-sdk/blob/9b6de4e4367a465b7605eb931d0e4375df8f5ddd/crates/matrix-sdk-ui/src/unable_to_decrypt_hook.rs#L233-L236

However, if the hook is dropped before the expiration of this timer the UTD will never be reported:

https://github.com/matrix-org/matrix-rust-sdk/blob/9b6de4e4367a465b7605eb931d0e4375df8f5ddd/crates/matrix-sdk-ui/src/unable_to_decrypt_hook.rs#L315-L318

The current default for that delay is 60s. This particularly affects clients like EXI that don't keep timelines around; EXA has a LRU cache of the last 16 opened timelines.

Some notes:
- We would want to keep the reporting task around (surviving the hook lifetime), but then we might not detect late decryption anymore because this is done by the timeline controller
- Maybe we should move that code to the event cache
- As a stop gap we could reduce the max delay to around 10s? would reduce the chances of having it dropped

Contributor guide

Open the contributing guide

Research direction

Start in crates/matrix-sdk-ui/src/unable_to_decrypt_hook.rs at the timer creation and timeline-controller drop handling linked in the issue. Trace how the reporting task and late decryption depend on the hook lifetime, then resolve which lifecycle location should own the task; done means UTD reports still occur when the timeline controller is dropped before max_delay.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
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.