diff --git a/crates/call2/src/participant.rs b/crates/call2/src/participant.rs index 5bc290b1828e3dfb7554b062f97753a7c38d5439..3f594ac944a45aef2a78039017e352993b3dab40 100644 --- a/crates/call2/src/participant.rs +++ b/crates/call2/src/participant.rs @@ -56,6 +56,10 @@ pub struct RemoteVideoTrack { pub(crate) live_kit_track: Arc, } +unsafe impl Send for RemoteVideoTrack {} +// todo!("remove this sync because it's not legit") +unsafe impl Sync for RemoteVideoTrack {} + impl fmt::Debug for RemoteVideoTrack { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("RemoteVideoTrack").finish() diff --git a/crates/gpui2/src/app.rs b/crates/gpui2/src/app.rs index 75f202e7106d504399efa0937ad0fc091e980533..35efe84e485d6914fbf79ef35a2cff9d1faeb9f8 100644 --- a/crates/gpui2/src/app.rs +++ b/crates/gpui2/src/app.rs @@ -403,7 +403,7 @@ impl AppContext { fn apply_emit_effect(&mut self, emitter: EntityId, event: Box) { self.event_listeners .clone() - .retain(&emitter, |handler| handler(&event, self)); + .retain(&emitter, |handler| handler(event.as_ref(), self)); } fn apply_focus_changed_effect(&mut self, window_id: WindowId, focused: Option) { diff --git a/crates/gpui2/src/app/entity_map.rs b/crates/gpui2/src/app/entity_map.rs index cf39a2b81f1f3576af857452d727322e9e24e4c3..04205175903148885d21609890187721b6d10716 100644 --- a/crates/gpui2/src/app/entity_map.rs +++ b/crates/gpui2/src/app/entity_map.rs @@ -100,10 +100,15 @@ impl EntityMap { } pub fn take_dropped(&mut self) -> Vec<(EntityId, AnyBox)> { - let dropped_entity_ids = mem::take(&mut self.ref_counts.write().dropped_entity_ids); + let mut ref_counts = self.ref_counts.write(); + let dropped_entity_ids = mem::take(&mut ref_counts.dropped_entity_ids); + dropped_entity_ids .into_iter() - .map(|entity_id| (entity_id, self.entities.remove(entity_id).unwrap())) + .map(|entity_id| { + ref_counts.counts.remove(entity_id); + (entity_id, self.entities.remove(entity_id).unwrap()) + }) .collect() } } @@ -212,7 +217,6 @@ impl Drop for AnyHandle { if prev_count == 1 { // We were the last reference to this entity, so we can remove it. let mut entity_map = RwLockUpgradableReadGuard::upgrade(entity_map); - entity_map.counts.remove(self.entity_id); entity_map.dropped_entity_ids.push(self.entity_id); } } diff --git a/crates/gpui2/src/app/model_context.rs b/crates/gpui2/src/app/model_context.rs index 6f88bf1aa6c6d3a974cf5259931668712313cea5..d81b113b7b660c90f401b965f83c060d72a93cbd 100644 --- a/crates/gpui2/src/app/model_context.rs +++ b/crates/gpui2/src/app/model_context.rs @@ -79,7 +79,7 @@ impl<'a, T: 'static> ModelContext<'a, T> { self.app.event_listeners.insert( handle.entity_id, Box::new(move |event, cx| { - let event = event.downcast_ref().expect("invalid event type"); + let event: &E::Event = event.downcast_ref().expect("invalid event type"); if let Some((this, handle)) = this.upgrade().zip(handle.upgrade()) { this.update(cx, |this, cx| on_event(this, handle, event, cx)); true diff --git a/crates/gpui2/src/test.rs b/crates/gpui2/src/test.rs index ffad9aab8bf573531ccda1e5be3963cad8549487..3f2697f7e3f2d2c6c44165728503b7fa1accf6e0 100644 --- a/crates/gpui2/src/test.rs +++ b/crates/gpui2/src/test.rs @@ -8,7 +8,7 @@ use std::{ pub fn run_test( mut num_iterations: u64, max_retries: usize, - test_fn: &mut (dyn RefUnwindSafe + Fn(TestDispatcher)), + test_fn: &mut (dyn RefUnwindSafe + Fn(TestDispatcher, u64)), on_fail_fn: Option, _fn_name: String, // todo!("re-enable fn_name") ) { @@ -28,7 +28,7 @@ pub fn run_test( } let result = panic::catch_unwind(|| { let dispatcher = TestDispatcher::new(StdRng::seed_from_u64(seed)); - test_fn(dispatcher); + test_fn(dispatcher, seed); }); match result { diff --git a/crates/live_kit_client/src/live_kit_client.rs b/crates/live_kit_client/src/live_kit_client.rs index 0467018c009a9b36f00908d6628311d580fdec91..47cc3873ff0c1d4f7a3148878be32c12d8f98c5b 100644 --- a/crates/live_kit_client/src/live_kit_client.rs +++ b/crates/live_kit_client/src/live_kit_client.rs @@ -1,3 +1,4 @@ +#[cfg(not(any(test, feature = "test-support")))] pub mod prod; #[cfg(not(any(test, feature = "test-support")))] diff --git a/crates/live_kit_client/src/prod.rs b/crates/live_kit_client/src/prod.rs index de9838c23dfe58d04b3a079476f791496a14bb3b..ab541744309e21ab7498d478fdd71653eb7595a8 100644 --- a/crates/live_kit_client/src/prod.rs +++ b/crates/live_kit_client/src/prod.rs @@ -621,6 +621,9 @@ 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 { @@ -635,6 +638,9 @@ 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 { @@ -649,6 +655,9 @@ 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 { @@ -692,6 +701,10 @@ 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 { unsafe { @@ -747,6 +760,10 @@ pub struct RemoteAudioTrack { publisher_id: String, } +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 { unsafe { @@ -783,6 +800,10 @@ pub struct RemoteVideoTrack { publisher_id: String, } +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 { unsafe { @@ -864,6 +885,10 @@ 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 { unsafe { diff --git a/crates/zed2/build.rs b/crates/zed2/build.rs new file mode 100644 index 0000000000000000000000000000000000000000..14bf9999fb725c6dae32bfc46341560b662f3d8b --- /dev/null +++ b/crates/zed2/build.rs @@ -0,0 +1,24 @@ +fn main() { + println!("cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET=10.15.7"); + + if let Ok(value) = std::env::var("ZED_PREVIEW_CHANNEL") { + println!("cargo:rustc-env=ZED_PREVIEW_CHANNEL={value}"); + } + + if std::env::var("ZED_BUNDLE").ok().as_deref() == Some("true") { + // Find WebRTC.framework in the Frameworks folder when running as part of an application bundle. + println!("cargo:rustc-link-arg=-Wl,-rpath,@executable_path/../Frameworks"); + } else { + // Find WebRTC.framework as a sibling of the executable when running outside of an application bundle. + println!("cargo:rustc-link-arg=-Wl,-rpath,@executable_path"); + } + + // Weakly link ReplayKit to ensure Zed can be used on macOS 10.15+. + println!("cargo:rustc-link-arg=-Wl,-weak_framework,ReplayKit"); + + // Seems to be required to enable Swift concurrency + println!("cargo:rustc-link-arg=-Wl,-rpath,/usr/lib/swift"); + + // Register exported Objective-C selectors, protocols, etc + println!("cargo:rustc-link-arg=-Wl,-ObjC"); +}