WIP

Antonio Scandurra created

Change summary

crates/call/src/room.rs                     |  15 +-
crates/call2/src/room.rs                    |   4 
crates/client2/src/client2.rs               |  14 +-
crates/gpui2/src/action.rs                  |   4 
crates/gpui2/src/app.rs                     |  42 ++++----
crates/gpui2/src/app/async_context.rs       |   6 
crates/gpui2/src/app/entity_map.rs          |   4 
crates/gpui2/src/app/model_context.rs       |  27 ++--
crates/gpui2/src/app/test_context.rs        |   4 
crates/gpui2/src/element.rs                 |  30 ++----
crates/gpui2/src/focusable.rs               |  23 ++--
crates/gpui2/src/gpui2.rs                   |  10 +-
crates/gpui2/src/interactive.rs             | 109 ++++++++++------------
crates/gpui2/src/keymap/matcher.rs          |  14 +-
crates/gpui2/src/subscription.rs            |   6 
crates/gpui2/src/taffy.rs                   |   7 -
crates/gpui2/src/view.rs                    |  57 ++++-------
crates/gpui2/src/window.rs                  |  59 +++++------
crates/live_kit_client/examples/test_app.rs |   8 -
crates/live_kit_client/src/prod.rs          |  18 ---
crates/live_kit_client/src/test.rs          |   4 
crates/ui2/src/theme.rs                     |   8 
22 files changed, 206 insertions(+), 267 deletions(-)

Detailed changes

crates/call/src/room.rs 🔗

