window: use a shorter timeout for xdg portal reads

A user reported this:

08:47:13.372  DEBUG  window::os::x11::connection        > Unable to
   resolve appearance using xdg-desktop-portal: Read:
   org.freedesktop.DBus.Error.TimedOut: Failed to activate service
   'org.freedesktop.portal.Desktop': timed out
   (service_start_timeout=120000ms)

which is an issue with their xdg-portal service.

Rather than have wezterm block for 2 minutes on startup, we give it
1 second, and log the issue as a warning.
This commit is contained in:
Wez Furlong committed 2023-02-08 09:19:28 -07:00
1 parent 70d2829b79
commit fd5c6dceb1
4 files changed
+18 -2

No files matched your search

Generated
+1
View File
@@ -6302,6 +6302,7 @@ dependencies = [
"downcast-rs",
"euclid",
"filedescriptor",
"futures-lite",
"futures-util",
"gl_generator",
"glium",
+1
View File
@@ -82,6 +82,7 @@ xcb-imdkit = { version="0.2", git="https://github.com/wez/xcb-imdkit-rs.git", br
zbus = "3.0"
zvariant = "3.6"
futures-util = "0.3"
futures-lite = "1.12"
[target.'cfg(target_os="macos")'.dependencies]
cocoa = "0.20"
+1 -1
View File
@@ -187,7 +187,7 @@ impl ConnectionOps for XConnection {
match promise::spawn::block_on(crate::os::xdg_desktop_portal::get_appearance()) {
Ok(appearance) => return appearance,
Err(err) => {
log::debug!("Unable to resolve appearance using xdg-desktop-portal: {err:#}");
log::warn!("Unable to resolve appearance using xdg-desktop-portal: {err:#}");
}
}
if let Some(XSetting::String(name)) = self.xsettings.borrow().get("Net/ThemeName") {
+15 -1
View File
@@ -4,6 +4,7 @@
use crate::{Appearance, Connection, ConnectionOps};
use anyhow::Context;
use futures_lite::future::FutureExt;
use futures_util::stream::StreamExt;
use std::collections::HashMap;
use std::sync::Mutex;
@@ -49,7 +50,20 @@ pub async fn read_setting(namespace: &str, key: &str) -> anyhow::Result<OwnedVal
let proxy = PortalSettingsProxy::new(&connection)
.await
.context("make proxy")?;
proxy.Read(namespace, key).await.context("Read")
proxy
.Read(namespace, key)
.or(async {
async_io::Timer::after(std::time::Duration::from_secs(1)).await;
Err(std::io::Error::new(
std::io::ErrorKind::TimedOut,
"Timed out reading from xdg-portal; this indicates a problem \
with your graphical environment. Consider running \
'systemctl restart --user xdg-desktop-portal.service'",
)
.into())
})
.await
.with_context(|| format!("Reading xdg-portal {namespace} {key}"))
}
fn value_to_appearance(value: OwnedValue) -> anyhow::Result<Appearance> {