Skip to content

fix(linux): follow Settings portal reduced-motion off the UI thread and cache fallback - #1766

Merged
Hona merged 1 commit into
devfrom
fix/655-linux-reduced-motion
Nov 23, 2026
Merged

Hona merged 1 commit into
devfrom
fix/655-linux-reduced-motion

Conversation

@Hona

@Hona Hona commented Nov 23, 2026

Copy link
Copy Markdown
Member

Fixes #655

Root cause

  • On Linux, crates/rune/src/platform/preferences.rs read ~/.config/kdeglobals synchronously from disk (on KDE) and called libgio-2.0.so.0 GSettings on the UI thread inside preferences::reduced_motion().
  • host_events::refresh_focus_preferences calls preferences::reduced_motion() on every window and overlay focus change, causing synchronous filesystem I/O during input handling and permanently dlopening GLib/GIO (with its background threads) even when the XDG Settings portal is available.

Outside answer

  • Google Chrome (ui/gfx/animation/animation.cc, ui/gfx/animation/animation_linux.cc, ui/gtk/gtk_ui.cc, ui/qt/qt_ui.cc, ui/linux/portal_settings_linux.cc, components/dbus/thread_linux/dbus_thread_linux.cc) caches prefers_reduced_motion_ in memory, runs D-Bus Settings portal I/O on a dedicated background thread, and updates via change signals (notify::gtk-enable-animations, Qt theme change, D-Bus SettingChanged) — never reading disk or GSettings on focus changes.
  • XDG Desktop Portal (org.freedesktop.portal.Settings) standardizes org.freedesktop.appearance reduced-motion (u: 0 no preference, 1 reduced motion, unknown treated as 0) with live SettingChanged signals, served by xdg-desktop-portal-kde and xdg-desktop-portal-gnome. GTK 4 (gdk/wayland/gdksettings-wayland.c) and Qt 6 (QXdgDesktopPortalTheme) read it once from the portal and follow SettingChanged; xdg-desktop-portal-gtk and older GNOME expose org.gnome.desktop.interface enable-animations (b) on the same portal.

Changes

flowchart LR
  UI[UI thread: preferences::reduced_motion] -->|relaxed atomic load| M[(MOTION AtomicU8)]
  W[rune-appearance-portal worker] -->|ReadOne / Read + SettingChanged| P[org.freedesktop.portal.Settings]
  P -->|org.freedesktop.appearance reduced-motion| M
  P -->|org.gnome.desktop.interface enable-animations| M
  W -.->|only if neither portal key answered, once| F[kdeglobals / libgio fallback]
  F -.-> M
  M -->|on state change| R[window.request_redraw]
Loading
  • crates/rune/src/platform/portal_appearance.rs: extend the shared rune-appearance-portal worker and D-Bus connection to read and follow org.freedesktop.appearance reduced-motion (u32) and org.gnome.desktop.interface enable-animations (bool) via SettingChanged, storing the state in an AtomicU8 and requesting window redraws on changes. When neither portal key answers, run the kdeglobals/GSettings fallback at most once on that worker thread.
  • crates/rune/src/platform/preferences.rs: delegate Linux reduced_motion() to portal_appearance::reduced_motion() when dbus is enabled, and cache the one-shot off-UI-thread fallback in CachedReducedMotion when dbus is disabled.
  • crates/rune/src/window/host/events.rs, crates/rune/src/window/host/lifecycle.rs, crates/rune/src/overlay/lifetime.rs, crates/rune/src/overlay/any_host.rs: sync the cached atomic into RuntimeCore::set_system_reduced_motion on Linux redraw/reveal and register overlays with portal_appearance::follow.
  • crates/rune/src/platform/portal_appearance_tests.rs, crates/rune/src/platform/preferences_tests.rs: unit tests for portal reduced-motion decoding/combination, fallback superseding, kdeglobals parsing, and one-shot off-thread fallback caching.
  • crates/rune/README.md, changelog/unreleased/2026-11-24-linux-portal-reduced-motion.md: document the new Linux behavior.

Verification

  • Verified new tests failed before the fix and pass after: cargo test -p rune -p rune-mermaid -p rune-kit --features rune-kit/markdown,rune-kit/mermaid platform:: (122 passed).
  • Verified Linux aarch64 compilation (both default features with dbus and --no-default-features): cargo check -p rune -p rune-kit --tests and cargo check -p rune --no-default-features --tests.
  • Verified file sizes and folder shape: scripts/file-size.sh (0 errors).
  • Not checked live: Linux tests and runtime D-Bus SettingChanged delivery against a live Linux desktop portal (checked compile-only in a headless Linux container; platform-independent state logic ran in unit tests).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linux: the reduced-motion preference is read from disk on the UI thread on every focus change

1 participant