diff --git a/Cargo.toml b/Cargo.toml index d261963..2e1bc79 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,11 @@ opt-level = 3 [profile.harness] inherits = "dev" opt-level = 3 +debug-assertions = false +overflow-checks = false + +[profile.harness.package.client] +debug-assertions = true [profile.release] opt-level = 3 diff --git a/crates/client/src/gui/camera_view.rs b/crates/client/src/gui/camera_view.rs index a75998e..8a15ae4 100644 --- a/crates/client/src/gui/camera_view.rs +++ b/crates/client/src/gui/camera_view.rs @@ -1,3 +1,5 @@ +use std::time::Duration; + use common::model::Id; use common::share::{Fps, Kind, Quality, Resolution}; @@ -19,6 +21,8 @@ use super::{ }; use crate::share::session::WatchQuality; +const IDLE_TICK: Duration = Duration::from_millis(250); + pub(super) const TILE_QUALITY: WatchQuality = WatchQuality::Fixed(Quality { resolution: Resolution::P360, fps: Fps::F30, @@ -56,7 +60,7 @@ impl Yumush { .collect() } - pub(super) fn tick_tiles(&mut self, cx: &mut Context) { + pub(super) fn tick_tiles(&mut self, cx: &mut Context) -> bool { let wanted = self.tile_sources(); let viewing = self.viewing(); let quality = tile_quality(self.chat.stage); @@ -77,7 +81,7 @@ impl Yumush { }, ); changed = true; - if viewing == Some(source) { + if viewing == Some(source) || self.is_me(source.0) { continue; } let (user_id, kind) = source; @@ -107,7 +111,7 @@ impl Yumush { { cx.drop_image(frame, None); } - if viewing != Some(source) { + if viewing != Some(source) && !self.is_me(source.0) { let network = self.network.clone(); let (user_id, kind) = source; cx.spawn(async move |_, _| { @@ -139,6 +143,7 @@ impl Yumush { if changed { cx.notify(); } + !self.chat.tiles.is_empty() } pub(super) fn set_stage(&mut self, stage: Stage, cx: &mut Context) { @@ -291,10 +296,13 @@ impl Yumush { pub(super) fn ticker(cx: &mut Context) -> Task<()> { cx.spawn(async move |this, cx| { + let mut busy = false; loop { - cx.background_executor().timer(FRAME_TICK).await; - if this.update(cx, |yumush, cx| yumush.tick_tiles(cx)).is_err() { - break; + let tick = if busy { FRAME_TICK } else { IDLE_TICK }; + cx.background_executor().timer(tick).await; + match this.update(cx, |yumush, cx| yumush.tick_tiles(cx)) { + Ok(next) => busy = next, + Err(_) => break, } } }) diff --git a/crates/client/src/gui/share_view.rs b/crates/client/src/gui/share_view.rs index d6cc5ba..d9945d9 100644 --- a/crates/client/src/gui/share_view.rs +++ b/crates/client/src/gui/share_view.rs @@ -258,6 +258,9 @@ impl Yumush { window: &mut Window, cx: &mut Context, ) { + if self.is_me(user_id) { + return; + } let watching = self.is_watching(user_id, kind); self.close_viewer(cx); if watching {