linux: Add tracing logs to the x11 client and linux dispatcher (#13928)
This adds some tracing logging that can be toggled on to debug issues. How I used it: ``` RUST_LOG=gpui=trace cargo run ``` Release Notes: - N/A
This commit is contained in:
parent
a1eaf1bb3c
commit
cd7268f21f
2 changed files with 32 additions and 2 deletions
|
@ -8,7 +8,11 @@ use calloop::{
|
||||||
use mio::Waker;
|
use mio::Waker;
|
||||||
use parking::{Parker, Unparker};
|
use parking::{Parker, Unparker};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use std::{sync::Arc, thread, time::Duration};
|
use std::{
|
||||||
|
sync::Arc,
|
||||||
|
thread,
|
||||||
|
time::{Duration, Instant},
|
||||||
|
};
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
|
|
||||||
struct TimerAfter {
|
struct TimerAfter {
|
||||||
|
@ -34,11 +38,19 @@ impl LinuxDispatcher {
|
||||||
.unwrap_or(1);
|
.unwrap_or(1);
|
||||||
|
|
||||||
let mut background_threads = (0..thread_count)
|
let mut background_threads = (0..thread_count)
|
||||||
.map(|_| {
|
.map(|i| {
|
||||||
let receiver = background_receiver.clone();
|
let receiver = background_receiver.clone();
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
for runnable in receiver {
|
for runnable in receiver {
|
||||||
|
let start = Instant::now();
|
||||||
|
|
||||||
runnable.run();
|
runnable.run();
|
||||||
|
|
||||||
|
log::trace!(
|
||||||
|
"background thread {}: ran runnable. took: {:?}",
|
||||||
|
i,
|
||||||
|
start.elapsed()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -462,7 +462,14 @@ impl X11Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process_x11_events(&self, events: Vec<Event>) {
|
fn process_x11_events(&self, events: Vec<Event>) {
|
||||||
|
log::trace!(
|
||||||
|
"main thread: processing X11 events. events: {}",
|
||||||
|
events.len()
|
||||||
|
);
|
||||||
|
|
||||||
for event in events.into_iter() {
|
for event in events.into_iter() {
|
||||||
|
log::trace!("main thread: processing X11 event: {:?}", event);
|
||||||
|
|
||||||
let mut state = self.0.borrow_mut();
|
let mut state = self.0.borrow_mut();
|
||||||
if state.ximc.is_none() || state.xim_handler.is_none() {
|
if state.ximc.is_none() || state.xim_handler.is_none() {
|
||||||
drop(state);
|
drop(state);
|
||||||
|
@ -1221,6 +1228,10 @@ impl LinuxClient for X11Client {
|
||||||
let (x_windows, events) = self.read_x11_events();
|
let (x_windows, events) = self.read_x11_events();
|
||||||
for x_window in x_windows {
|
for x_window in x_windows {
|
||||||
if let Some(window) = self.get_window(x_window) {
|
if let Some(window) = self.get_window(x_window) {
|
||||||
|
log::trace!(
|
||||||
|
"main thread: refreshing window {} due expose event",
|
||||||
|
window.x_window
|
||||||
|
);
|
||||||
window.refresh();
|
window.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1242,7 +1253,13 @@ impl LinuxClient for X11Client {
|
||||||
// Runnables
|
// Runnables
|
||||||
while let Ok(runnable) = state.runnables.try_recv() {
|
while let Ok(runnable) = state.runnables.try_recv() {
|
||||||
drop(state);
|
drop(state);
|
||||||
|
|
||||||
|
let start = Instant::now();
|
||||||
|
|
||||||
runnable.run();
|
runnable.run();
|
||||||
|
|
||||||
|
log::trace!("main thread: ran runnable. took: {:?}", start.elapsed());
|
||||||
|
|
||||||
state = self.0.borrow_mut();
|
state = self.0.borrow_mut();
|
||||||
|
|
||||||
if Instant::now() + Duration::from_millis(1) >= next_refresh_needed {
|
if Instant::now() + Duration::from_millis(1) >= next_refresh_needed {
|
||||||
|
@ -1252,6 +1269,7 @@ impl LinuxClient for X11Client {
|
||||||
|
|
||||||
// XDG events
|
// XDG events
|
||||||
if let Ok(event) = state.xdp_event_source.try_recv() {
|
if let Ok(event) = state.xdp_event_source.try_recv() {
|
||||||
|
log::trace!("main thread: XDG event");
|
||||||
match event {
|
match event {
|
||||||
XDPEvent::WindowAppearance(appearance) => {
|
XDPEvent::WindowAppearance(appearance) => {
|
||||||
let mut windows = state
|
let mut windows = state
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue