Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

improve: reduce decoder/GPU timeouts and optimize GPU poll loop

Richie McIlroye230beb905ce
diff --git a/crates/rendering/src/decoder/mod.rs b/crates/rendering/src/decoder/mod.rs
index 77c9b540f..1782b5bd8 100644
--- a/crates/rendering/src/decoder/mod.rs
+++ b/crates/rendering/src/decoder/mod.rs
@@ -456,8 +456,8 @@ pub struct AsyncVideoDecoderHandle {
}
impl AsyncVideoDecoderHandle {
- const NORMAL_TIMEOUT_MS: u64 = 5000;
- const INITIAL_SEEK_TIMEOUT_MS: u64 = 20000;
+ const NORMAL_TIMEOUT_MS: u64 = 2000;
+ const INITIAL_SEEK_TIMEOUT_MS: u64 = 10000;
pub async fn get_frame(&self, time: f32) -> Option<DecodedFrame> {
self.get_frame_with_timeout(time, Self::NORMAL_TIMEOUT_MS)
diff --git a/crates/rendering/src/frame_pipeline.rs b/crates/rendering/src/frame_pipeline.rs
index e2953af94..fa811e0c9 100644
--- a/crates/rendering/src/frame_pipeline.rs
+++ b/crates/rendering/src/frame_pipeline.rs
@@ -5,7 +5,7 @@ use wgpu::COPY_BYTES_PER_ROW_ALIGNMENT;
use crate::{ProjectUniforms, RenderingError};
-const GPU_BUFFER_WAIT_TIMEOUT_SECS: u64 = 30;
+const GPU_BUFFER_WAIT_TIMEOUT_SECS: u64 = 10;
pub struct PendingReadback {
rx: oneshot::Receiver<Result<(), wgpu::BufferAsyncError>>,
@@ -43,8 +43,12 @@ impl PendingReadback {
Err(oneshot::error::TryRecvError::Empty) => {
device.poll(wgpu::PollType::Poll)?;
poll_count += 1;
- if poll_count.is_multiple_of(3) {
+ if poll_count < 10 {
tokio::task::yield_now().await;
+ } else if poll_count < 100 {
+ tokio::time::sleep(std::time::Duration::from_micros(100)).await;
+ } else {
+ tokio::time::sleep(std::time::Duration::from_millis(1)).await;
}
if poll_count.is_multiple_of(10000) {
tracing::warn!(