Skip to content

feat(send_queue): report progress for media uploads #5008

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

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b609637
feat(send_queue): add global setting for sending media progress updates
Johennes Jul 7, 2025
98ded6d
chore(send_queue): collect thumbnail-related metadata in a dedicated …
Johennes Jul 7, 2025
ed36540
feat(send_queue): cache thumbnail sizes to use them in progress repor…
Johennes Jul 7, 2025
84fa087
chore(send_queue): Make parent_is_thumbnail_upload available outside …
Johennes Jul 7, 2025
1c9436b
feat(send_queue): enable progress monitoring in RoomSendQueue::handle…
Johennes Jul 7, 2025
d2f47f3
feat(sdk): introduce AbstractProgress for tracking media progress in …
Johennes Jul 7, 2025
5c0bb6a
chore(send_queue): rename RoomSendQueueUpdate::UploadedMedia to Media…
Johennes Jul 7, 2025
e4e2796
feat(send_queue): communicate media upload progress in RoomSendQueueU…
Johennes Jul 7, 2025
6a82e29
feat(timeline): communicate media upload progress through EventSendSt…
Johennes Jul 7, 2025
5da557d
feat(ffi): expose media upload progress through EventSendState::NotSe…
Johennes Jul 7, 2025
7ce947b
fixup! feat(send_queue): add global setting for sending media progres…
Johennes Jul 9, 2025
80be2d2
fixup! feat(send_queue): communicate media upload progress in RoomSen…
Johennes Jul 9, 2025
f91be75
fixup! feat(timeline): communicate media upload progress through Even…
Johennes Jul 9, 2025
0f2eb69
fixup! feat(send_queue): enable progress monitoring in RoomSendQueue:…
Johennes Jul 9, 2025
1d1e9a6
fixup! feat(send_queue): communicate media upload progress in RoomSen…
Johennes Jul 9, 2025
08a805d
fixup! feat(send_queue): communicate media upload progress in RoomSen…
Johennes Jul 9, 2025
66827e1
fixup! feat(send_queue): communicate media upload progress in RoomSen…
Johennes Jul 9, 2025
5cb65e1
fixup! feat(timeline): communicate media upload progress through Even…
Johennes Jul 9, 2025
8ba3aa6
fixup! feat(ffi): expose media upload progress through EventSendState…
Johennes Jul 9, 2025
207fc5f
fixup! feat(send_queue): communicate media upload progress in RoomSen…
Johennes Jul 9, 2025
50ed24c
fixup! feat(send_queue): communicate media upload progress in RoomSen…
Johennes Jul 9, 2025
c7d1934
fixup! feat(timeline): communicate media upload progress through Even…
Johennes Jul 9, 2025
48ccad9
fixup! feat(send_queue): communicate media upload progress in RoomSen…
Johennes Jul 9, 2025
13631d5
fixup! feat(send_queue): communicate media upload progress in RoomSen…
Johennes Jul 9, 2025
50696e1
fixup! feat(send_queue): communicate media upload progress in RoomSen…
Johennes Jul 9, 2025
0e1baac
fixup! feat(send_queue): communicate media upload progress in RoomSen…
Johennes Jul 9, 2025
cf51ac9
fixup! feat(send_queue): cache thumbnail sizes to use them in progres…
Johennes Jul 9, 2025
97a553f
fixup! feat(send_queue): cache thumbnail sizes to use them in progres…
Johennes Jul 9, 2025
971dcda
fixup! feat(send_queue): cache thumbnail sizes to use them in progres…
Johennes Jul 10, 2025
ad963c7
fixup! feat(send_queue): communicate media upload progress in RoomSen…
Johennes Jul 10, 2025
7cba439
Merge branch 'main' into johannes/send-queue-media-progress
Johennes Jul 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion bindings/matrix-sdk-ffi/src/client_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ pub struct ClientBuilder {
decryption_settings: DecryptionSettings,
enable_share_history_on_invite: bool,
request_config: Option<RequestConfig>,
enable_send_queue_media_upload_progress_reporting: bool,

#[cfg(not(target_family = "wasm"))]
user_agent: Option<String>,
Expand Down Expand Up @@ -180,6 +181,7 @@ impl ClientBuilder {
enable_share_history_on_invite: false,
request_config: Default::default(),
threads_enabled: false,
enable_send_queue_media_upload_progress_reporting: false,
})
}

Expand Down Expand Up @@ -386,6 +388,18 @@ impl ClientBuilder {
Arc::new(builder)
}

/// Set whether to enable progress reporting for media uploads in the send
/// queue.
pub fn enable_send_queue_media_upload_progress_reporting(
self: Arc<Self>,
enable_send_queue_media_upload_progress_reporting: bool,
) -> Arc<Self> {
let mut builder = unwrap_or_clone_arc(self);
builder.enable_send_queue_media_upload_progress_reporting =
enable_send_queue_media_upload_progress_reporting;
Arc::new(builder)
}

