diff --git a/Cargo.lock b/Cargo.lock index 9dd1cc3..00485a8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2130,8 +2130,6 @@ dependencies = [ [[package]] name = "gpui" version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "979b45cfa6ec723b6f42330915a1b3769b930d02b2d505f9697f8ca602bee707" dependencies = [ "anyhow", "ashpd 0.11.1", diff --git a/Cargo.toml b/Cargo.toml index 3d1f979..a9594db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,8 @@ libc = "0.2" # GPUI's zed-async-tar uses xattr 0.2.3, whose Linux ENOATTR alias was removed # from libc. Keep the compatibility fix local; see vendor/xattr/PATCH.md. xattr = { path = "vendor/xattr" } +# Wake Wayland presentation after idle without continuously rendering. +gpui = { path = "vendor/gpui" } [profile.dev] debug = 1 diff --git a/README.md b/README.md index b255c03..2672822 100644 --- a/README.md +++ b/README.md @@ -228,8 +228,10 @@ ASCII runs, Unicode glyphs, backgrounds, and decorations are batched; cursor animation reuses prepared terminal rows. Blink holds use timed wakeups, and inactive cursors schedule no animation frames. -The project uses published crates, with no local Alacritty checkout required. -The small [vendored xattr patch](vendor/xattr/PATCH.md) fixes GPUI's transitive +Dependencies are pinned to published releases, with no local Alacritty checkout +required. The [vendored GPUI patch](vendor/gpui/PATCH.md) restarts Wayland painting +when asynchronous output invalidates an idle window; active frames remain paced +by the compositor. The [xattr patch](vendor/xattr/PATCH.md) fixes GPUI's transitive Linux `ENOATTR` compatibility issue. `Cargo.lock` records dependency versions. ## Development @@ -246,12 +248,21 @@ cargo test --locked cargo clippy --locked --all-targets -- -D warnings RUST_LOG=psyterm::timing=debug cargo run --locked -- --gui + +# Optional regression check with Weston installed (headless backend, fake seat): +cargo build --locked +python3 scripts/check-wayland-idle.py ``` `prepare_us` and `paint_us` measure CPU callback time in microseconds. They exclude GPU execution, compositor scheduling, and presentation, so they are not end-to-end input-latency measurements. +The Wayland regression check creates a private compositor and server. With the +cursor hidden, it verifies a quiet window does not keep repainting, then sends +terminal output and checks that painting resumes without a screenshot, resize, +or desktop input to wake the compositor. It fails on unpatched GPUI 0.2.2. + Tests cover protocol framing, socket ownership, binary bridge flushing, key/paste encoding, palettes, fonts, cursor curves, rendering assembly, PTY lifecycle, and server reattachment/layout behavior. Pane tests cover natural @@ -259,7 +270,7 @@ shell exit, empty-tab removal, focus preservation, idle directory changes, program/manual name precedence, title resets, and rename persistence. Editor tests cover Unicode selection and composition; protocol tests pin the previous versions’ shutdown handshakes. Stack tests cover insertion, navigation, hidden -output, reattachment, and exit cleanup. +output, reattachment, exit cleanup, and command bursts without intervening snapshots. Live Hyprland checks verified GUI→zygote→server ancestry, a single-threaded zygote, no server GPU descriptors, two simultaneous GUIs, tabs/splits, and shell diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md index 7cfab55..3a9203d 100644 --- a/THIRD_PARTY_NOTICES.md +++ b/THIRD_PARTY_NOTICES.md @@ -35,3 +35,9 @@ from `src/renderer/animation_utils.rs`, used by `rendered_window.rs` with `position_animation_length = 0.15` in `renderer/mod.rs`. This is the same Neovide revision and MIT license recorded above. Horizontal tab/pane and vertical stack transitions use this curve; text scrolling has a separate spring in Neovide. + +## GPUI + +`vendor/gpui` contains the published GPUI 0.2.2 crate, licensed under Apache-2.0. +The original [license](vendor/gpui/LICENSE-APACHE) and source metadata are retained. +Changes for Wayland idle redraw are documented in [PATCH.md](vendor/gpui/PATCH.md). diff --git a/scripts/check-wayland-idle.py b/scripts/check-wayland-idle.py new file mode 100755 index 0000000..876f220 --- /dev/null +++ b/scripts/check-wayland-idle.py @@ -0,0 +1,141 @@ +#!/usr/bin/env python3 +"""Regression check for asynchronous redraw after Wayland stops frame callbacks. + +Requires Weston with its headless backend and --fake-seat support. Runs in a +private compositor/runtime; never sends input to the user's desktop or shells. +""" +import argparse +import os +from pathlib import Path +import re +import shutil +import socket +import struct +import subprocess +import tempfile +import time + +parser = argparse.ArgumentParser(description=__doc__) +parser.add_argument("--binary", type=Path, default=Path("target/debug/psyterm")) +args = parser.parse_args() +binary = args.binary.resolve() +if not binary.is_file() or not shutil.which("weston"): + parser.error("build psyTerm first and install Weston") + +runtime = Path(tempfile.mkdtemp(prefix="psyterm-idle-check-")) +server_socket = runtime / "server.sock" +gui_log = runtime / "gui.log" +env = { + **os.environ, + "XDG_RUNTIME_DIR": str(runtime), + "WAYLAND_DISPLAY": "psyterm-test", + "SHELL": "/bin/sh", + "RUST_LOG": "psyterm::timing=debug", +} +env.pop("DISPLAY", None) + + +def wait_for(predicate, description, timeout=12): + deadline = time.monotonic() + timeout + while time.monotonic() < deadline: + result = predicate() + if result: + return result + time.sleep(0.025) + raise AssertionError(f"Timed out waiting for {description}; logs: {runtime}") + + +def control(*arguments): + return subprocess.check_output( + [str(binary), "--socket", str(server_socket), *arguments], + env=env, cwd=runtime, text=True, timeout=10, + ) + + +def read_exact(stream, count): + result = b"" + while len(result) < count: + chunk = stream.recv(count - len(result)) + if not chunk: + raise EOFError("server disconnected") + result += chunk + return result + + +def read_frame(stream): + return read_exact(stream, struct.unpack("