From ee2a4a9d37dee1b421f6e44251fc5af2283f44ec Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 15 Dec 2025 22:10:33 -0700 Subject: [PATCH] Clean up screenshare (#44945) Release Notes: - Fixed a bug where screen-share tabs would persist after the sender (or receiver) had left the call. --- crates/call/src/call_impl/room.rs | 12 ++++++++++++ crates/workspace/src/shared_screen.rs | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/crates/call/src/call_impl/room.rs b/crates/call/src/call_impl/room.rs index fc15b4e4395ae7aa3100a165d942a6906cf1976d..ccc8c067c25a91aa44c01911be89c21f0ea9367c 100644 --- a/crates/call/src/call_impl/room.rs +++ b/crates/call/src/call_impl/room.rs @@ -305,6 +305,7 @@ impl Room { pub(crate) fn leave(&mut self, cx: &mut Context) -> Task> { cx.notify(); + self.emit_video_track_unsubscribed_events(cx); self.leave_internal(cx) } @@ -352,6 +353,14 @@ impl Room { self.maintain_connection.take(); } + fn emit_video_track_unsubscribed_events(&self, cx: &mut Context) { + for participant in self.remote_participants.values() { + for sid in participant.video_tracks.keys() { + cx.emit(Event::RemoteVideoTrackUnsubscribed { sid: sid.clone() }); + } + } + } + async fn maintain_connection( this: WeakEntity, client: Arc, @@ -882,6 +891,9 @@ impl Room { project_id: project.id, }); } + for sid in participant.video_tracks.keys() { + cx.emit(Event::RemoteVideoTrackUnsubscribed { sid: sid.clone() }); + } false } }); diff --git a/crates/workspace/src/shared_screen.rs b/crates/workspace/src/shared_screen.rs index 3c009f613ea52906649b73bb9fd657bab6906c3b..564560274699ab6685d481340c5efd4b6336ed56 100644 --- a/crates/workspace/src/shared_screen.rs +++ b/crates/workspace/src/shared_screen.rs @@ -42,6 +42,11 @@ impl SharedScreen { }) .detach(); + cx.observe_release(&room, |_, _, cx| { + cx.emit(Event::Close); + }) + .detach(); + let view = cx.new(|cx| RemoteVideoTrackView::new(track.clone(), window, cx)); cx.subscribe(&view, |_, _, ev, cx| match ev { call::RemoteVideoTrackViewEvent::Close => cx.emit(Event::Close),