From f07936a91196154a0544e217458085c00652bb44 Mon Sep 17 00:00:00 2001 From: 21pages Date: Tue, 9 Jul 2024 18:01:30 +0800 Subject: [PATCH] wayland not call check_get_displays_changed_msg (#8637) * wayland not call check_get_displays_changed_msg For wayland, call Display::all() in video service will cause block, I don't know the reason. Signed-off-by: 21pages * Update display_service.rs --------- Signed-off-by: 21pages Co-authored-by: RustDesk <71636191+rustdesk@users.noreply.github.com> --- libs/scrap/src/common/linux.rs | 1 + src/server/display_service.rs | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libs/scrap/src/common/linux.rs b/libs/scrap/src/common/linux.rs index e70ac6ca5..0f1e9b622 100644 --- a/libs/scrap/src/common/linux.rs +++ b/libs/scrap/src/common/linux.rs @@ -59,6 +59,7 @@ impl Display { }) } + // Call this function carefully for wayland, it may cause blocking pub fn all() -> io::Result> { Ok(if super::is_x11() { x11::Display::all()? diff --git a/src/server/display_service.rs b/src/server/display_service.rs index 0f54188a8..aa226099d 100644 --- a/src/server/display_service.rs +++ b/src/server/display_service.rs @@ -184,6 +184,14 @@ fn check_get_displays_changed_msg() -> Option { } pub fn check_displays_changed() -> ResultType<()> { + #[cfg(target_os = "linux")] + { + // For wayland, call Display::all() in video service will cause block, reproduced by refresh, I don't know the reason. + // block, or even crash here, https://github.com/rustdesk/rustdesk/blob/0bb4d43e9ea9d9dfb9c46c8d27d1a97cd0ad6bea/libs/scrap/src/wayland/pipewire.rs#L235 + if !is_x11() { + return Ok(()); + } + } check_update_displays(&try_get_displays()?); Ok(()) } @@ -394,7 +402,8 @@ pub fn try_get_displays_(add_amyuni_headless: bool) -> ResultType> let mut displays = Display::all()?; // Do not add virtual display if the platform is not installed or the virtual display is not supported. - if !crate::platform::is_installed() || !virtual_display_manager::is_virtual_display_supported() { + if !crate::platform::is_installed() || !virtual_display_manager::is_virtual_display_supported() + { return Ok(displays); }