Use ThreadExecutor instead of calloop executor
I thought the calloop executor had been fixed, but it still seems to have issues that were preventing capture of continuous frames from working consistently. Fixes https://github.com/pop-os/cosmic-workspaces-epoch/issues/160.
This commit is contained in:
parent
7ab1f93acf
commit
74270a2deb
4 changed files with 21 additions and 20 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -1265,6 +1265,7 @@ dependencies = [
|
|||
"freedesktop-desktop-entry",
|
||||
"freedesktop-icons",
|
||||
"futures-channel",
|
||||
"futures-executor",
|
||||
"gbm",
|
||||
"i18n-embed",
|
||||
"i18n-embed-fl",
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ rust-embed = "8.1.0"
|
|||
rustix = { version = "0.38.30", features = ["fs"] }
|
||||
calloop-wayland-source = "0.4.0"
|
||||
aliasable = "0.1.3"
|
||||
futures-executor = { version = "0.3.31", features = ["thread-pool"] }
|
||||
|
||||
[dependencies.i18n-embed]
|
||||
version = "0.15.3"
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ pub struct AppData {
|
|||
captures: RefCell<HashMap<CaptureSource, Arc<Capture>>>,
|
||||
dmabuf_feedback: Option<DmabufFeedback>,
|
||||
gbm: Option<(PathBuf, gbm::Device<fs::File>)>,
|
||||
scheduler: calloop::futures::Scheduler<()>,
|
||||
thread_pool: futures_executor::ThreadPool,
|
||||
}
|
||||
|
||||
impl AppData {
|
||||
|
|
@ -227,7 +227,12 @@ fn start(conn: Connection) -> mpsc::Receiver<Event> {
|
|||
}
|
||||
|
||||
thread::spawn(move || {
|
||||
let (executor, scheduler) = calloop::futures::executor().unwrap();
|
||||
// TODO: The `calloop` executor doesn't seem to be working properly, so
|
||||
// spawn an executor using one additional thread.
|
||||
let thread_pool = futures_executor::ThreadPool::builder()
|
||||
.pool_size(1)
|
||||
.create()
|
||||
.unwrap();
|
||||
|
||||
let registry_state = RegistryState::new(&globals);
|
||||
let mut app_data = AppData {
|
||||
|
|
@ -245,7 +250,7 @@ fn start(conn: Connection) -> mpsc::Receiver<Event> {
|
|||
captures: RefCell::new(HashMap::new()),
|
||||
dmabuf_feedback: None,
|
||||
gbm: None,
|
||||
scheduler,
|
||||
thread_pool,
|
||||
};
|
||||
|
||||
let (cmd_sender, cmd_channel) = calloop::channel::channel();
|
||||
|
|
@ -263,10 +268,6 @@ fn start(conn: Connection) -> mpsc::Receiver<Event> {
|
|||
}
|
||||
})
|
||||
.unwrap();
|
||||
event_loop
|
||||
.handle()
|
||||
.insert_source(executor, |(), _, _| {})
|
||||
.unwrap();
|
||||
|
||||
loop {
|
||||
event_loop.dispatch(None, &mut app_data).unwrap();
|
||||
|
|
|
|||
|
|
@ -159,19 +159,17 @@ impl ScreencopyHandler for AppData {
|
|||
let conn = conn.clone();
|
||||
let release = session.release.take();
|
||||
let qh = qh.clone();
|
||||
self.scheduler
|
||||
.schedule(async move {
|
||||
if let Some(release) = release {
|
||||
// Wait for buffer to be released by server
|
||||
release.await;
|
||||
}
|
||||
let mut session = capture_clone.session.lock().unwrap();
|
||||
let Some(session) = session.as_mut() else {
|
||||
return;
|
||||
};
|
||||
session.attach_buffer_and_commit(&capture_clone, &conn, &qh);
|
||||
})
|
||||
.unwrap();
|
||||
self.thread_pool.spawn_ok(async move {
|
||||
if let Some(release) = release {
|
||||
// Wait for buffer to be released by server
|
||||
release.await;
|
||||
}
|
||||
let mut session = capture_clone.session.lock().unwrap();
|
||||
let Some(session) = session.as_mut() else {
|
||||
return;
|
||||
};
|
||||
session.attach_buffer_and_commit(&capture_clone, &conn, &qh);
|
||||
});
|
||||
|
||||
let front = session.buffers.as_mut().unwrap().first_mut().unwrap();
|
||||
let (buffer, release) = SubsurfaceBuffer::new(front.backing.clone());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue