Desktop: Isolate CEF-rendered UI into separate crate and process (#4321)

* Extract CEF rendered UI into a separate process and crate

* Review

* Review

* Review

* Review

* Remove necessary workarounds

* Block on frame copy ack

* Crop and resample frames correctly

* Skip blank frames

* Fix deps

* Fix fmt

* Fix clippy warning

* Review

* Fix todo
This commit is contained in:
Timon
2026-07-14 14:51:20 -07:00
committed by Keavon Chambers
parent 97a43e66fb
commit ba0a97aefe
82 changed files with 4768 additions and 1291 deletions
+45
View File
@@ -0,0 +1,45 @@
use ipc_channel::ipc::IpcSender;
use std::sync::Mutex;
use crate::remote::messages::HostControlMessage;
pub(super) struct FrameSink {
state: Mutex<FrameSinkState>,
}
#[derive(Default)]
struct FrameSinkState {
newest_installed: u64,
last_acked: u64,
}
impl FrameSink {
pub(super) fn new() -> Self {
Self {
state: Mutex::new(FrameSinkState::default()),
}
}
pub(super) fn deliver(&self, sender: &IpcSender<HostControlMessage>, seq: u64, install: impl FnOnce() -> bool) {
let Ok(mut state) = self.state.lock() else {
tracing::error!("Failed to lock the frame sink");
return;
};
if seq > 1 && seq - 1 > state.last_acked {
if let Err(e) = sender.send(HostControlMessage::FrameAck { seq: seq - 1 }) {
tracing::debug!("Failed to ack superseded frames to CEF host: {e}");
}
state.last_acked = seq - 1;
}
if seq > state.newest_installed && install() {
state.newest_installed = seq;
}
if seq > state.last_acked {
if let Err(e) = sender.send(HostControlMessage::FrameAck { seq }) {
tracing::debug!("Failed to ack frame to CEF host: {e}");
}
state.last_acked = seq;
}
}
}