/// Add a default request config to this client.
pub fn request_config(self: Arc<Self>, config: RequestConfig) -> Arc<Self> {
let mut builder = unwrap_or_clone_arc(self);
Expand Down Expand Up @@ -524,7 +538,10 @@ impl ClientBuilder {
.with_encryption_settings(builder.encryption_settings)
.with_room_key_recipient_strategy(builder.room_key_recipient_strategy)
.with_decryption_settings(builder.decryption_settings)
.with_enable_share_history_on_invite(builder.enable_share_history_on_invite);
.with_enable_share_history_on_invite(builder.enable_share_history_on_invite)
.with_enable_send_queue_media_upload_progress_reporting(
builder.enable_send_queue_media_upload_progress_reporting,
);

match builder.sliding_sync_version_builder {
SlidingSyncVersionBuilder::None => {
Expand Down
17 changes: 16 additions & 1 deletion crates/matrix-sdk/src/client/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ pub struct ClientBuilder {
enable_share_history_on_invite: bool,
cross_process_store_locks_holder_name: String,
threading_support: ThreadingSupport,
enable_send_queue_media_upload_progress_reporting: bool,
}

impl ClientBuilder {
Expand Down Expand Up @@ -145,6 +146,7 @@ impl ClientBuilder {
cross_process_store_locks_holder_name:
Self::DEFAULT_CROSS_PROCESS_STORE_LOCKS_HOLDER_NAME.to_owned(),
threading_support: ThreadingSupport::Disabled,
enable_send_queue_media_upload_progress_reporting: false,
}
}

Expand Down Expand Up @@ -489,6 +491,16 @@ impl ClientBuilder {
self
}

/// Set whether to report media upload progress via the send queue.
pub fn with_enable_send_queue_media_upload_progress_reporting(
mut self,
enable_send_queue_media_upload_progress_reporting: bool,
) -> Self {
self.enable_send_queue_media_upload_progress_reporting =
enable_send_queue_media_upload_progress_reporting;
self
}

/// Create a [`Client`] with the options set on this builder.
///
/// # Errors
Expand Down Expand Up @@ -573,7 +585,10 @@ impl ClientBuilder {
});

// Enable the send queue by default.
let send_queue = Arc::new(SendQueueData::new(true));
let send_queue = Arc::new(SendQueueData::new(
true,
self.enable_send_queue_media_upload_progress_reporting,
));

let server_info = ClientServerInfo {
server_versions: match self.server_versions {
Expand Down
11 changes: 10 additions & 1 deletion crates/matrix-sdk/src/send_queue/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ impl SendQueue {
data.is_dropping.clone(),
&self.client,
owned_room_id.clone(),
data.report_media_upload_progress.clone(),
);

map.insert(owned_room_id, room_q.clone());
Expand Down Expand Up @@ -330,18 +331,22 @@ pub(super) struct SendQueueData {

/// Are we currently dropping the Client?
is_dropping: Arc<AtomicBool>,

/// Will media upload progress be reported via send queue updates?
report_media_upload_progress: Arc<AtomicBool>,
}

impl SendQueueData {
/// Create the data for a send queue, in the given enabled state.
pub fn new(globally_enabled: bool) -> Self {
pub fn new(globally_enabled: bool, report_media_upload_progress: bool) -> Self {
let (sender, _) = broadcast::channel(32);

Self {
rooms: Default::default(),
globally_enabled: AtomicBool::new(globally_enabled),
error_reporter: sender,
is_dropping: Arc::new(false.into()),
report_media_upload_progress: Arc::new(AtomicBool::new(report_media_upload_progress)),
}
}
}
Expand Down Expand Up @@ -389,6 +394,7 @@ impl RoomSendQueue {
is_dropping: Arc<AtomicBool>,
client: &Client,
room_id: OwnedRoomId,
report_media_upload_progress: Arc<AtomicBool>,
) -> Self {
let (updates_sender, _) = broadcast::channel(32);

Expand All @@ -406,6 +412,7 @@ impl RoomSendQueue {
locally_enabled.clone(),
global_error_reporter,
is_dropping,
report_media_upload_progress,
));

Self {
Expand Down Expand Up @@ -514,6 +521,7 @@ impl RoomSendQueue {
///
/// It only progresses forward: nothing can be cancelled at any point, which
/// makes the implementation not overly complicated to follow.
#[allow(clippy::too_many_arguments)]
#[instrument(skip_all, fields(room_id = %room.room_id()))]
async fn sending_task(
room: WeakRoom,
Expand All @@ -523,6 +531,7 @@ impl RoomSendQueue {
locally_enabled: Arc<AtomicBool>,
global_error_reporter: broadcast::Sender<SendQueueRoomError>,
is_dropping: Arc<AtomicBool>,
_report_media_upload_progress: Arc<AtomicBool>,
) {
trace!("spawned the sending task");

Expand Down