From 2a140770a02cbeeaedc8c4dec90de9135aebc679 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Thu, 5 Jun 2025 21:30:15 +0200 Subject: [PATCH] fix: Move runtime module from matrix-sdk-common to matrix-sdk-ffi (#5184) This module only builds on non-wasm with the patched async-compat from the workspace Cargo.toml's patch section, and it is only used by the ffi crate. It is currently breaking the use of the SDK as a git dependency, and would prevent the publishing of matrix-sdk-common (unless using --no-verify, but then that would just break all users of the newly published crates.io version). This bug was introduced in https://github.com/matrix-org/matrix-rust-sdk/pull/5089. Signed-off-by: Jonas Platte --- Cargo.lock | 1 - bindings/matrix-sdk-ffi/src/client.rs | 5 ++--- bindings/matrix-sdk-ffi/src/client_builder.rs | 4 ++-- bindings/matrix-sdk-ffi/src/encryption.rs | 7 +++++-- bindings/matrix-sdk-ffi/src/lib.rs | 1 + bindings/matrix-sdk-ffi/src/room.rs | 3 ++- bindings/matrix-sdk-ffi/src/room_directory_search.rs | 4 ++-- bindings/matrix-sdk-ffi/src/room_list.rs | 3 ++- .../matrix-sdk-ffi}/src/runtime.rs | 2 +- bindings/matrix-sdk-ffi/src/session_verification.rs | 6 ++++-- bindings/matrix-sdk-ffi/src/sync_service.rs | 5 +++-- bindings/matrix-sdk-ffi/src/timeline/mod.rs | 2 +- bindings/matrix-sdk-ffi/src/utils.rs | 3 ++- bindings/matrix-sdk-ffi/src/widget.rs | 4 ++-- crates/matrix-sdk-common/Cargo.toml | 1 - crates/matrix-sdk-common/src/lib.rs | 1 - 16 files changed, 29 insertions(+), 23 deletions(-) rename {crates/matrix-sdk-common => bindings/matrix-sdk-ffi}/src/runtime.rs (98%) diff --git a/Cargo.lock b/Cargo.lock index b91c72b4b..dcc1ba667 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2980,7 +2980,6 @@ version = "0.11.0" dependencies = [ "assert_matches", "assert_matches2", - "async-compat", "eyeball-im", "futures-core", "futures-executor", diff --git a/bindings/matrix-sdk-ffi/src/client.rs b/bindings/matrix-sdk-ffi/src/client.rs index 0123273fe..331b35ea8 100644 --- a/bindings/matrix-sdk-ffi/src/client.rs +++ b/bindings/matrix-sdk-ffi/src/client.rs @@ -41,9 +41,7 @@ use matrix_sdk::{ AuthApi, AuthSession, Client as MatrixClient, SessionChange, SessionTokens, STATE_STORE_DATABASE_NAME, }; -use matrix_sdk_common::{ - runtime::get_runtime_handle, stream::StreamExt, SendOutsideWasm, SyncOutsideWasm, -}; +use matrix_sdk_common::{stream::StreamExt, SendOutsideWasm, SyncOutsideWasm}; use matrix_sdk_ui::{ notification_client::{ NotificationClient as MatrixNotificationClient, @@ -102,6 +100,7 @@ use crate::{ AccountDataEvent, AccountDataEventType, AuthData, InviteAvatars, MediaPreviewConfig, MediaPreviews, MediaSource, RoomAccountDataEvent, RoomAccountDataEventType, }, + runtime::get_runtime_handle, sync_service::{SyncService, SyncServiceBuilder}, task_handle::TaskHandle, utd::{UnableToDecryptDelegate, UtdHook}, diff --git a/bindings/matrix-sdk-ffi/src/client_builder.rs b/bindings/matrix-sdk-ffi/src/client_builder.rs index 1bc37176b..460bc2edb 100644 --- a/bindings/matrix-sdk-ffi/src/client_builder.rs +++ b/bindings/matrix-sdk-ffi/src/client_builder.rs @@ -18,7 +18,7 @@ use matrix_sdk::{ Client as MatrixClient, ClientBuildError as MatrixClientBuildError, HttpError, IdParseError, RumaApiError, SqliteStoreConfig, }; -use matrix_sdk_common::{runtime::get_runtime_handle, SendOutsideWasm, SyncOutsideWasm}; +use matrix_sdk_common::{SendOutsideWasm, SyncOutsideWasm}; use ruma::api::error::{DeserializationError, FromHttpResponseError}; use tracing::{debug, error}; use zeroize::Zeroizing; @@ -26,7 +26,7 @@ use zeroize::Zeroizing; use super::client::Client; use crate::{ authentication::OidcConfiguration, client::ClientSessionDelegate, error::ClientError, - helpers::unwrap_or_clone_arc, task_handle::TaskHandle, + helpers::unwrap_or_clone_arc, runtime::get_runtime_handle, task_handle::TaskHandle, }; /// A list of bytes containing a certificate in DER or PEM form. diff --git a/bindings/matrix-sdk-ffi/src/encryption.rs b/bindings/matrix-sdk-ffi/src/encryption.rs index 640259603..af74a2bb9 100644 --- a/bindings/matrix-sdk-ffi/src/encryption.rs +++ b/bindings/matrix-sdk-ffi/src/encryption.rs @@ -5,12 +5,15 @@ use matrix_sdk::{ encryption, encryption::{backups, recovery}, }; -use matrix_sdk_common::{runtime::get_runtime_handle, SendOutsideWasm, SyncOutsideWasm}; +use matrix_sdk_common::{SendOutsideWasm, SyncOutsideWasm}; use thiserror::Error; use tracing::{error, info}; use zeroize::Zeroize; -use crate::{client::Client, error::ClientError, ruma::AuthData, task_handle::TaskHandle}; +use crate::{ + client::Client, error::ClientError, ruma::AuthData, runtime::get_runtime_handle, + task_handle::TaskHandle, +}; #[derive(uniffi::Object)] pub struct Encryption { diff --git a/bindings/matrix-sdk-ffi/src/lib.rs b/bindings/matrix-sdk-ffi/src/lib.rs index e41ff7346..2e2086945 100644 --- a/bindings/matrix-sdk-ffi/src/lib.rs +++ b/bindings/matrix-sdk-ffi/src/lib.rs @@ -26,6 +26,7 @@ mod room_list; mod room_member; mod room_preview; mod ruma; +mod runtime; mod session_verification; mod sync_service; mod task_handle; diff --git a/bindings/matrix-sdk-ffi/src/room.rs b/bindings/matrix-sdk-ffi/src/room.rs index d5345b0f9..7e068e7b1 100644 --- a/bindings/matrix-sdk-ffi/src/room.rs +++ b/bindings/matrix-sdk-ffi/src/room.rs @@ -12,7 +12,7 @@ use matrix_sdk::{ PredecessorRoom as SdkPredecessorRoom, RoomHero as SdkRoomHero, RoomMemberships, RoomState, SuccessorRoom as SdkSuccessorRoom, }; -use matrix_sdk_common::{runtime::get_runtime_handle, SendOutsideWasm, SyncOutsideWasm}; +use matrix_sdk_common::{SendOutsideWasm, SyncOutsideWasm}; use matrix_sdk_ui::{ timeline::{default_event_filter, RoomExt, TimelineBuilder}, unable_to_decrypt_hook::UtdHookManager, @@ -46,6 +46,7 @@ use crate::{ room_member::{RoomMember, RoomMemberWithSenderInfo}, room_preview::RoomPreview, ruma::{ImageInfo, LocationContent, Mentions, NotifyType}, + runtime::get_runtime_handle, timeline::{ configuration::{TimelineConfiguration, TimelineFilter}, EventTimelineItem, ReceiptType, SendHandle, Timeline, diff --git a/bindings/matrix-sdk-ffi/src/room_directory_search.rs b/bindings/matrix-sdk-ffi/src/room_directory_search.rs index ea22b5cf3..099ecbc8c 100644 --- a/bindings/matrix-sdk-ffi/src/room_directory_search.rs +++ b/bindings/matrix-sdk-ffi/src/room_directory_search.rs @@ -18,11 +18,11 @@ use std::{fmt::Debug, sync::Arc}; use eyeball_im::VectorDiff; use futures_util::StreamExt; use matrix_sdk::room_directory_search::RoomDirectorySearch as SdkRoomDirectorySearch; -use matrix_sdk_common::{runtime::get_runtime_handle, SendOutsideWasm, SyncOutsideWasm}; +use matrix_sdk_common::{SendOutsideWasm, SyncOutsideWasm}; use ruma::ServerName; use tokio::sync::RwLock; -use crate::{error::ClientError, task_handle::TaskHandle}; +use crate::{error::ClientError, runtime::get_runtime_handle, task_handle::TaskHandle}; #[derive(uniffi::Enum)] pub enum PublicRoomJoinRule { diff --git a/bindings/matrix-sdk-ffi/src/room_list.rs b/bindings/matrix-sdk-ffi/src/room_list.rs index b66efe76a..f1862e1f9 100644 --- a/bindings/matrix-sdk-ffi/src/room_list.rs +++ b/bindings/matrix-sdk-ffi/src/room_list.rs @@ -11,7 +11,7 @@ use matrix_sdk::{ }, Room as SdkRoom, }; -use matrix_sdk_common::{runtime::get_runtime_handle, SendOutsideWasm, SyncOutsideWasm}; +use matrix_sdk_common::{SendOutsideWasm, SyncOutsideWasm}; use matrix_sdk_ui::{ room_list_service::filters::{ new_filter_all, new_filter_any, new_filter_category, new_filter_deduplicate_versions, @@ -24,6 +24,7 @@ use matrix_sdk_ui::{ use crate::{ room::{Membership, Room}, + runtime::get_runtime_handle, TaskHandle, }; diff --git a/crates/matrix-sdk-common/src/runtime.rs b/bindings/matrix-sdk-ffi/src/runtime.rs similarity index 98% rename from crates/matrix-sdk-common/src/runtime.rs rename to bindings/matrix-sdk-ffi/src/runtime.rs index 9c07319ee..7f1711856 100644 --- a/crates/matrix-sdk-common/src/runtime.rs +++ b/bindings/matrix-sdk-ffi/src/runtime.rs @@ -19,7 +19,7 @@ #[cfg(not(target_family = "wasm"))] mod sys { - pub use tokio::runtime::{Handle, Runtime}; + pub use tokio::runtime::Handle; /// Get a runtime handle appropriate for the current target platform. /// diff --git a/bindings/matrix-sdk-ffi/src/session_verification.rs b/bindings/matrix-sdk-ffi/src/session_verification.rs index f36dcb466..894d8a23c 100644 --- a/bindings/matrix-sdk-ffi/src/session_verification.rs +++ b/bindings/matrix-sdk-ffi/src/session_verification.rs @@ -10,11 +10,13 @@ use matrix_sdk::{ ruma::events::key::verification::VerificationMethod, Account, }; -use matrix_sdk_common::{runtime::get_runtime_handle, SendOutsideWasm, SyncOutsideWasm}; +use matrix_sdk_common::{SendOutsideWasm, SyncOutsideWasm}; use ruma::UserId; use tracing::{error, warn}; -use crate::{client::UserProfile, error::ClientError, utils::Timestamp}; +use crate::{ + client::UserProfile, error::ClientError, runtime::get_runtime_handle, utils::Timestamp, +}; #[derive(uniffi::Object)] pub struct SessionVerificationEmoji { diff --git a/bindings/matrix-sdk-ffi/src/sync_service.rs b/bindings/matrix-sdk-ffi/src/sync_service.rs index 753235ec7..296bf7480 100644 --- a/bindings/matrix-sdk-ffi/src/sync_service.rs +++ b/bindings/matrix-sdk-ffi/src/sync_service.rs @@ -16,7 +16,7 @@ use std::{fmt::Debug, sync::Arc}; use futures_util::pin_mut; use matrix_sdk::Client; -use matrix_sdk_common::{runtime::get_runtime_handle, SendOutsideWasm, SyncOutsideWasm}; +use matrix_sdk_common::{SendOutsideWasm, SyncOutsideWasm}; use matrix_sdk_ui::{ sync_service::{ State as MatrixSyncServiceState, SyncService as MatrixSyncService, @@ -26,7 +26,8 @@ use matrix_sdk_ui::{ }; use crate::{ - error::ClientError, helpers::unwrap_or_clone_arc, room_list::RoomListService, TaskHandle, + error::ClientError, helpers::unwrap_or_clone_arc, room_list::RoomListService, + runtime::get_runtime_handle, TaskHandle, }; #[derive(uniffi::Enum)] diff --git a/bindings/matrix-sdk-ffi/src/timeline/mod.rs b/bindings/matrix-sdk-ffi/src/timeline/mod.rs index 927f40351..5689c2ac4 100644 --- a/bindings/matrix-sdk-ffi/src/timeline/mod.rs +++ b/bindings/matrix-sdk-ffi/src/timeline/mod.rs @@ -30,7 +30,6 @@ use matrix_sdk::{ reply::{EnforceThread, Reply}, }, }; -use matrix_sdk_common::runtime::get_runtime_handle; use matrix_sdk_ui::timeline::{ self, AttachmentSource, EventItemOrigin, Profile, TimelineDetails, TimelineUniqueId as SdkTimelineUniqueId, @@ -75,6 +74,7 @@ use crate::{ AssetType, AudioInfo, FileInfo, FormattedBody, ImageInfo, Mentions, PollKind, ThumbnailInfo, VideoInfo, }, + runtime::get_runtime_handle, task_handle::TaskHandle, utils::Timestamp, }; diff --git a/bindings/matrix-sdk-ffi/src/utils.rs b/bindings/matrix-sdk-ffi/src/utils.rs index 700150518..d29f7aa42 100644 --- a/bindings/matrix-sdk-ffi/src/utils.rs +++ b/bindings/matrix-sdk-ffi/src/utils.rs @@ -14,10 +14,11 @@ use std::{mem::ManuallyDrop, ops::Deref}; -use matrix_sdk_common::runtime::get_runtime_handle; use ruma::{MilliSecondsSinceUnixEpoch, UInt}; use tracing::warn; +use crate::runtime::get_runtime_handle; + #[derive(Debug, Clone)] pub struct Timestamp(u64); diff --git a/bindings/matrix-sdk-ffi/src/widget.rs b/bindings/matrix-sdk-ffi/src/widget.rs index f35cf738b..b631a4252 100644 --- a/bindings/matrix-sdk-ffi/src/widget.rs +++ b/bindings/matrix-sdk-ffi/src/widget.rs @@ -5,11 +5,11 @@ use matrix_sdk::{ async_trait, widget::{MessageLikeEventFilter, StateEventFilter, ToDeviceEventFilter}, }; -use matrix_sdk_common::{runtime::get_runtime_handle, SendOutsideWasm, SyncOutsideWasm}; +use matrix_sdk_common::{SendOutsideWasm, SyncOutsideWasm}; use ruma::events::MessageLikeEventType; use tracing::error; -use crate::room::Room; +use crate::{room::Room, runtime::get_runtime_handle}; #[derive(uniffi::Record)] pub struct WidgetDriverAndHandle { diff --git a/crates/matrix-sdk-common/Cargo.toml b/crates/matrix-sdk-common/Cargo.toml index b03c9b62f..556acca4b 100644 --- a/crates/matrix-sdk-common/Cargo.toml +++ b/crates/matrix-sdk-common/Cargo.toml @@ -25,7 +25,6 @@ uniffi = ["dep:uniffi"] test-send-sync = [] [dependencies] -async-compat.workspace = true eyeball-im.workspace = true futures-core.workspace = true futures-util.workspace = true diff --git a/crates/matrix-sdk-common/src/lib.rs b/crates/matrix-sdk-common/src/lib.rs index 952be3f4a..491239b36 100644 --- a/crates/matrix-sdk-common/src/lib.rs +++ b/crates/matrix-sdk-common/src/lib.rs @@ -28,7 +28,6 @@ pub mod failures_cache; pub mod linked_chunk; pub mod locks; pub mod ring_buffer; -pub mod runtime; pub mod serde_helpers; pub mod sleep; pub mod store_locks;