From c258f5268ae78545e984e661c30f03592c71e93f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 29 Nov 2026 22:57:52 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20share=20watch=20catch-up?= =?UTF-8?q?=20only=20flushes=20on=20local=20backlog.=20It=20compared=20eac?= =?UTF-8?q?h=20packet's=20age=20since=20capture=20against=20the=20fastest?= =?UTF-8?q?=20delay=20ever=20seen,=20so=20a=20sender=20whose=20frames=20ta?= =?UTF-8?q?ke=20over=20a=20second=20to=20encode=20and=20pace=20(software?= =?UTF-8?q?=204K)=20made=20every=20packet=20look=20late:=20the=20receiver?= =?UTF-8?q?=20flushed=20and=20reset=20on=20every=20packet=20and=20showed?= =?UTF-8?q?=200=20fps=20forever.=20Packets=20now=20carry=20their=20arrival?= =?UTF-8?q?=20time=20and=20are=20skipped=20only=20when=20this=20receiver?= =?UTF-8?q?=20queued=20them=20for=20over=20a=20second.=20Disabled=20Releas?= =?UTF-8?q?e=20buttons=20use=20a=20Press::Off=20style=20(faint=20ink)=20in?= =?UTF-8?q?stead=20of=20raw=20opacity,=20which=20broke=20the=20token=20tes?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/client/src/gui/builder/release.rs | 4 +--- crates/client/src/gui/parts.rs | 3 +++ crates/client/src/share/session.rs | 28 ++++++++++++++---------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/crates/client/src/gui/builder/release.rs b/crates/client/src/gui/builder/release.rs index baea3a7..1d90639 100644 --- a/crates/client/src/gui/builder/release.rs +++ b/crates/client/src/gui/builder/release.rs @@ -9,7 +9,6 @@ use gpui_kit::{ PathPromptOptions, Styled, WeakEntity, Window, component::{WindowExt, notification::Notification}, div, - prelude::FluentBuilder as _, }; use crate::gui::glyph::Fill as _; @@ -85,7 +84,7 @@ fn release_button( parts::button( id, label, - Press::Plain, + if enabled { Press::Plain } else { Press::Off }, palette.tokens, entity_action(entity, move |yumush, window, cx| { if enabled { @@ -93,7 +92,6 @@ fn release_button( } }), ) - .when(!enabled, |this| this.opacity(0.4)) .into_any_element() } diff --git a/crates/client/src/gui/parts.rs b/crates/client/src/gui/parts.rs index 001f74a..4a78e27 100644 --- a/crates/client/src/gui/parts.rs +++ b/crates/client/src/gui/parts.rs @@ -250,6 +250,7 @@ pub enum Press { Plain, Primary, Danger, + Off, } pub fn button( @@ -265,6 +266,8 @@ pub fn button( .child(words(label, Text::Ui, Ink::Paper, t).font_weight(FontWeight::MEDIUM)), Press::Danger => press(id, t, on_click) .child(words(label, Text::Ui, Ink::Bad, t).font_weight(FontWeight::MEDIUM)), + Press::Off => press(id, t, |_, _| {}) + .child(words(label, Text::Ui, Ink::Faint, t).font_weight(FontWeight::MEDIUM)), Press::Primary => pill(id, t, on_click).child( words(label, Text::Ui, Ink::Paper, t) .font_weight(FontWeight::SEMIBOLD) diff --git a/crates/client/src/share/session.rs b/crates/client/src/share/session.rs index c7813c3..98d7c10 100644 --- a/crates/client/src/share/session.rs +++ b/crates/client/src/share/session.rs @@ -61,7 +61,7 @@ const INITIAL_DELAY_MS: i64 = 100; const MIN_DELAY_MS: i64 = 20; const MAX_DELAY_MS: i64 = 200; const RESYNC_MS: i64 = 2000; -const CATCH_UP_MS: i64 = 1000; +const CATCH_UP: Duration = Duration::from_secs(1); const DELAY_MARGIN_MS: i64 = 8; const DELAY_WINDOW_MS: i64 = 3000; const DELAY_PERCENTILE: usize = 98; @@ -692,7 +692,7 @@ pub struct Watching { video: Arc>, health: Arc>, volume: Arc, - video_tx: Sender, + video_tx: Sender<(Instant, Bytes)>, audio_tx: Option>, meter: Meter, received: AtomicU64, @@ -795,16 +795,22 @@ impl Watching { } pub fn receive(&self, datagram: &Bytes, packet: &Packet<'_>) { - let (ts_ms, tx) = match packet { - Packet::Video { ts_ms, .. } => (*ts_ms, Some(&self.video_tx)), - Packet::ScreenAudio { ts_ms, .. } => (*ts_ms, self.audio_tx.as_ref()), + let ts_ms = match packet { + Packet::Video { ts_ms, .. } | Packet::ScreenAudio { ts_ms, .. } => *ts_ms, Packet::Voice { .. } | Packet::Nack { .. } | Packet::Ack { .. } => return, }; self.clock.observe(ts_ms); self.received .fetch_add((datagram.len() - RELAY_PREFIX) as u64, Ordering::Relaxed); - if let Some(tx) = tx { - let _ = tx.send(datagram.clone()); + match packet { + Packet::Video { .. } => { + let _ = self.video_tx.send((Instant::now(), datagram.clone())); + } + _ => { + if let Some(tx) = &self.audio_tx { + let _ = tx.send(datagram.clone()); + } + } } } @@ -1043,7 +1049,7 @@ impl Feedback { } fn watch_video( - rx: Receiver, + rx: Receiver<(Instant, Bytes)>, feedback: &Feedback, clock: &Clock, video: &Mutex