@@ -1251,7 +1251,7 @@ impl Room {
                     .read_with(&cx, |this, _| {
                         this.live_kit
                             .as_ref()
-                            .map(|live_kit| live_kit.room.publish_audio_track(&track))
+                            .map(|live_kit| live_kit.room.publish_audio_track(track))
                     })
                     .ok_or_else(|| anyhow!("live-kit was not initialized"))?
                     .await
@@ -1337,7 +1337,7 @@ impl Room {
                     .read_with(&cx, |this, _| {
                         this.live_kit
                             .as_ref()
-                            .map(|live_kit| live_kit.room.publish_video_track(&track))
+                            .map(|live_kit| live_kit.room.publish_video_track(track))
                     })
                     .ok_or_else(|| anyhow!("live-kit was not initialized"))?
                     .await
@@ -1481,11 +1481,12 @@ impl Room {
 
     #[cfg(any(test, feature = "test-support"))]
     pub fn set_display_sources(&self, sources: Vec<live_kit_client::MacOSDisplay>) {
-        self.live_kit
-            .as_ref()
-            .unwrap()
-            .room
-            .set_display_sources(sources);
+        todo!()
+        // self.live_kit
+        //     .as_ref()
+        //     .unwrap()
+        //     .room
+        //     .set_display_sources(sources);
     }
 }
 

crates/call2/src/room.rs 🔗

@@ -1269,7 +1269,7 @@ impl Room {
                     .update(&mut cx, |this, _| {
                         this.live_kit
                             .as_ref()
-                            .map(|live_kit| live_kit.room.publish_audio_track(&track))
+                            .map(|live_kit| live_kit.room.publish_audio_track(track))
                     })?
                     .ok_or_else(|| anyhow!("live-kit was not initialized"))?
                     .await
@@ -1355,7 +1355,7 @@ impl Room {
                     .update(&mut cx, |this, _| {
                         this.live_kit
                             .as_ref()
-                            .map(|live_kit| live_kit.room.publish_video_track(&track))
+                            .map(|live_kit| live_kit.room.publish_video_track(track))
                     })?
                     .ok_or_else(|| anyhow!("live-kit was not initialized"))?
                     .await

crates/client2/src/client2.rs 🔗

@@ -312,7 +312,7 @@ pub struct PendingEntitySubscription<T: 'static> {
 
 impl<T> PendingEntitySubscription<T>
 where
-    T: 'static + Send + Sync,
+    T: 'static + Send,
 {
     pub fn set_model(mut self, model: &Handle<T>, cx: &mut AsyncAppContext) -> Subscription {
         self.consumed = true;
@@ -529,7 +529,7 @@ impl Client {
         remote_id: u64,
     ) -> Result<PendingEntitySubscription<T>>
     where
-        T: 'static + Send + Sync,
+        T: 'static + Send,
     {
         let id = (TypeId::of::<T>(), remote_id);
 
@@ -557,7 +557,7 @@ impl Client {
     ) -> Subscription
     where
         M: EnvelopedMessage,
-        E: 'static + Send + Sync,
+        E: 'static + Send,
         H: 'static + Send + Sync + Fn(Handle<E>, TypedEnvelope<M>, Arc<Self>, AsyncAppContext) -> F,
         F: 'static + Future<Output = Result<()>> + Send,
     {
@@ -599,7 +599,7 @@ impl Client {
     ) -> Subscription
     where
         M: RequestMessage,
-        E: 'static + Send + Sync,
+        E: 'static + Send,
         H: 'static + Send + Sync + Fn(Handle<E>, TypedEnvelope<M>, Arc<Self>, AsyncAppContext) -> F,
         F: 'static + Future<Output = Result<M::Response>> + Send,
     {
@@ -615,7 +615,7 @@ impl Client {
     pub fn add_model_message_handler<M, E, H, F>(self: &Arc<Self>, handler: H)
     where
         M: EntityMessage,
-        E: 'static + Send + Sync,
+        E: 'static + Send,
         H: 'static + Send + Sync + Fn(Handle<E>, TypedEnvelope<M>, Arc<Self>, AsyncAppContext) -> F,
         F: 'static + Future<Output = Result<()>> + Send,
     {
@@ -627,7 +627,7 @@ impl Client {
     fn add_entity_message_handler<M, E, H, F>(self: &Arc<Self>, handler: H)
     where
         M: EntityMessage,
-        E: 'static + Send + Sync,
+        E: 'static + Send,
         H: 'static + Send + Sync + Fn(AnyHandle, TypedEnvelope<M>, Arc<Self>, AsyncAppContext) -> F,
         F: 'static + Future<Output = Result<()>> + Send,
     {
@@ -666,7 +666,7 @@ impl Client {
     pub fn add_model_request_handler<M, E, H, F>(self: &Arc<Self>, handler: H)
     where
         M: EntityMessage + RequestMessage,
-        E: 'static + Send + Sync,
+        E: 'static + Send,
         H: 'static + Send + Sync + Fn(Handle<E>, TypedEnvelope<M>, Arc<Self>, AsyncAppContext) -> F,
         F: 'static + Future<Output = Result<M::Response>> + Send,
     {

crates/gpui2/src/action.rs 🔗

@@ -4,7 +4,7 @@ use collections::{HashMap, HashSet};
 use serde::Deserialize;
 use std::any::{type_name, Any};
 
-pub trait Action: Any + Send + Sync {
+pub trait Action: Any + Send {
     fn qualified_name() -> SharedString
     where
         Self: Sized;
@@ -19,7 +19,7 @@ pub trait Action: Any + Send + Sync {
 
 impl<A> Action for A
 where
-    A: for<'a> Deserialize<'a> + PartialEq + Any + Send + Sync + Clone + Default,
+    A: for<'a> Deserialize<'a> + PartialEq + Any + Send + Clone + Default,
 {
     fn qualified_name() -> SharedString {
         type_name::<A>().into()

crates/gpui2/src/app.rs 🔗

@@ -22,7 +22,7 @@ use crate::{
 use anyhow::{anyhow, Result};
 use collections::{HashMap, HashSet, VecDeque};
 use futures::{future::BoxFuture, Future};
-use parking_lot::{Mutex, RwLock};
+use parking_lot::Mutex;
 use slotmap::SlotMap;
 use std::{
     any::{type_name, Any, TypeId},
@@ -109,11 +109,10 @@ impl App {
 
 type ActionBuilder = fn(json: Option<serde_json::Value>) -> anyhow::Result<Box<dyn Action>>;
 type FrameCallback = Box<dyn FnOnce(&mut WindowContext) + Send>;
-type Handler = Box<dyn FnMut(&mut AppContext) -> bool + Send + Sync + 'static>;
-type Listener = Box<dyn FnMut(&dyn Any, &mut AppContext) -> bool + Send + Sync + 'static>;
-type QuitHandler =
-    Box<dyn FnMut(&mut AppContext) -> BoxFuture<'static, ()> + Send + Sync + 'static>;
-type ReleaseListener = Box<dyn FnMut(&mut dyn Any, &mut AppContext) + Send + Sync + 'static>;
+type Handler = Box<dyn FnMut(&mut AppContext) -> bool + Send + 'static>;
+type Listener = Box<dyn FnMut(&dyn Any, &mut AppContext) -> bool + Send + 'static>;
+type QuitHandler = Box<dyn FnMut(&mut AppContext) -> BoxFuture<'static, ()> + Send + 'static>;
+type ReleaseListener = Box<dyn FnMut(&mut dyn Any, &mut AppContext) + Send + 'static>;
 
 pub struct AppContext {
     this: Weak<Mutex<AppContext>>,
@@ -133,9 +132,9 @@ pub struct AppContext {
     pub(crate) unit_entity: Handle<()>,
     pub(crate) entities: EntityMap,
     pub(crate) windows: SlotMap<WindowId, Option<Window>>,
-    pub(crate) keymap: Arc<RwLock<Keymap>>,
+    pub(crate) keymap: Arc<Mutex<Keymap>>,
     pub(crate) global_action_listeners:
-        HashMap<TypeId, Vec<Box<dyn Fn(&dyn Action, DispatchPhase, &mut Self) + Send + Sync>>>,
+        HashMap<TypeId, Vec<Box<dyn Fn(&dyn Action, DispatchPhase, &mut Self) + Send>>>,
     action_builders: HashMap<SharedString, ActionBuilder>,
     pending_effects: VecDeque<Effect>,
     pub(crate) pending_notifications: HashSet<EntityId>,
@@ -188,7 +187,7 @@ impl AppContext {
                 unit_entity,
                 entities,
                 windows: SlotMap::with_key(),
-                keymap: Arc::new(RwLock::new(Keymap::default())),
+                keymap: Arc::new(Mutex::new(Keymap::default())),
                 global_action_listeners: HashMap::default(),
                 action_builders: HashMap::default(),
                 pending_effects: VecDeque::new(),
@@ -447,7 +446,7 @@ impl AppContext {
             .retain(&type_id, |observer| observer(self));
     }
 
-    fn apply_defer_effect(&mut self, callback: Box<dyn FnOnce(&mut Self) + Send + Sync + 'static>) {
+    fn apply_defer_effect(&mut self, callback: Box<dyn FnOnce(&mut Self) + Send + 'static>) {
         callback(self);
     }
 
@@ -506,7 +505,7 @@ impl AppContext {
         })
     }
 
-    pub fn defer(&mut self, f: impl FnOnce(&mut AppContext) + 'static + Send + Sync) {
+    pub fn defer(&mut self, f: impl FnOnce(&mut AppContext) + 'static + Send) {
         self.push_effect(Effect::Defer {
             callback: Box::new(f),
         });
@@ -556,7 +555,7 @@ impl AppContext {
             .unwrap()
     }
 
-    pub fn default_global<G: 'static + Default + Sync + Send>(&mut self) -> &mut G {
+    pub fn default_global<G: 'static + Default + Send>(&mut self) -> &mut G {
         let global_type = TypeId::of::<G>();
         self.push_effect(Effect::NotifyGlobalObservers { global_type });
         self.globals_by_type
@@ -566,7 +565,7 @@ impl AppContext {
             .unwrap()
     }
 
-    pub fn set_global<G: Any + Send + Sync>(&mut self, global: G) {
+    pub fn set_global<G: Any + Send>(&mut self, global: G) {
         let global_type = TypeId::of::<G>();
         self.push_effect(Effect::NotifyGlobalObservers { global_type });
         self.globals_by_type.insert(global_type, Box::new(global));
@@ -581,7 +580,7 @@ impl AppContext {
 
     pub fn observe_global<G: 'static>(
         &mut self,
-        mut f: impl FnMut(&mut Self) + Send + Sync + 'static,
+        mut f: impl FnMut(&mut Self) + Send + 'static,
     ) -> Subscription {
         self.global_observers.insert(
             TypeId::of::<G>(),
@@ -616,14 +615,11 @@ impl AppContext {
     }
 
     pub fn bind_keys(&mut self, bindings: impl IntoIterator<Item = KeyBinding>) {
-        self.keymap.write().add_bindings(bindings);
+        self.keymap.lock().add_bindings(bindings);
         self.pending_effects.push_back(Effect::Refresh);
     }
 
-    pub fn on_action<A: Action>(
-        &mut self,
-        listener: impl Fn(&A, &mut Self) + Send + Sync + 'static,
-    ) {
+    pub fn on_action<A: Action>(&mut self, listener: impl Fn(&A, &mut Self) + Send + 'static) {
         self.global_action_listeners
             .entry(TypeId::of::<A>())
             .or_default()
@@ -660,7 +656,7 @@ impl Context for AppContext {
     type EntityContext<'a, 'w, T> = ModelContext<'a, T>;
     type Result<T> = T;
 
-    fn entity<T: Any + Send + Sync>(
+    fn entity<T: 'static + Send>(
         &mut self,
         build_entity: impl FnOnce(&mut Self::EntityContext<'_, '_, T>) -> T,
     ) -> Handle<T> {
@@ -766,7 +762,7 @@ impl MainThread<AppContext> {
         })
     }
 
-    pub fn update_global<G: 'static + Send + Sync, R>(
+    pub fn update_global<G: 'static + Send, R>(
         &mut self,
         update: impl FnOnce(&mut G, &mut MainThread<AppContext>) -> R,
     ) -> R {
@@ -783,7 +779,7 @@ pub(crate) enum Effect {
     },
     Emit {
         emitter: EntityId,
-        event: Box<dyn Any + Send + Sync + 'static>,
+        event: Box<dyn Any + Send + 'static>,
     },
     FocusChanged {
         window_id: WindowId,
@@ -794,7 +790,7 @@ pub(crate) enum Effect {
         global_type: TypeId,
     },
     Defer {
-        callback: Box<dyn FnOnce(&mut AppContext) + Send + Sync + 'static>,
+        callback: Box<dyn FnOnce(&mut AppContext) + Send + 'static>,
     },
 }
 

crates/gpui2/src/app/async_context.rs 🔗

@@ -5,7 +5,7 @@ use crate::{
 use anyhow::anyhow;
 use derive_more::{Deref, DerefMut};
 use parking_lot::Mutex;
-use std::{any::Any, future::Future, sync::Weak};
+use std::{future::Future, sync::Weak};
 
 #[derive(Clone)]
 pub struct AsyncAppContext {
@@ -22,7 +22,7 @@ impl Context for AsyncAppContext {
         build_entity: impl FnOnce(&mut Self::EntityContext<'_, '_, T>) -> T,
     ) -> Self::Result<Handle<T>>
     where
-        T: Any + Send + Sync,
+        T: 'static + Send,
     {
         let app = self
             .app
@@ -224,7 +224,7 @@ impl Context for AsyncWindowContext {
         build_entity: impl FnOnce(&mut Self::EntityContext<'_, '_, T>) -> T,
     ) -> Result<Handle<T>>
     where
-        T: Any + Send + Sync,
+        T: 'static + Send,
     {
         self.app
             .update_window(self.window, |cx| cx.entity(build_entity))

crates/gpui2/src/app/entity_map.rs 🔗

@@ -4,7 +4,7 @@ use derive_more::{Deref, DerefMut};
 use parking_lot::{RwLock, RwLockUpgradableReadGuard};
 use slotmap::{SecondaryMap, SlotMap};
 use std::{
-    any::{type_name, Any, TypeId},
+    any::{type_name, TypeId},
     fmt::{self, Display},
     hash::{Hash, Hasher},
     marker::PhantomData,
@@ -59,7 +59,7 @@ impl EntityMap {
     /// Insert an entity into a slot obtained by calling `reserve`.
     pub fn insert<T>(&mut self, slot: Slot<T>, entity: T) -> Handle<T>
     where
-        T: Any + Send + Sync,
+        T: 'static + Send,
     {
         let handle = slot.0;
         self.entities.insert(handle.entity_id, Box::new(entity));

crates/gpui2/src/app/model_context.rs 🔗

@@ -43,10 +43,10 @@ impl<'a, T: 'static> ModelContext<'a, T> {
     pub fn observe<T2: 'static>(
         &mut self,
         handle: &Handle<T2>,
-        mut on_notify: impl FnMut(&mut T, Handle<T2>, &mut ModelContext<'_, T>) + Send + Sync + 'static,
+        mut on_notify: impl FnMut(&mut T, Handle<T2>, &mut ModelContext<'_, T>) + Send + 'static,
     ) -> Subscription
     where
-        T: Any + Send + Sync,
+        T: 'static + Send,
     {
         let this = self.weak_handle();
         let handle = handle.downgrade();
@@ -68,11 +68,10 @@ impl<'a, T: 'static> ModelContext<'a, T> {
         handle: &Handle<E>,
         mut on_event: impl FnMut(&mut T, Handle<E>, &E::Event, &mut ModelContext<'_, T>)
             + Send
-            + Sync
             + 'static,
     ) -> Subscription
     where
-        T: Any + Send + Sync,
+        T: 'static + Send,
     {
         let this = self.weak_handle();
         let handle = handle.downgrade();
@@ -92,7 +91,7 @@ impl<'a, T: 'static> ModelContext<'a, T> {
 
     pub fn on_release(
         &mut self,
-        mut on_release: impl FnMut(&mut T, &mut AppContext) + Send + Sync + 'static,
+        mut on_release: impl FnMut(&mut T, &mut AppContext) + Send + 'static,
     ) -> Subscription
     where
         T: 'static,
@@ -109,10 +108,10 @@ impl<'a, T: 'static> ModelContext<'a, T> {
     pub fn observe_release<E: 'static>(
         &mut self,
         handle: &Handle<E>,
-        mut on_release: impl FnMut(&mut T, &mut E, &mut ModelContext<'_, T>) + Send + Sync + 'static,
+        mut on_release: impl FnMut(&mut T, &mut E, &mut ModelContext<'_, T>) + Send + 'static,
     ) -> Subscription
     where
-        T: Any + Send + Sync,
+        T: Any + Send,
     {
         let this = self.weak_handle();
         self.app.release_listeners.insert(
@@ -128,10 +127,10 @@ impl<'a, T: 'static> ModelContext<'a, T> {
 
     pub fn observe_global<G: 'static>(
         &mut self,
-        mut f: impl FnMut(&mut T, &mut ModelContext<'_, T>) + Send + Sync + 'static,
+        mut f: impl FnMut(&mut T, &mut ModelContext<'_, T>) + Send + 'static,
     ) -> Subscription
     where
-        T: Any + Send + Sync,
+        T: 'static + Send,
     {
         let handle = self.weak_handle();
         self.global_observers.insert(
@@ -142,11 +141,11 @@ impl<'a, T: 'static> ModelContext<'a, T> {
 
     pub fn on_app_quit<Fut>(
         &mut self,
-        mut on_quit: impl FnMut(&mut T, &mut ModelContext<T>) -> Fut + Send + Sync + 'static,
+        mut on_quit: impl FnMut(&mut T, &mut ModelContext<T>) -> Fut + Send + 'static,
     ) -> Subscription
     where
         Fut: 'static + Future<Output = ()> + Send,
-        T: Any + Send + Sync,
+        T: 'static + Send,
     {
         let handle = self.weak_handle();
         self.app.quit_observers.insert(
@@ -177,7 +176,7 @@ impl<'a, T: 'static> ModelContext<'a, T> {
 
     pub fn update_global<G, R>(&mut self, f: impl FnOnce(&mut G, &mut Self) -> R) -> R
     where
-        G: 'static + Send + Sync,
+        G: 'static + Send,
     {
         let mut global = self.app.lease_global::<G>();
         let result = f(&mut global, self);
@@ -214,7 +213,7 @@ impl<'a, T: 'static> ModelContext<'a, T> {
 impl<'a, T> ModelContext<'a, T>
 where
     T: EventEmitter,
-    T::Event: Send + Sync,
+    T::Event: Send,
 {
     pub fn emit(&mut self, event: T::Event) {
         self.app.pending_effects.push_back(Effect::Emit {
@@ -233,7 +232,7 @@ impl<'a, T> Context for ModelContext<'a, T> {
         build_entity: impl FnOnce(&mut Self::EntityContext<'_, '_, U>) -> U,
     ) -> Handle<U>
     where
-        U: 'static + Send + Sync,
+        U: 'static + Send,
     {
         self.app.entity(build_entity)
     }

crates/gpui2/src/app/test_context.rs 🔗

@@ -3,7 +3,7 @@ use crate::{
     ModelContext, Result, Task, TestDispatcher, TestPlatform, WindowContext,
 };
 use parking_lot::Mutex;
-use std::{any::Any, future::Future, sync::Arc};
+use std::{future::Future, sync::Arc};
 
 #[derive(Clone)]
 pub struct TestAppContext {
@@ -20,7 +20,7 @@ impl Context for TestAppContext {
         build_entity: impl FnOnce(&mut Self::EntityContext<'_, '_, T>) -> T,
     ) -> Self::Result<Handle<T>>
     where
-        T: Any + Send + Sync,
+        T: 'static + Send,
     {
         let mut lock = self.app.lock();
         lock.entity(build_entity)

crates/gpui2/src/element.rs 🔗

@@ -16,8 +16,6 @@ pub trait Element<V: 'static> {
         element_state: Option<Self::ElementState>,
         cx: &mut ViewContext<V>,
     ) -> Self::ElementState;
-    // where
-    //     V: Any + Send + Sync;
 
     fn layout(
         &mut self,
@@ -25,8 +23,6 @@ pub trait Element<V: 'static> {
         element_state: &mut Self::ElementState,
         cx: &mut ViewContext<V>,
     ) -> LayoutId;
-    // where
-    //     V: Any + Send + Sync;
 
     fn paint(
         &mut self,
@@ -35,9 +31,6 @@ pub trait Element<V: 'static> {
         element_state: &mut Self::ElementState,
         cx: &mut ViewContext<V>,
     );
-
-    // where
-    //     Self::ViewState: Any + Send + Sync;
 }
 
 #[derive(Deref, DerefMut, Default, Clone, Debug, Eq, PartialEq, Hash)]
@@ -104,8 +97,7 @@ impl<V, E: Element<V>> RenderedElement<V, E> {
 impl<V, E> ElementObject<V> for RenderedElement<V, E>
 where
     E: Element<V>,
-    // E::ViewState: Any + Send + Sync,
-    E::ElementState: Any + Send + Sync,
+    E::ElementState: 'static + Send,
 {
     fn initialize(&mut self, view_state: &mut V, cx: &mut ViewContext<V>) {
         let frame_state = if let Some(id) = self.element.id() {
@@ -178,18 +170,16 @@ where
     }
 }
 
-pub struct AnyElement<V>(Box<dyn ElementObject<V> + Send + Sync>);
+pub struct AnyElement<V>(Box<dyn ElementObject<V> + Send>);
 
 unsafe impl<V> Send for AnyElement<V> {}
-unsafe impl<V> Sync for AnyElement<V> {}
 
 impl<V> AnyElement<V> {
     pub fn new<E>(element: E) -> Self
     where
         V: 'static,
-        E: 'static + Send + Sync,
-        E: Element<V>,
-        E::ElementState: Any + Send + Sync,
+        E: 'static + Element<V> + Send,
+        E::ElementState: Any + Send,
     {
         AnyElement(Box::new(RenderedElement::new(element)))
     }
@@ -230,8 +220,8 @@ impl<V> Component<V> for AnyElement<V> {
 impl<V, E, F> Element<V> for Option<F>
 where
     V: 'static,
-    E: 'static + Component<V> + Send + Sync,
-    F: FnOnce(&mut V, &mut ViewContext<'_, '_, V>) -> E + Send + Sync + 'static,
+    E: 'static + Component<V> + Send,
+    F: FnOnce(&mut V, &mut ViewContext<'_, '_, V>) -> E + Send + 'static,
 {
     type ElementState = AnyElement<V>;
 
@@ -274,8 +264,8 @@ where
 impl<V, E, F> Component<V> for Option<F>
 where
     V: 'static,
-    E: 'static + Component<V> + Send + Sync,
-    F: FnOnce(&mut V, &mut ViewContext<'_, '_, V>) -> E + Send + Sync + 'static,
+    E: 'static + Component<V> + Send,
+    F: FnOnce(&mut V, &mut ViewContext<'_, '_, V>) -> E + Send + 'static,
 {
     fn render(self) -> AnyElement<V> {
         AnyElement::new(self)
@@ -285,8 +275,8 @@ where
 impl<V, E, F> Component<V> for F
 where
     V: 'static,
-    E: 'static + Component<V> + Send + Sync,
-    F: FnOnce(&mut V, &mut ViewContext<'_, '_, V>) -> E + Send + Sync + 'static,
+    E: 'static + Component<V> + Send,
+    F: FnOnce(&mut V, &mut ViewContext<'_, '_, V>) -> E + Send + 'static,
 {
     fn render(self) -> AnyElement<V> {
         AnyElement::new(Some(self))

crates/gpui2/src/focusable.rs 🔗

@@ -4,12 +4,11 @@ use crate::{
 };
 use refineable::Refineable;
 use smallvec::SmallVec;
-use std::sync::Arc;
 
 pub type FocusListeners<V> = SmallVec<[FocusListener<V>; 2]>;
 
 pub type FocusListener<V> =
-    Arc<dyn Fn(&mut V, &FocusHandle, &FocusEvent, &mut ViewContext<V>) + Send + Sync + 'static>;
+    Box<dyn Fn(&mut V, &FocusHandle, &FocusEvent, &mut ViewContext<V>) + Send + 'static>;
 
 pub trait Focusable<V: 'static>: Element<V> {
     fn focus_listeners(&mut self) -> &mut FocusListeners<V>;
@@ -43,13 +42,13 @@ pub trait Focusable<V: 'static>: Element<V> {
 
     fn on_focus(
         mut self,
-        listener: impl Fn(&mut V, &FocusEvent, &mut ViewContext<V>) + Send + Sync + 'static,
+        listener: impl Fn(&mut V, &FocusEvent, &mut ViewContext<V>) + Send + 'static,
     ) -> Self
     where
         Self: Sized,
     {
         self.focus_listeners()
-            .push(Arc::new(move |view, focus_handle, event, cx| {
+            .push(Box::new(move |view, focus_handle, event, cx| {
                 if event.focused.as_ref() == Some(focus_handle) {
                     listener(view, event, cx)
                 }
@@ -59,13 +58,13 @@ pub trait Focusable<V: 'static>: Element<V> {
 
     fn on_blur(
         mut self,
-        listener: impl Fn(&mut V, &FocusEvent, &mut ViewContext<V>) + Send + Sync + 'static,
+        listener: impl Fn(&mut V, &FocusEvent, &mut ViewContext<V>) + Send + 'static,
     ) -> Self
     where
         Self: Sized,
     {
         self.focus_listeners()
-            .push(Arc::new(move |view, focus_handle, event, cx| {
+            .push(Box::new(move |view, focus_handle, event, cx| {
                 if event.blurred.as_ref() == Some(focus_handle) {
                     listener(view, event, cx)
                 }
@@ -75,13 +74,13 @@ pub trait Focusable<V: 'static>: Element<V> {
 
     fn on_focus_in(
         mut self,
-        listener: impl Fn(&mut V, &FocusEvent, &mut ViewContext<V>) + Send + Sync + 'static,
+        listener: impl Fn(&mut V, &FocusEvent, &mut ViewContext<V>) + Send + 'static,
     ) -> Self
     where
         Self: Sized,
     {
         self.focus_listeners()
-            .push(Arc::new(move |view, focus_handle, event, cx| {
+            .push(Box::new(move |view, focus_handle, event, cx| {
                 let descendant_blurred = event
                     .blurred
                     .as_ref()
@@ -100,13 +99,13 @@ pub trait Focusable<V: 'static>: Element<V> {
 
     fn on_focus_out(
         mut self,
-        listener: impl Fn(&mut V, &FocusEvent, &mut ViewContext<V>) + Send + Sync + 'static,
+        listener: impl Fn(&mut V, &FocusEvent, &mut ViewContext<V>) + Send + 'static,
     ) -> Self
     where
         Self: Sized,
     {
         self.focus_listeners()
-            .push(Arc::new(move |view, focus_handle, event, cx| {
+            .push(Box::new(move |view, focus_handle, event, cx| {
                 let descendant_blurred = event
                     .blurred
                     .as_ref()
@@ -123,7 +122,7 @@ pub trait Focusable<V: 'static>: Element<V> {
     }
 }
 
-pub trait ElementFocus<V: 'static>: 'static + Send + Sync {
+pub trait ElementFocus<V: 'static>: 'static + Send {
     fn as_focusable(&self) -> Option<&FocusEnabled<V>>;
     fn as_focusable_mut(&mut self) -> Option<&mut FocusEnabled<V>>;
 
@@ -138,7 +137,7 @@ pub trait ElementFocus<V: 'static>: 'static + Send + Sync {
                 .focus_handle
                 .get_or_insert_with(|| focus_handle.unwrap_or_else(|| cx.focus_handle()))
                 .clone();
-            for listener in focusable.focus_listeners.iter().cloned() {
+            for listener in focusable.focus_listeners.drain(..) {
                 let focus_handle = focus_handle.clone();
                 cx.on_focus_changed(move |view, event, cx| {
                     listener(view, &focus_handle, event, cx)

crates/gpui2/src/gpui2.rs 🔗

@@ -67,7 +67,7 @@ use std::{
 };
 use taffy::TaffyLayoutEngine;
 
-type AnyBox = Box<dyn Any + Send + Sync>;
+type AnyBox = Box<dyn Any + Send>;
 
 pub trait Context {
     type EntityContext<'a, 'w, T>;
@@ -78,7 +78,7 @@ pub trait Context {
         build_entity: impl FnOnce(&mut Self::EntityContext<'_, '_, T>) -> T,
     ) -> Self::Result<Handle<T>>
     where
-        T: 'static + Send + Sync;
+        T: 'static + Send;
 
     fn update_entity<T: 'static, R>(
         &mut self,
@@ -119,7 +119,7 @@ impl<C: Context> Context for MainThread<C> {
         build_entity: impl FnOnce(&mut Self::EntityContext<'_, '_, T>) -> T,
     ) -> Self::Result<Handle<T>>
     where
-        T: Any + Send + Sync,
+        T: 'static + Send,
     {
         self.0.entity(|cx| {
             let cx = unsafe {
@@ -154,7 +154,7 @@ pub trait BorrowAppContext {
     where
         F: FnOnce(&mut Self) -> R;
 
-    fn set_global<T: Send + Sync + 'static>(&mut self, global: T);
+    fn set_global<T: Send + 'static>(&mut self, global: T);
 }
 
 impl<C> BorrowAppContext for C
@@ -171,7 +171,7 @@ where
         result
     }
 
-    fn set_global<G: 'static + Send + Sync>(&mut self, global: G) {
+    fn set_global<G: 'static + Send>(&mut self, global: G) {
         self.borrow_mut().set_global(global)
     }
 }

crates/gpui2/src/interactive.rs 🔗

@@ -12,6 +12,7 @@ use std::{
     any::{Any, TypeId},
     fmt::Debug,
     marker::PhantomData,
+    mem,
     ops::Deref,
     path::PathBuf,
     sync::Arc,
@@ -48,14 +49,14 @@ pub trait StatelessInteractive<V: 'static>: Element<V> {
     fn on_mouse_down(
         mut self,
         button: MouseButton,
-        handler: impl Fn(&mut V, &MouseDownEvent, &mut ViewContext<V>) + Send + Sync + 'static,
+        handler: impl Fn(&mut V, &MouseDownEvent, &mut ViewContext<V>) + Send + 'static,
     ) -> Self
     where
         Self: Sized,
     {
         self.stateless_interaction()
             .mouse_down_listeners
-            .push(Arc::new(move |view, event, bounds, phase, cx| {
+            .push(Box::new(move |view, event, bounds, phase, cx| {
                 if phase == DispatchPhase::Bubble
                     && event.button == button
                     && bounds.contains_point(&event.position)
@@ -69,14 +70,14 @@ pub trait StatelessInteractive<V: 'static>: Element<V> {
     fn on_mouse_up(
         mut self,
         button: MouseButton,
-        handler: impl Fn(&mut V, &MouseUpEvent, &mut ViewContext<V>) + Send + Sync + 'static,
+        handler: impl Fn(&mut V, &MouseUpEvent, &mut ViewContext<V>) + Send + 'static,
     ) -> Self
     where
         Self: Sized,
     {
         self.stateless_interaction()
             .mouse_up_listeners
-            .push(Arc::new(move |view, event, bounds, phase, cx| {
+            .push(Box::new(move |view, event, bounds, phase, cx| {
                 if phase == DispatchPhase::Bubble
                     && event.button == button
                     && bounds.contains_point(&event.position)
@@ -90,14 +91,14 @@ pub trait StatelessInteractive<V: 'static>: Element<V> {
     fn on_mouse_down_out(
         mut self,
         button: MouseButton,
-        handler: impl Fn(&mut V, &MouseDownEvent, &mut ViewContext<V>) + Send + Sync + 'static,
+        handler: impl Fn(&mut V, &MouseDownEvent, &mut ViewContext<V>) + Send + 'static,
     ) -> Self
     where
         Self: Sized,
     {
         self.stateless_interaction()
             .mouse_down_listeners
-            .push(Arc::new(move |view, event, bounds, phase, cx| {
+            .push(Box::new(move |view, event, bounds, phase, cx| {
                 if phase == DispatchPhase::Capture
                     && event.button == button
                     && !bounds.contains_point(&event.position)
@@ -111,14 +112,14 @@ pub trait StatelessInteractive<V: 'static>: Element<V> {
     fn on_mouse_up_out(
         mut self,
         button: MouseButton,
-        handler: impl Fn(&mut V, &MouseUpEvent, &mut ViewContext<V>) + Send + Sync + 'static,
+        handler: impl Fn(&mut V, &MouseUpEvent, &mut ViewContext<V>) + Send + 'static,
     ) -> Self
     where
         Self: Sized,
     {
         self.stateless_interaction()
             .mouse_up_listeners
-            .push(Arc::new(move |view, event, bounds, phase, cx| {
+            .push(Box::new(move |view, event, bounds, phase, cx| {
                 if phase == DispatchPhase::Capture
                     && event.button == button
                     && !bounds.contains_point(&event.position)
@@ -131,14 +132,14 @@ pub trait StatelessInteractive<V: 'static>: Element<V> {
 
     fn on_mouse_move(
         mut self,
-        handler: impl Fn(&mut V, &MouseMoveEvent, &mut ViewContext<V>) + Send + Sync + 'static,
+        handler: impl Fn(&mut V, &MouseMoveEvent, &mut ViewContext<V>) + Send + 'static,
     ) -> Self
     where
         Self: Sized,
     {
         self.stateless_interaction()
             .mouse_move_listeners
-            .push(Arc::new(move |view, event, bounds, phase, cx| {
+            .push(Box::new(move |view, event, bounds, phase, cx| {
                 if phase == DispatchPhase::Bubble && bounds.contains_point(&event.position) {
                     handler(view, event, cx);
                 }
@@ -148,14 +149,14 @@ pub trait StatelessInteractive<V: 'static>: Element<V> {
 
     fn on_scroll_wheel(
         mut self,
-        handler: impl Fn(&mut V, &ScrollWheelEvent, &mut ViewContext<V>) + Send + Sync + 'static,
+        handler: impl Fn(&mut V, &ScrollWheelEvent, &mut ViewContext<V>) + Send + 'static,
     ) -> Self
     where
         Self: Sized,
     {
         self.stateless_interaction()
             .scroll_wheel_listeners
-            .push(Arc::new(move |view, event, bounds, phase, cx| {
+            .push(Box::new(move |view, event, bounds, phase, cx| {
                 if phase == DispatchPhase::Bubble && bounds.contains_point(&event.position) {
                     handler(view, event, cx);
                 }
@@ -176,14 +177,14 @@ pub trait StatelessInteractive<V: 'static>: Element<V> {
 
     fn on_action<A: 'static>(
         mut self,
-        listener: impl Fn(&mut V, &A, DispatchPhase, &mut ViewContext<V>) + Send + Sync + 'static,
+        listener: impl Fn(&mut V, &A, DispatchPhase, &mut ViewContext<V>) + Send + 'static,
     ) -> Self
     where
         Self: Sized,
     {
         self.stateless_interaction().key_listeners.push((
             TypeId::of::<A>(),
-            Arc::new(move |view, event, _, phase, cx| {
+            Box::new(move |view, event, _, phase, cx| {
                 let event = event.downcast_ref().unwrap();
                 listener(view, event, phase, cx);
                 None
@@ -194,17 +195,14 @@ pub trait StatelessInteractive<V: 'static>: Element<V> {
 
     fn on_key_down(
         mut self,
-        listener: impl Fn(&mut V, &KeyDownEvent, DispatchPhase, &mut ViewContext<V>)
-            + Send
-            + Sync
-            + 'static,
+        listener: impl Fn(&mut V, &KeyDownEvent, DispatchPhase, &mut ViewContext<V>) + Send + 'static,
     ) -> Self
     where
         Self: Sized,
     {
         self.stateless_interaction().key_listeners.push((
             TypeId::of::<KeyDownEvent>(),
-            Arc::new(move |view, event, _, phase, cx| {
+            Box::new(move |view, event, _, phase, cx| {
                 let event = event.downcast_ref().unwrap();
                 listener(view, event, phase, cx);
                 None
@@ -215,17 +213,14 @@ pub trait StatelessInteractive<V: 'static>: Element<V> {
 
     fn on_key_up(
         mut self,
-        listener: impl Fn(&mut V, &KeyUpEvent, DispatchPhase, &mut ViewContext<V>)
-            + Send
-            + Sync
-            + 'static,
+        listener: impl Fn(&mut V, &KeyUpEvent, DispatchPhase, &mut ViewContext<V>) + Send + 'static,
     ) -> Self
     where
         Self: Sized,
     {
         self.stateless_interaction().key_listeners.push((
             TypeId::of::<KeyUpEvent>(),
-            Arc::new(move |view, event, _, phase, cx| {
+            Box::new(move |view, event, _, phase, cx| {
                 let event = event.downcast_ref().unwrap();
                 listener(view, event, phase, cx);
                 None
@@ -264,14 +259,14 @@ pub trait StatelessInteractive<V: 'static>: Element<V> {
 
     fn on_drop<S: 'static>(
         mut self,
-        listener: impl Fn(&mut V, S, &mut ViewContext<V>) + Send + Sync + 'static,
+        listener: impl Fn(&mut V, S, &mut ViewContext<V>) + Send + 'static,
     ) -> Self
     where
         Self: Sized,
     {
         self.stateless_interaction().drop_listeners.push((
             TypeId::of::<S>(),
-            Arc::new(move |view, drag_state, cx| {
+            Box::new(move |view, drag_state, cx| {
                 listener(view, *drag_state.downcast().unwrap(), cx);
             }),
         ));
@@ -307,26 +302,26 @@ pub trait StatefulInteractive<V: 'static>: StatelessInteractive<V> {
 
     fn on_click(
         mut self,
-        listener: impl Fn(&mut V, &ClickEvent, &mut ViewContext<V>) + Send + Sync + 'static,
+        listener: impl Fn(&mut V, &ClickEvent, &mut ViewContext<V>) + Send + 'static,
     ) -> Self
     where
         Self: Sized,
     {
         self.stateful_interaction()
             .click_listeners
-            .push(Arc::new(move |view, event, cx| listener(view, event, cx)));
+            .push(Box::new(move |view, event, cx| listener(view, event, cx)));
         self
     }
 
     fn on_drag<S, R, E>(
         mut self,
-        listener: impl Fn(&mut V, &mut ViewContext<V>) -> Drag<S, R, V, E> + Send + Sync + 'static,
+        listener: impl Fn(&mut V, &mut ViewContext<V>) -> Drag<S, R, V, E> + Send + 'static,
     ) -> Self
     where
         Self: Sized,
-        S: Any + Send + Sync,
+        S: Any + Send,
         R: Fn(&mut V, &mut ViewContext<V>) -> E,
-        R: 'static + Send + Sync,
+        R: 'static + Send,
         E: Component<V>,
     {
         debug_assert!(
@@ -334,7 +329,7 @@ pub trait StatefulInteractive<V: 'static>: StatelessInteractive<V> {
             "calling on_drag more than once on the same element is not supported"
         );
         self.stateful_interaction().drag_listener =
-            Some(Arc::new(move |view_state, cursor_offset, cx| {
+            Some(Box::new(move |view_state, cursor_offset, cx| {
                 let drag = listener(view_state, cx);
                 let view_handle = cx.handle().upgrade().unwrap();
                 let drag_handle_view = Some(
@@ -354,7 +349,7 @@ pub trait StatefulInteractive<V: 'static>: StatelessInteractive<V> {
     }
 }
 
-pub trait ElementInteraction<V: 'static>: 'static + Send + Sync {
+pub trait ElementInteraction<V: 'static>: 'static + Send {
     fn as_stateless(&self) -> &StatelessInteraction<V>;
     fn as_stateless_mut(&mut self) -> &mut StatelessInteraction<V>;
     fn as_stateful(&self) -> Option<&StatefulInteraction<V>>;
@@ -369,7 +364,7 @@ pub trait ElementInteraction<V: 'static>: 'static + Send + Sync {
             cx.with_element_id(stateful.id.clone(), |global_id, cx| {
                 stateful.key_listeners.push((
                     TypeId::of::<KeyDownEvent>(),
-                    Arc::new(move |_, key_down, context, phase, cx| {
+                    Box::new(move |_, key_down, context, phase, cx| {
                         if phase == DispatchPhase::Bubble {
                             let key_down = key_down.downcast_ref::<KeyDownEvent>().unwrap();
                             if let KeyMatch::Some(action) =
@@ -387,9 +382,9 @@ pub trait ElementInteraction<V: 'static>: 'static + Send + Sync {
                 result
             })
         } else {
-            let stateless = self.as_stateless();
+            let stateless = self.as_stateless_mut();
             cx.with_key_dispatch_context(stateless.dispatch_context.clone(), |cx| {
-                cx.with_key_listeners(&stateless.key_listeners, f)
+                cx.with_key_listeners(mem::take(&mut stateless.key_listeners), f)
             })
         }
     }
@@ -455,26 +450,26 @@ pub trait ElementInteraction<V: 'static>: 'static + Send + Sync {
         element_state: &mut InteractiveElementState,
         cx: &mut ViewContext<V>,
     ) {
-        let stateless = self.as_stateless();
-        for listener in stateless.mouse_down_listeners.iter().cloned() {
+        let stateless = self.as_stateless_mut();
+        for listener in stateless.mouse_down_listeners.drain(..) {
             cx.on_mouse_event(move |state, event: &MouseDownEvent, phase, cx| {
                 listener(state, event, &bounds, phase, cx);
             })
         }
 
-        for listener in stateless.mouse_up_listeners.iter().cloned() {
+        for listener in stateless.mouse_up_listeners.drain(..) {
             cx.on_mouse_event(move |state, event: &MouseUpEvent, phase, cx| {
                 listener(state, event, &bounds, phase, cx);
             })
         }
 
-        for listener in stateless.mouse_move_listeners.iter().cloned() {
+        for listener in stateless.mouse_move_listeners.drain(..) {
             cx.on_mouse_event(move |state, event: &MouseMoveEvent, phase, cx| {
                 listener(state, event, &bounds, phase, cx);
             })
         }
 
-        for listener in stateless.scroll_wheel_listeners.iter().cloned() {
+        for listener in stateless.scroll_wheel_listeners.drain(..) {
             cx.on_mouse_event(move |state, event: &ScrollWheelEvent, phase, cx| {
                 listener(state, event, &bounds, phase, cx);
             })
@@ -510,7 +505,7 @@ pub trait ElementInteraction<V: 'static>: 'static + Send + Sync {
         }
 
         if cx.active_drag.is_some() {
-            let drop_listeners = stateless.drop_listeners.clone();
+            let drop_listeners = mem::take(&mut stateless.drop_listeners);
             cx.on_mouse_event(move |view, event: &MouseUpEvent, phase, cx| {
                 if phase == DispatchPhase::Bubble && bounds.contains_point(&event.position) {
                     if let Some(drag_state_type) =
@@ -532,9 +527,9 @@ pub trait ElementInteraction<V: 'static>: 'static + Send + Sync {
             });
         }
 
-        if let Some(stateful) = self.as_stateful() {
-            let click_listeners = stateful.click_listeners.clone();
-            let drag_listener = stateful.drag_listener.clone();
+        if let Some(stateful) = self.as_stateful_mut() {
+            let click_listeners = mem::take(&mut stateful.click_listeners);
+            let drag_listener = mem::take(&mut stateful.drag_listener);
 
             if !click_listeners.is_empty() || drag_listener.is_some() {
                 let pending_mouse_down = element_state.pending_mouse_down.clone();
@@ -690,7 +685,7 @@ impl<V> From<ElementId> for StatefulInteraction<V> {
     }
 }
 
-type DropListener<V> = dyn Fn(&mut V, AnyBox, &mut ViewContext<V>) + 'static + Send + Sync;
+type DropListener<V> = dyn Fn(&mut V, AnyBox, &mut ViewContext<V>) + 'static + Send;
 
 pub struct StatelessInteraction<V> {
     pub dispatch_context: DispatchContext,
@@ -703,7 +698,7 @@ pub struct StatelessInteraction<V> {
     pub group_hover_style: Option<GroupStyle>,
     drag_over_styles: SmallVec<[(TypeId, StyleRefinement); 2]>,
     group_drag_over_styles: SmallVec<[(TypeId, GroupStyle); 2]>,
-    drop_listeners: SmallVec<[(TypeId, Arc<DropListener<V>>); 2]>,
+    drop_listeners: SmallVec<[(TypeId, Box<DropListener<V>>); 2]>,
 }
 
 impl<V> StatelessInteraction<V> {
@@ -1082,40 +1077,35 @@ pub struct FocusEvent {
     pub focused: Option<FocusHandle>,
 }
 
-pub type MouseDownListener<V> = Arc<
+pub type MouseDownListener<V> = Box<
     dyn Fn(&mut V, &MouseDownEvent, &Bounds<Pixels>, DispatchPhase, &mut ViewContext<V>)
         + Send
-        + Sync
         + 'static,
 >;
-pub type MouseUpListener<V> = Arc<
+pub type MouseUpListener<V> = Box<
     dyn Fn(&mut V, &MouseUpEvent, &Bounds<Pixels>, DispatchPhase, &mut ViewContext<V>)
         + Send
-        + Sync
         + 'static,
 >;
 
-pub type MouseMoveListener<V> = Arc<
+pub type MouseMoveListener<V> = Box<
     dyn Fn(&mut V, &MouseMoveEvent, &Bounds<Pixels>, DispatchPhase, &mut ViewContext<V>)
         + Send
-        + Sync
         + 'static,
 >;
 
-pub type ScrollWheelListener<V> = Arc<
+pub type ScrollWheelListener<V> = Box<
     dyn Fn(&mut V, &ScrollWheelEvent, &Bounds<Pixels>, DispatchPhase, &mut ViewContext<V>)
         + Send
-        + Sync
         + 'static,
 >;
 
-pub type ClickListener<V> =
-    Arc<dyn Fn(&mut V, &ClickEvent, &mut ViewContext<V>) + Send + Sync + 'static>;
+pub type ClickListener<V> = Box<dyn Fn(&mut V, &ClickEvent, &mut ViewContext<V>) + Send + 'static>;
 
 pub(crate) type DragListener<V> =
-    Arc<dyn Fn(&mut V, Point<Pixels>, &mut ViewContext<V>) -> AnyDrag + Send + Sync + 'static>;
+    Box<dyn Fn(&mut V, Point<Pixels>, &mut ViewContext<V>) -> AnyDrag + Send + 'static>;
 
-pub type KeyListener<V> = Arc<
+pub type KeyListener<V> = Box<
     dyn Fn(
             &mut V,
             &dyn Any,
@@ -1124,6 +1114,5 @@ pub type KeyListener<V> = Arc<
             &mut ViewContext<V>,
         ) -> Option<Box<dyn Action>>
         + Send
-        + Sync
         + 'static,
 >;

crates/gpui2/src/keymap/matcher.rs 🔗

@@ -1,17 +1,17 @@
 use crate::{Action, DispatchContext, Keymap, KeymapVersion, Keystroke};
-use parking_lot::RwLock;
+use parking_lot::Mutex;
 use smallvec::SmallVec;
 use std::sync::Arc;
 
 pub struct KeyMatcher {
     pending_keystrokes: Vec<Keystroke>,
-    keymap: Arc<RwLock<Keymap>>,
+    keymap: Arc<Mutex<Keymap>>,
     keymap_version: KeymapVersion,
 }
 
 impl KeyMatcher {
-    pub fn new(keymap: Arc<RwLock<Keymap>>) -> Self {
-        let keymap_version = keymap.read().version();
+    pub fn new(keymap: Arc<Mutex<Keymap>>) -> Self {
+        let keymap_version = keymap.lock().version();
         Self {
             pending_keystrokes: Vec::new(),
             keymap_version,
@@ -21,7 +21,7 @@ impl KeyMatcher {
 
     // todo!("replace with a function that calls an FnMut for every binding matching the action")
     // pub fn bindings_for_action(&self, action_id: TypeId) -> impl Iterator<Item = &Binding> {
-    //     self.keymap.read().bindings_for_action(action_id)
+    //     self.keymap.lock().bindings_for_action(action_id)
     // }
 
     pub fn clear_pending(&mut self) {
@@ -46,7 +46,7 @@ impl KeyMatcher {
         keystroke: &Keystroke,
         context_stack: &[&DispatchContext],
     ) -> KeyMatch {
-        let keymap = self.keymap.read();
+        let keymap = self.keymap.lock();
         // Clear pending keystrokes if the keymap has changed since the last matched keystroke.
         if keymap.version() != self.keymap_version {
             self.keymap_version = keymap.version();
@@ -89,7 +89,7 @@ impl KeyMatcher {
         contexts: &[&DispatchContext],
     ) -> Option<SmallVec<[Keystroke; 2]>> {
         self.keymap
-            .read()
+            .lock()
             .bindings()
             .iter()
             .rev()

crates/gpui2/src/subscription.rs 🔗

@@ -21,8 +21,8 @@ struct SubscriberSetState<EmitterKey, Callback> {
 
 impl<EmitterKey, Callback> SubscriberSet<EmitterKey, Callback>
 where
-    EmitterKey: 'static + Send + Sync + Ord + Clone + Debug,
-    Callback: 'static + Send + Sync,
+    EmitterKey: 'static + Send + Ord + Clone + Debug,
+    Callback: 'static + Send,
 {
     pub fn new() -> Self {
         Self(Arc::new(Mutex::new(SubscriberSetState {
@@ -96,7 +96,7 @@ where
 
 #[must_use]
 pub struct Subscription {
-    unsubscribe: Option<Box<dyn FnOnce() + Send + Sync + 'static>>,
+    unsubscribe: Option<Box<dyn FnOnce() + Send + 'static>>,
 }
 
 impl Subscription {

crates/gpui2/src/taffy.rs 🔗

@@ -53,10 +53,7 @@ impl TaffyLayoutEngine {
         &mut self,
         style: Style,
         rem_size: Pixels,
-        measure: impl Fn(Size<Option<Pixels>>, Size<AvailableSpace>) -> Size<Pixels>
-            + Send
-            + Sync
-            + 'static,
+        measure: impl Fn(Size<Option<Pixels>>, Size<AvailableSpace>) -> Size<Pixels> + Send + Sync + 'static,
     ) -> LayoutId {
         let style = style.to_taffy(rem_size);
 
@@ -179,7 +176,7 @@ struct Measureable<F>(F);
 
 impl<F> taffy::tree::Measurable for Measureable<F>
 where
-    F: Send + Sync + Fn(Size<Option<Pixels>>, Size<AvailableSpace>) -> Size<Pixels>,
+    F: Fn(Size<Option<Pixels>>, Size<AvailableSpace>) -> Size<Pixels> + Send + Sync,
 {
     fn measure(
         &self,

crates/gpui2/src/view.rs 🔗

@@ -8,14 +8,12 @@ use std::{marker::PhantomData, sync::Arc};
 
 pub struct View<V> {
     state: Handle<V>,
-    render: Arc<dyn Fn(&mut V, &mut ViewContext<V>) -> AnyElement<V> + Send + Sync + 'static>,
+    render: Arc<Mutex<dyn Fn(&mut V, &mut ViewContext<V>) -> AnyElement<V> + Send + 'static>>,
 }
 
 impl<V: 'static> View<V> {
     pub fn into_any(self) -> AnyView {
-        AnyView {
-            view: Arc::new(Mutex::new(self)),
-        }
+        AnyView(Arc::new(self))
     }
 }
 
@@ -30,14 +28,16 @@ impl<V> Clone for View<V> {
 
 pub fn view<V, E>(
     state: Handle<V>,
-    render: impl Fn(&mut V, &mut ViewContext<V>) -> E + Send + Sync + 'static,
+    render: impl Fn(&mut V, &mut ViewContext<'_, '_, V>) -> E + Send + 'static,
 ) -> View<V>
 where
     E: Component<V>,
 {
     View {
         state,
-        render: Arc::new(move |state, cx| render(state, cx).render()),
+        render: Arc::new(Mutex::new(
+            move |state: &mut V, cx: &mut ViewContext<'_, '_, V>| render(state, cx).render(),
+        )),
     }
 }
 
@@ -64,7 +64,7 @@ impl<V: 'static> Element<()> for View<V> {
         cx: &mut ViewContext<()>,
     ) -> Self::ElementState {
         self.state.update(cx, |state, cx| {
-            let mut any_element = (self.render)(state, cx);
+            let mut any_element = (self.render.lock())(state, cx);
             any_element.initialize(state, cx);
             any_element
         })
@@ -96,7 +96,6 @@ struct EraseViewState<V, ParentV> {
 }
 
 unsafe impl<V, ParentV> Send for EraseViewState<V, ParentV> {}
-unsafe impl<V, ParentV> Sync for EraseViewState<V, ParentV> {}
 
 impl<V: 'static, ParentV: 'static> Component<ParentV> for EraseViewState<V, ParentV> {
     fn render(self) -> AnyElement<ParentV> {
@@ -142,9 +141,9 @@ impl<V: 'static, ParentV: 'static> Element<ParentV> for EraseViewState<V, Parent
 
 trait ViewObject: Send + Sync {
     fn entity_id(&self) -> EntityId;
-    fn initialize(&mut self, cx: &mut WindowContext) -> AnyBox;
-    fn layout(&mut self, element: &mut AnyBox, cx: &mut WindowContext) -> LayoutId;
-    fn paint(&mut self, bounds: Bounds<Pixels>, element: &mut AnyBox, cx: &mut WindowContext);
+    fn initialize(&self, cx: &mut WindowContext) -> AnyBox;
+    fn layout(&self, element: &mut AnyBox, cx: &mut WindowContext) -> LayoutId;
+    fn paint(&self, bounds: Bounds<Pixels>, element: &mut AnyBox, cx: &mut WindowContext);
 }
 
 impl<V: 'static> ViewObject for View<V> {
@@ -152,17 +151,17 @@ impl<V: 'static> ViewObject for View<V> {
         self.state.entity_id
     }
 
-    fn initialize(&mut self, cx: &mut WindowContext) -> AnyBox {
+    fn initialize(&self, cx: &mut WindowContext) -> AnyBox {
         cx.with_element_id(self.entity_id(), |_global_id, cx| {
             self.state.update(cx, |state, cx| {
-                let mut any_element = Box::new((self.render)(state, cx));
+                let mut any_element = Box::new((self.render.lock())(state, cx));
                 any_element.initialize(state, cx);
                 any_element as AnyBox
             })
         })
     }
 
-    fn layout(&mut self, element: &mut AnyBox, cx: &mut WindowContext) -> LayoutId {
+    fn layout(&self, element: &mut AnyBox, cx: &mut WindowContext) -> LayoutId {
         cx.with_element_id(self.entity_id(), |_global_id, cx| {
             self.state.update(cx, |state, cx| {
                 let element = element.downcast_mut::<AnyElement<V>>().unwrap();
@@ -171,7 +170,7 @@ impl<V: 'static> ViewObject for View<V> {
         })
     }
 
-    fn paint(&mut self, _: Bounds<Pixels>, element: &mut AnyBox, cx: &mut WindowContext) {
+    fn paint(&self, _: Bounds<Pixels>, element: &mut AnyBox, cx: &mut WindowContext) {
         cx.with_element_id(self.entity_id(), |_global_id, cx| {
             self.state.update(cx, |state, cx| {
                 let element = element.downcast_mut::<AnyElement<V>>().unwrap();
@@ -181,9 +180,8 @@ impl<V: 'static> ViewObject for View<V> {
     }
 }
 
-pub struct AnyView {
-    view: Arc<Mutex<dyn ViewObject>>,
-}
+#[derive(Clone)]
+pub struct AnyView(Arc<dyn ViewObject>);
 
 impl<ParentV: 'static> Component<ParentV> for AnyView {
     fn render(self) -> AnyElement<ParentV> {
@@ -198,7 +196,7 @@ impl Element<()> for AnyView {
     type ElementState = AnyBox;
 
     fn id(&self) -> Option<crate::ElementId> {
-        Some(ElementId::View(self.view.lock().entity_id()))
+        Some(ElementId::View(self.0.entity_id()))
     }
 
     fn initialize(
@@ -207,7 +205,7 @@ impl Element<()> for AnyView {
         _: Option<Self::ElementState>,
         cx: &mut ViewContext<()>,
     ) -> Self::ElementState {
-        self.view.lock().initialize(cx)
+        self.0.initialize(cx)
     }
 
     fn layout(
@@ -216,7 +214,7 @@ impl Element<()> for AnyView {
         element: &mut Self::ElementState,
         cx: &mut ViewContext<()>,
     ) -> LayoutId {
-        self.view.lock().layout(element, cx)
+        self.0.layout(element, cx)
     }
 
     fn paint(
@@ -226,7 +224,7 @@ impl Element<()> for AnyView {
         element: &mut AnyBox,
         cx: &mut ViewContext<()>,
     ) {
-        self.view.lock().paint(bounds, element, cx)
+        self.0.paint(bounds, element, cx)
     }
 }
 
@@ -236,7 +234,6 @@ struct EraseAnyViewState<ParentViewState> {
 }
 
 unsafe impl<ParentV> Send for EraseAnyViewState<ParentV> {}
-unsafe impl<ParentV> Sync for EraseAnyViewState<ParentV> {}
 
 impl<ParentV: 'static> Component<ParentV> for EraseAnyViewState<ParentV> {
     fn render(self) -> AnyElement<ParentV> {
@@ -257,7 +254,7 @@ impl<ParentV: 'static> Element<ParentV> for EraseAnyViewState<ParentV> {
         _: Option<Self::ElementState>,
         cx: &mut ViewContext<ParentV>,
     ) -> Self::ElementState {
-        self.view.view.lock().initialize(cx)
+        self.view.0.initialize(cx)
     }
 
     fn layout(
@@ -266,7 +263,7 @@ impl<ParentV: 'static> Element<ParentV> for EraseAnyViewState<ParentV> {
         element: &mut Self::ElementState,
         cx: &mut ViewContext<ParentV>,
     ) -> LayoutId {
-        self.view.view.lock().layout(element, cx)
+        self.view.0.layout(element, cx)
     }
 
     fn paint(
@@ -276,14 +273,6 @@ impl<ParentV: 'static> Element<ParentV> for EraseAnyViewState<ParentV> {
         element: &mut Self::ElementState,
         cx: &mut ViewContext<ParentV>,
     ) {
-        self.view.view.lock().paint(bounds, element, cx)
-    }
-}
-
-impl Clone for AnyView {
-    fn clone(&self) -> Self {
-        Self {
-            view: self.view.clone(),
-        }
+        self.view.0.paint(bounds, element, cx)
     }
 }

crates/gpui2/src/window.rs 🔗

@@ -46,8 +46,8 @@ pub enum DispatchPhase {
     Capture,
 }
 
-type AnyListener = Arc<dyn Fn(&dyn Any, DispatchPhase, &mut WindowContext) + Send + Sync + 'static>;
-type AnyKeyListener = Arc<
+type AnyListener = Box<dyn Fn(&dyn Any, DispatchPhase, &mut WindowContext) + Send + 'static>;
+type AnyKeyListener = Box<
     dyn Fn(
             &dyn Any,
             &[&DispatchContext],
@@ -55,10 +55,9 @@ type AnyKeyListener = Arc<
             &mut WindowContext,
         ) -> Option<Box<dyn Action>>
         + Send
-        + Sync
         + 'static,
 >;
-type AnyFocusListener = Arc<dyn Fn(&FocusEvent, &mut WindowContext) + Send + Sync + 'static>;
+type AnyFocusListener = Box<dyn Fn(&FocusEvent, &mut WindowContext) + Send + 'static>;
 
 slotmap::new_key_type! { pub struct FocusId; }
 
@@ -500,7 +499,7 @@ impl<'a, 'w> WindowContext<'a, 'w> {
 
     pub fn on_mouse_event<Event: 'static>(
         &mut self,
-        handler: impl Fn(&Event, DispatchPhase, &mut WindowContext) + Send + Sync + 'static,
+        handler: impl Fn(&Event, DispatchPhase, &mut WindowContext) + Send + 'static,
     ) {
         let order = self.window.z_index_stack.clone();
         self.window
@@ -509,7 +508,7 @@ impl<'a, 'w> WindowContext<'a, 'w> {
             .or_default()
             .push((
                 order,
-                Arc::new(move |event: &dyn Any, phase, cx| {
+                Box::new(move |event: &dyn Any, phase, cx| {
                     handler(event.downcast_ref().unwrap(), phase, cx)
                 }),
             ))
@@ -1081,7 +1080,7 @@ impl<'a, 'w> WindowContext<'a, 'w> {
 
     pub fn observe_global<G: 'static>(
         &mut self,
-        f: impl Fn(&mut WindowContext<'_, '_>) + Send + Sync + 'static,
+        f: impl Fn(&mut WindowContext<'_, '_>) + Send + 'static,
     ) -> Subscription {
         let window_id = self.window.handle.id;
         self.global_observers.insert(
@@ -1178,7 +1177,7 @@ impl Context for WindowContext<'_, '_> {
         build_entity: impl FnOnce(&mut Self::EntityContext<'_, '_, T>) -> T,
     ) -> Handle<T>
     where
-        T: Any + Send + Sync,
+        T: 'static + Send,
     {
         let slot = self.app.entities.reserve();
         let entity = build_entity(&mut ViewContext::mutable(
@@ -1311,7 +1310,7 @@ pub trait BorrowWindow: BorrowMut<Window> + BorrowMut<AppContext> {
         f: impl FnOnce(Option<S>, &mut Self) -> (R, S),
     ) -> R
     where
-        S: Any + Send + Sync,
+        S: 'static + Send,
     {
         self.with_element_id(id, |global_id, cx| {
             if let Some(any) = cx
@@ -1347,7 +1346,7 @@ pub trait BorrowWindow: BorrowMut<Window> + BorrowMut<AppContext> {
         f: impl FnOnce(Option<S>, &mut Self) -> (R, S),
     ) -> R
     where
-        S: Any + Send + Sync,
+        S: 'static + Send,
     {
         if let Some(element_id) = element_id {
             self.with_element_state(element_id, f)
@@ -1438,7 +1437,7 @@ impl<'a, 'w, V: 'static> ViewContext<'a, 'w, V> {
 
     pub fn on_next_frame(&mut self, f: impl FnOnce(&mut V, &mut ViewContext<V>) + Send + 'static)
     where
-        V: Any + Send + Sync,
+        V: Any + Send,
     {
         let entity = self.handle();
         self.window_cx.on_next_frame(move |cx| {
@@ -1449,14 +1448,11 @@ impl<'a, 'w, V: 'static> ViewContext<'a, 'w, V> {
     pub fn observe<E>(
         &mut self,
         handle: &Handle<E>,
-        mut on_notify: impl FnMut(&mut V, Handle<E>, &mut ViewContext<'_, '_, V>)
-            + Send
-            + Sync
-            + 'static,
+        mut on_notify: impl FnMut(&mut V, Handle<E>, &mut ViewContext<'_, '_, V>) + Send + 'static,
     ) -> Subscription
     where
         E: 'static,
-        V: Any + Send + Sync,
+        V: Any + Send,
     {
         let this = self.handle();
         let handle = handle.downgrade();
@@ -1482,7 +1478,6 @@ impl<'a, 'w, V: 'static> ViewContext<'a, 'w, V> {
         handle: &Handle<E>,
         mut on_event: impl FnMut(&mut V, Handle<E>, &E::Event, &mut ViewContext<'_, '_, V>)
             + Send
-            + Sync
             + 'static,
     ) -> Subscription {
         let this = self.handle();
@@ -1507,7 +1502,7 @@ impl<'a, 'w, V: 'static> ViewContext<'a, 'w, V> {
 
     pub fn on_release(
         &mut self,
-        mut on_release: impl FnMut(&mut V, &mut WindowContext) + Send + Sync + 'static,
+        mut on_release: impl FnMut(&mut V, &mut WindowContext) + Send + 'static,
     ) -> Subscription {
         let window_handle = self.window.handle;
         self.app.release_listeners.insert(
@@ -1523,10 +1518,10 @@ impl<'a, 'w, V: 'static> ViewContext<'a, 'w, V> {
     pub fn observe_release<T: 'static>(
         &mut self,
         handle: &Handle<T>,
-        mut on_release: impl FnMut(&mut V, &mut T, &mut ViewContext<'_, '_, V>) + Send + Sync + 'static,
+        mut on_release: impl FnMut(&mut V, &mut T, &mut ViewContext<'_, '_, V>) + Send + 'static,
     ) -> Subscription
     where
-        V: Any + Send + Sync,
+        V: Any + Send,
     {
         let this = self.handle();
         let window_handle = self.window.handle;
@@ -1551,10 +1546,10 @@ impl<'a, 'w, V: 'static> ViewContext<'a, 'w, V> {
 
     pub fn on_focus_changed(
         &mut self,
-        listener: impl Fn(&mut V, &FocusEvent, &mut ViewContext<V>) + Send + Sync + 'static,
+        listener: impl Fn(&mut V, &FocusEvent, &mut ViewContext<V>) + Send + 'static,
     ) {
         let handle = self.handle();
-        self.window.focus_listeners.push(Arc::new(move |event, cx| {
+        self.window.focus_listeners.push(Box::new(move |event, cx| {
             handle
                 .update(cx, |view, cx| listener(view, event, cx))
                 .log_err();
@@ -1563,13 +1558,14 @@ impl<'a, 'w, V: 'static> ViewContext<'a, 'w, V> {
 
     pub fn with_key_listeners<R>(
         &mut self,
-        key_listeners: &[(TypeId, KeyListener<V>)],
+        key_listeners: impl IntoIterator<Item = (TypeId, KeyListener<V>)>,
         f: impl FnOnce(&mut Self) -> R,
     ) -> R {
+        let old_stack_len = self.window.key_dispatch_stack.len();
         if !self.window.freeze_key_dispatch_stack {
-            for (event_type, listener) in key_listeners.iter().cloned() {
+            for (event_type, listener) in key_listeners {
                 let handle = self.handle();
-                let listener = Arc::new(
+                let listener = Box::new(
                     move |event: &dyn Any,
                           context_stack: &[&DispatchContext],
                           phase: DispatchPhase,
@@ -1594,8 +1590,7 @@ impl<'a, 'w, V: 'static> ViewContext<'a, 'w, V> {
         let result = f(self);
 
         if !self.window.freeze_key_dispatch_stack {
-            let prev_len = self.window.key_dispatch_stack.len() - key_listeners.len();
-            self.window.key_dispatch_stack.truncate(prev_len);
+            self.window.key_dispatch_stack.truncate(old_stack_len);
         }
 
         result
@@ -1681,7 +1676,7 @@ impl<'a, 'w, V: 'static> ViewContext<'a, 'w, V> {
 
     pub fn update_global<G, R>(&mut self, f: impl FnOnce(&mut G, &mut Self) -> R) -> R
     where
-        G: 'static + Send + Sync,
+        G: 'static + Send,
     {
         let mut global = self.app.lease_global::<G>();
         let result = f(&mut global, self);
@@ -1691,7 +1686,7 @@ impl<'a, 'w, V: 'static> ViewContext<'a, 'w, V> {
 
     pub fn observe_global<G: 'static>(
         &mut self,
-        f: impl Fn(&mut V, &mut ViewContext<'_, '_, V>) + Send + Sync + 'static,
+        f: impl Fn(&mut V, &mut ViewContext<'_, '_, V>) + Send + 'static,
     ) -> Subscription {
         let window_id = self.window.handle.id;
         let handle = self.handle();
@@ -1708,7 +1703,7 @@ impl<'a, 'w, V: 'static> ViewContext<'a, 'w, V> {
 
     pub fn on_mouse_event<Event: 'static>(
         &mut self,
-        handler: impl Fn(&mut V, &Event, DispatchPhase, &mut ViewContext<V>) + Send + Sync + 'static,
+        handler: impl Fn(&mut V, &Event, DispatchPhase, &mut ViewContext<V>) + Send + 'static,
     ) {
         let handle = self.handle().upgrade().unwrap();
         self.window_cx.on_mouse_event(move |event, phase, cx| {
@@ -1722,7 +1717,7 @@ impl<'a, 'w, V: 'static> ViewContext<'a, 'w, V> {
 impl<'a, 'w, V> ViewContext<'a, 'w, V>
 where
     V: EventEmitter,
-    V::Event: Any + Send + Sync,
+    V::Event: Any + Send,
 {
     pub fn emit(&mut self, event: V::Event) {
         let emitter = self.view_state.entity_id;
@@ -1742,7 +1737,7 @@ impl<'a, 'w, V> Context for ViewContext<'a, 'w, V> {
         build_entity: impl FnOnce(&mut Self::EntityContext<'_, '_, T>) -> T,
     ) -> Handle<T>
     where
-        T: 'static + Send + Sync,
+        T: 'static + Send,
     {
         self.window_cx.entity(build_entity)
     }

crates/live_kit_client/examples/test_app.rs 🔗

@@ -61,7 +61,7 @@ fn main() {
 
             let mut audio_track_updates = room_b.remote_audio_track_updates();
             let audio_track = LocalAudioTrack::create();
-            let audio_track_publication = room_a.publish_audio_track(&audio_track).await.unwrap();
+            let audio_track_publication = room_a.publish_audio_track(audio_track).await.unwrap();
 
             if let RemoteAudioTrackUpdate::Subscribed(track, _) =
                 audio_track_updates.next().await.unwrap()
@@ -132,10 +132,8 @@ fn main() {
             let display = displays.into_iter().next().unwrap();
 
             let local_video_track = LocalVideoTrack::screen_share_for_display(&display);
-            let local_video_track_publication = room_a
-                .publish_video_track(&local_video_track)
-                .await
-                .unwrap();
+            let local_video_track_publication =
+                room_a.publish_video_track(local_video_track).await.unwrap();
 
             if let RemoteVideoTrackUpdate::Subscribed(track) =
                 video_track_updates.next().await.unwrap()

crates/live_kit_client/src/prod.rs 🔗

@@ -229,7 +229,7 @@ impl Room {
 
     pub fn publish_video_track(
         self: &Arc<Self>,
-        track: &LocalVideoTrack,
+        track: LocalVideoTrack,
     ) -> impl Future<Output = Result<LocalTrackPublication>> {
         let (tx, rx) = oneshot::channel::<Result<LocalTrackPublication>>();
         extern "C" fn callback(tx: *mut c_void, publication: *mut c_void, error: CFStringRef) {
@@ -255,7 +255,7 @@ impl Room {
 
     pub fn publish_audio_track(
         self: &Arc<Self>,
-        track: &LocalAudioTrack,
+        track: LocalAudioTrack,
     ) -> impl Future<Output = Result<LocalTrackPublication>> {
         let (tx, rx) = oneshot::channel::<Result<LocalTrackPublication>>();
         extern "C" fn callback(tx: *mut c_void, publication: *mut c_void, error: CFStringRef) {
@@ -622,8 +622,6 @@ impl Drop for RoomDelegate {
 
 pub struct LocalAudioTrack(*const c_void);
 unsafe impl Send for LocalAudioTrack {}
-// todo!(Sync is not ok here. We need to remove it)
-unsafe impl Sync for LocalAudioTrack {}
 
 impl LocalAudioTrack {
     pub fn create() -> Self {
@@ -639,8 +637,6 @@ impl Drop for LocalAudioTrack {
 
 pub struct LocalVideoTrack(*const c_void);
 unsafe impl Send for LocalVideoTrack {}
-// todo!(Sync is not ok here. We need to remove it)
-unsafe impl Sync for LocalVideoTrack {}
 
 impl LocalVideoTrack {
     pub fn screen_share_for_display(display: &MacOSDisplay) -> Self {
@@ -656,8 +652,6 @@ impl Drop for LocalVideoTrack {
 
 pub struct LocalTrackPublication(*const c_void);
 unsafe impl Send for LocalTrackPublication {}
-// todo!(Sync is not ok here. We need to remove it)
-unsafe impl Sync for LocalTrackPublication {}
 
 impl LocalTrackPublication {
     pub fn new(native_track_publication: *const c_void) -> Self {
@@ -702,8 +696,6 @@ impl Drop for LocalTrackPublication {
 pub struct RemoteTrackPublication(*const c_void);
 
 unsafe impl Send for RemoteTrackPublication {}
-// todo!(Sync is not ok here. We need to remove it)
-unsafe impl Sync for RemoteTrackPublication {}
 
 impl RemoteTrackPublication {
     pub fn new(native_track_publication: *const c_void) -> Self {
@@ -761,8 +753,6 @@ pub struct RemoteAudioTrack {
 }
 
 unsafe impl Send for RemoteAudioTrack {}
-// todo!(Sync is not ok here. We need to remove it)
-unsafe impl Sync for RemoteAudioTrack {}
 
 impl RemoteAudioTrack {
     fn new(native_track: *const c_void, sid: Sid, publisher_id: String) -> Self {
@@ -801,8 +791,6 @@ pub struct RemoteVideoTrack {
 }
 
 unsafe impl Send for RemoteVideoTrack {}
-// todo!(Sync is not ok here. We need to remove it)
-unsafe impl Sync for RemoteVideoTrack {}
 
 impl RemoteVideoTrack {
     fn new(native_track: *const c_void, sid: Sid, publisher_id: String) -> Self {
@@ -886,8 +874,6 @@ pub enum RemoteAudioTrackUpdate {
 pub struct MacOSDisplay(*const c_void);
 
 unsafe impl Send for MacOSDisplay {}
-// todo!(Sync is not ok here. We need to remove it)
-unsafe impl Sync for MacOSDisplay {}
 
 impl MacOSDisplay {
     fn new(ptr: *const c_void) -> Self {

crates/live_kit_client/src/test.rs 🔗

@@ -371,7 +371,7 @@ impl Room {
 
     pub fn publish_video_track(
         self: &Arc<Self>,
-        track: &LocalVideoTrack,
+        track: LocalVideoTrack,
     ) -> impl Future<Output = Result<LocalTrackPublication>> {
         let this = self.clone();
         let track = track.clone();
@@ -384,7 +384,7 @@ impl Room {
     }
     pub fn publish_audio_track(
         self: &Arc<Self>,
-        track: &LocalAudioTrack,
+        track: LocalAudioTrack,
     ) -> impl Future<Output = Result<LocalTrackPublication>> {
         let this = self.clone();
         let track = track.clone();

crates/ui2/src/theme.rs 🔗

@@ -152,8 +152,8 @@ pub struct Themed<E> {
 impl<V, E> Component<V> for Themed<E>
 where
     V: 'static,
-    E: 'static + Element<V> + Send + Sync,
-    E::ElementState: Send + Sync,
+    E: 'static + Element<V> + Send,
+    E::ElementState: Send,
 {
     fn render(self) -> AnyElement<V> {
         AnyElement::new(self)
@@ -163,10 +163,10 @@ where
 #[derive(Default)]
 struct ThemeStack(Vec<Theme>);
 
-impl<V, E: 'static + Element<V> + Send + Sync> Element<V> for Themed<E>
+impl<V, E: 'static + Element<V> + Send> Element<V> for Themed<E>
 where
     V: 'static,
-    E::ElementState: Send + Sync,
+    E::ElementState: Send,
 {
     type ElementState = E::ElementState;