From 877fc93f7a854c18813dfa789de5b79b58722dfa Mon Sep 17 00:00:00 2001 From: Aaron <12213433+surfine@users.noreply.github.com> Date: Mon, 23 Nov 2026 13:43:02 +0800 Subject: [PATCH 01/27] =?UTF-8?q?feat(=E6=80=A7=E8=83=BD):=20scripts/intel?= =?UTF-8?q?-floor.sh=E2=80=94=E2=80=94=E4=B8=80=E9=94=AE=E5=9C=A8=20Intel?= =?UTF-8?q?=20=E7=9C=9F=E6=9C=BA=E4=B8=8A=E8=B7=91=E5=8D=A1=E9=A1=BF?= =?UTF-8?q?=E8=A1=A8=E4=B8=8E=E9=9D=99=E7=BD=AE=E8=83=BD=E8=80=97=E5=B9=B6?= =?UTF-8?q?=E8=AE=B0=E5=B8=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 编 x86_64 stage 包与 fixture、ditto 传过去远端验签、caffeinate、锁屏与 load 检查、 经 run-in-guest.sh 跑 hitch N 遍再跑 energy-profile,拉回输出交 perf-report.sh --parse。 拒绝本机地址;远端只用系统自带命令(不调 python3/git)。 perf-report.sh 加 --app,读指定包的版本号与 build 号。 Co-Authored-By: Claude Opus 5.5 --- scripts/intel-floor.sh | 132 +++++++++++++++++++++++++++++++++++++++++ scripts/perf-report.sh | 6 +- 2 files changed, 136 insertions(+), 2 deletions(-) create mode 100755 scripts/intel-floor.sh diff --git a/scripts/intel-floor.sh b/scripts/intel-floor.sh new file mode 100755 index 00000000..2fcd78e5 --- /dev/null +++ b/scripts/intel-floor.sh @@ -0,0 +1,132 @@ +#!/bin/bash +# Intel 最低标(性能计划第 0 阶段第 1 条):在 2017 MacBook 这类真 Intel 机上跑卡顿表和静置能耗,结果记进卡顿账。 +# 把 2026-11-22 那次手动做的步骤固定下来: +# 1. 本机编 x86_64 的 --stage 包和 x86_64 GlanceFixture(-target x86_64-apple-macos15.0); +# 2. ditto 打包、scp 过去、远端 ditto 解开到 ~/wsqa-run,远端 codesign 验签; +# 3. 远端 caffeinate,先查屏幕没锁、load < 6 才开跑; +# 4. 经 tests/vm/run-in-guest.sh 跑 hitch N 轮(默认 2),再跑 energy-profile.sh; +# 5. 把每轮输出拉回 .build/perf/intel-floor/,交给 scripts/perf-report.sh --parse 记帐。 +# 远端只用系统自带的命令(ditto、codesign、caffeinate、ioreg、sysctl、open、footprint): +# 那台机器没有命令行开发者工具,调 python3/git 会弹安装窗口。 +# +# 用法:scripts/intel-floor.sh user@host [--rounds N] [--hitch-rounds N] [--no-build] [--no-energy] [--no-ledger] +# --rounds N hitch 跑几遍(默认 2),每遍记一行帐 +# --hitch-rounds N 每遍里每类交互几次(默认 20) +# --no-build 不重编,直接用现有的 .build/duo-validation-intel/WindowShade.app +# --no-energy 不跑静置能耗 +# --no-ledger 只写 .build/perf/*.json,不改 docs/perf-ledger.md +# SSH 身份固定为 ~/.ssh/oclp_macbook(IdentitiesOnly),可用 INTEL_FLOOR_KEY 改。 +set -euo pipefail +cd "$(dirname "$0")/.." + +TARGET=""; ROUNDS=2; HITCH_ROUNDS=20; BUILD=1; ENERGY=1; LEDGER=1 +while [ $# -gt 0 ]; do + case "$1" in + --rounds) ROUNDS="${2:?}"; shift 2 ;; + --hitch-rounds) HITCH_ROUNDS="${2:?}"; shift 2 ;; + --no-build) BUILD=0; shift ;; + --no-energy) ENERGY=0; shift ;; + --no-ledger) LEDGER=0; shift ;; + -*) echo "unknown option $1" >&2; exit 2 ;; + *) [ -z "$TARGET" ] || { echo "只能给一个远端地址" >&2; exit 2; }; TARGET="$1"; shift ;; + esac +done +[ -n "$TARGET" ] || { echo "usage: intel-floor.sh user@host [--rounds N] [--hitch-rounds N] [--no-build] [--no-energy] [--no-ledger]" >&2; exit 2; } +[[ "$ROUNDS" =~ ^[0-9]+$ && "$HITCH_ROUNDS" =~ ^[0-9]+$ ]] || { echo "--rounds/--hitch-rounds 要是整数" >&2; exit 2; } +[[ "$TARGET" == *@* ]] || { echo "远端地址要写成 user@host" >&2; exit 2; } +HOST="${TARGET#*@}" +# 必须是明确的远端:拒绝本机的各种写法(探针会在那台机器屏幕上开窗、跑满主线程)。 +case "$HOST" in + localhost|127.*|::1|0.0.0.0|"$(hostname)"|"$(hostname -s)"|"$(scutil --get LocalHostName 2>/dev/null).local") + echo "REFUSED: $HOST 是本机;intel-floor 只对另一台机器跑(本机用 scripts/perf-report.sh --host)" >&2; exit 3 ;; +esac +for ip in $(ifconfig 2>/dev/null | awk '/inet /{print $2}'); do + [ "$HOST" != "$ip" ] || { echo "REFUSED: $HOST 是本机的地址" >&2; exit 3; } +done + +KEY="${INTEL_FLOOR_KEY:-$HOME/.ssh/oclp_macbook}" +SSH_OPTS=(-i "$KEY" -o IdentitiesOnly=yes -o ConnectTimeout=10 -o ServerAliveInterval=30) +rsh() { ssh "${SSH_OPTS[@]}" "$TARGET" "$@"; } +rcp() { scp -q "${SSH_OPTS[@]}" "$@"; } + +rsh true || { echo "NOT RUN: 连不上 $TARGET(机器睡了、或不在同一网段)" >&2; exit 78; } +arch=$(rsh uname -m) +[ "$arch" = x86_64 ] || { echo "REFUSED: $TARGET 是 $arch,不是 Intel" >&2; exit 3; } + +APP=.build/duo-validation-intel/WindowShade.app +FIXDIR=.build/glance-tests-intel +FIX=$FIXDIR/GlanceFixture.app +if [ "$BUILD" = 1 ]; then + echo "==> 编 x86_64 --stage" + (cd prototype && WINDOWSHADE_ARCH=x86_64 ./build.sh --stage) +fi +[ -d "$APP" ] || { echo "找不到 $APP(去掉 --no-build 重跑)" >&2; exit 1; } +lipo -archs "$APP/Contents/MacOS/WindowShade" | grep -qx x86_64 || { echo "$APP 不是纯 x86_64" >&2; exit 1; } + +echo "==> 编 x86_64 GlanceFixture" +mkdir -p "$FIX/Contents/MacOS" +swiftc -O -target x86_64-apple-macos15.0 tests/fixtures/GlanceFixture.swift -o "$FIX/Contents/MacOS/GlanceFixture" +cat > "$FIX/Contents/Info.plist" <<'PLIST' + + + +CFBundleIdentifiercom.windowshade.glance-fixture +CFBundleNameGlanceFixture +CFBundleExecutableGlanceFixture +CFBundlePackageTypeAPPL +LSMinimumSystemVersion15.0 + +PLIST +codesign --force -s - "$FIX" >/dev/null 2>&1 || true + +echo "==> 传到 $TARGET:~/wsqa-run" +pack=$(mktemp -d -t intel-floor) +trap 'rm -rf "$pack"' EXIT +ditto -c -k --keepParent "$APP" "$pack/app.zip" +ditto -c -k --keepParent "$FIX" "$pack/fixture.zip" +rcp "$pack/app.zip" "$pack/fixture.zip" tests/vm/run-in-guest.sh scripts/energy-profile.sh "$TARGET:/tmp/" +# energy-profile.sh 会 cd 到脚本上一层;放进 ~/wsqa-run/scripts/,上一层就是 ~/wsqa-run。 +rsh 'set -e; mkdir -p ~/wsqa-run/scripts + pkill -x WindowShade 2>/dev/null || true; pkill -x GlanceFixture 2>/dev/null || true + rm -rf ~/wsqa-run/WindowShade.app ~/wsqa-run/GlanceFixture.app + ditto -x -k /tmp/app.zip ~/wsqa-run/ && ditto -x -k /tmp/fixture.zip ~/wsqa-run/ + mv /tmp/run-in-guest.sh ~/wsqa-run/run-in-guest.sh && mv /tmp/energy-profile.sh ~/wsqa-run/scripts/energy-profile.sh + rm -f /tmp/app.zip /tmp/fixture.zip + codesign --verify --strict ~/wsqa-run/WindowShade.app && echo "remote codesign: ok"' + +echo "==> 远端准备:caffeinate、锁屏、负载" +rsh 'pkill -f "caffeinate -d -i -t 7200" 2>/dev/null; nohup caffeinate -d -i -t 7200 >/dev/null 2>&1 &' || true +locked=$(rsh 'ioreg -n Root -d1 | grep -c "CGSSessionScreenIsLocked\"=Yes"' || true) +[ "${locked:-0}" = 0 ] || { echo "NOT RUN: $TARGET 的屏幕锁着;先在那台机器上解锁(caffeinate 已开,不会再锁)" >&2; exit 78; } +wait_load() { + local t0=$SECONDS load + while :; do + load=$(rsh 'sysctl -n vm.loadavg' | awk '{print $2}') + awk -v l="$load" 'BEGIN{exit !(l < 6)}' && { echo "INFO load $load"; return 0; } + (( SECONDS - t0 < 300 )) || { echo "NOT RUN: $TARGET 的 load $load 5 分钟都没降到 6 以下" >&2; return 1; } + echo "INFO load $load ≥ 6,等 15 秒"; sleep 15 + done +} + +MACHINE=$(rsh 'echo "$(sysctl -n hw.model) · $(sysctl -n machdep.cpu.brand_string | sed "s/(R)//g; s/(TM)//g; s/ CPU.*//; s/ */ /g") · macOS $(sw_vers -productVersion)"') +MACHINE="$MACHINE · x86_64 build" +OUT=.build/perf/intel-floor/$(date +%Y%m%d-%H%M%S) +mkdir -p "$OUT" +ledger_flag=(); [ "$LEDGER" = 1 ] || ledger_flag=(--no-ledger) +status=0 +for r in $(seq 1 "$ROUNDS"); do + wait_load || exit 78 + echo "==> hitch 第 $r/$ROUNDS 遍(每类 $HITCH_ROUNDS 次)" + # 真机比虚拟机快,但 m3 收起一次要 1–2 秒:每组总时限放到 30 分钟。 + rsh "WSQA_HITCH_ROUNDS=$HITCH_ROUNDS WSQA_TIMEOUT_SCALE=2 WSQA_SUITE_TIMEOUT=1800 bash ~/wsqa-run/run-in-guest.sh hitch" | tee "$OUT/summary-$r.txt" || status=$? + rcp "$TARGET:wsqa-run/results/hitch.txt" "$OUT/hitch-$r.txt" + scripts/perf-report.sh --parse "$OUT/hitch-$r.txt" --machine "$MACHINE" --app "$APP" ${ledger_flag[@]+"${ledger_flag[@]}"} || status=$? +done + +if [ "$ENERGY" = 1 ]; then + echo "==> 静置能耗(3 × 60 秒,别碰那台机器)" + rsh 'bash ~/wsqa-run/scripts/energy-profile.sh ~/wsqa-run/WindowShade.app/Contents/MacOS/WindowShade' | tee "$OUT/energy.txt" || status=$? +fi +rsh 'pkill -f "caffeinate -d -i -t 7200"' 2>/dev/null || true +echo "intel-floor: 输出在 $OUT" +exit "$status" diff --git a/scripts/perf-report.sh b/scripts/perf-report.sh index 28d3af97..6eeab05d 100755 --- a/scripts/perf-report.sh +++ b/scripts/perf-report.sh @@ -11,10 +11,11 @@ # scripts/perf-report.sh --vm lume@ [--rounds N] 虚拟机:走 tests/vm/run-core-probes.sh(先在本机跑过一次 tests/run-glance-probe.sh) # scripts/perf-report.sh --parse <日志文件> [--machine 文字] 只解析已有输出(包含 HITCH 行),不跑探针;用于补记和自测 # --no-ledger 只写 .build/perf/*.json,不改 docs/perf-ledger.md +# --app <包> 读这个包的版本号与 build 号(默认 .build/duo-validation/WindowShade.app;intel-floor.sh 传 Intel 包) set -euo pipefail cd "$(dirname "$0")/.." -MODE=""; VMHOST=""; ROUNDS=20; FORCE=0; LOGFILE=""; MACHINE_OVERRIDE=""; LEDGER=1 +MODE=""; VMHOST=""; ROUNDS=20; FORCE=0; LOGFILE=""; MACHINE_OVERRIDE=""; LEDGER=1; APP_OVERRIDE="" while [ $# -gt 0 ]; do case "$1" in --host) MODE=host; shift ;; @@ -24,13 +25,14 @@ while [ $# -gt 0 ]; do --force) FORCE=1; shift ;; --machine) MACHINE_OVERRIDE="${2:?}"; shift 2 ;; --no-ledger) LEDGER=0; shift ;; + --app) APP_OVERRIDE="${2:?--app needs a path}"; shift 2 ;; *) echo "unknown option $1" >&2; exit 2 ;; esac done [ -n "$MODE" ] || { echo "usage: perf-report.sh --host | --vm lume@ | --parse [--rounds N] [--force] [--no-ledger]" >&2; exit 2; } [[ "$ROUNDS" =~ ^[0-9]+$ ]] || { echo "--rounds 要是整数" >&2; exit 2; } -APP=.build/duo-validation/WindowShade.app +APP=${APP_OVERRIDE:-.build/duo-validation/WindowShade.app} plist() { [ -f "$APP/Contents/Info.plist" ] && /usr/libexec/PlistBuddy -c "Print $1" "$APP/Contents/Info.plist" 2>/dev/null || true; } BUILD=$(plist CFBundleVersion); VERSION=$(plist CFBundleShortVersionString) COMMIT=$(git rev-parse --short=9 HEAD 2>/dev/null || echo unknown) From fd1af313e5e235df1beb9c272a1248fb8faa14d4 Mon Sep 17 00:00:00 2001 From: Aaron <12213433+surfine@users.noreply.github.com> Date: Mon, 23 Nov 2026 13:53:58 +0800 Subject: [PATCH 02/27] =?UTF-8?q?feat(=E6=80=A7=E8=83=BD):=20=E5=8D=A1?= =?UTF-8?q?=E9=A1=BF=E5=B0=BA=E8=A1=A5=E9=BD=90=E2=80=94=E2=80=94=E6=8E=A2?= =?UTF-8?q?=E9=92=88=E6=89=A3=E6=8E=89=E8=87=AA=E8=BA=AB=E5=99=AA=E5=A3=B0?= =?UTF-8?q?=E3=80=81HITCH-present=20=E5=91=88=E7=8E=B0=E4=BE=A7=E6=8C=87?= =?UTF-8?q?=E6=A0=87=E3=80=81glance=EF=BC=8Funfold=EF=BC=8Ffold=20?= =?UTF-8?q?=E5=AE=89=E8=A3=85=E6=AD=A5=E9=AA=A4=20signpost=E3=80=81refresh?= =?UTF-8?q?Panel=20=E8=AE=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 性能计划第 0 阶段第 2–4 条,只加量法与埋点,不改产品行为: - hitch 展开等待先看行程内状态,动画跑完才问 CGWindowList;onscreen() 一次查询拿在屏与框。 - Effects/PresentTimeline:探针在量时记 FoldRenderer drawable 的 presentedTime, HitchMeter 同一算法印 HITCH-present fold/unfold;perf-report 记作 present-fold/present-unfold。 - SystemLog.glanceSignposter(prepare/show/hide/finish);foldPhase 每步一个 fold/phase 区间; unfold/unfold-restore 同步区间;refreshPanel 计数、区间、关面板时写日志,hitch 探针印每次打开的次数。 Co-Authored-By: Claude Opus 5.5 --- prototype/App/FoldExit.swift | 4 ++ prototype/App/Glance.swift | 8 ++++ prototype/App/GlanceProbe.swift | 5 +- prototype/App/HitchProbe.swift | 48 +++++++++++++++++-- prototype/Core/HitchMeter.swift | 7 +-- prototype/Effects/FoldRenderer.swift | 1 + prototype/Effects/PresentTimeline.swift | 30 ++++++++++++ prototype/Support/SystemLog.swift | 3 ++ prototype/Window/AppWindows.swift | 7 ++- .../WindowBrowserController.swift | 9 +++- scripts/perf-report.sh | 8 ++-- tests/HitchMeterTests.swift | 4 ++ 12 files changed, 119 insertions(+), 15 deletions(-) create mode 100644 prototype/Effects/PresentTimeline.swift diff --git a/prototype/App/FoldExit.swift b/prototype/App/FoldExit.swift index e46bfc35..f408b190 100644 --- a/prototype/App/FoldExit.swift +++ b/prototype/App/FoldExit.swift @@ -7,6 +7,8 @@ extension AppDelegate { func unshadeReturningElement(_ id: CGWindowID, playSound: Bool = true, pinAfterRestore: Bool = true, onVerified: ((Bool) -> Void)? = nil) -> AXUIElement? { + let signpost = SystemLog.foldSignposter.beginInterval("unfold-restore", id: SystemLog.foldSignposter.makeSignpostID(), "window=\(id)") + defer { SystemLog.foldSignposter.endInterval("unfold-restore", signpost) } duoController.windowEffects.cancelForSynchronousRestore(id) guard shaded[id] != nil else { return nil } // 同 ShadeController.shade:展开开始就在后台把音频设备叫醒,音效不迟半秒。 @@ -112,6 +114,8 @@ extension AppDelegate { } @discardableResult func unshade(_ id: CGWindowID) -> Bool { + let signpost = SystemLog.foldSignposter.beginInterval("unfold", id: SystemLog.foldSignposter.makeSignpostID(), "window=\(id)") + defer { SystemLog.foldSignposter.endInterval("unfold", signpost) } MainThreadActivity.push("restore: 展开窗口") defer { MainThreadActivity.pop() } let memoScope = beginAppWindowsMemo() diff --git a/prototype/App/Glance.swift b/prototype/App/Glance.swift index bc70fdc6..f87fe4a0 100644 --- a/prototype/App/Glance.swift +++ b/prototype/App/Glance.swift @@ -567,6 +567,8 @@ final class GlanceController { } private func prepare(_ id: CGWindowID) { + let signpost = SystemLog.glanceSignposter.beginInterval("prepare", id: SystemLog.glanceSignposter.makeSignpostID(), "window=\(id)") + defer { SystemLog.glanceSignposter.endInterval("prepare", signpost) } if let existing = sessions[id] { if existing.stage == .closing, existing.rehiddenAt != nil { // 真窗口已藏回、视频流已停:旧画面不能再当作实时会话复用。 @@ -645,6 +647,8 @@ final class GlanceController { } private func open(_ id: CGWindowID) { + let signpost = SystemLog.glanceSignposter.beginInterval("show", id: SystemLog.glanceSignposter.makeSignpostID(), "window=\(id)") + defer { SystemLog.glanceSignposter.endInterval("show", signpost) } guard let session = sessions[id] else { return } if session.stage == .shown || session.stage == .waitingForFrame { return } guard let target = target(for: id) else { @@ -743,6 +747,8 @@ final class GlanceController { } private func close(_ id: CGWindowID) { + let signpost = SystemLog.glanceSignposter.beginInterval("hide", id: SystemLog.glanceSignposter.makeSignpostID(), "window=\(id)") + defer { SystemLog.glanceSignposter.endInterval("hide", signpost) } guard let session = sessions[id] else { return } switch session.stage { case .expanding, .closing: @@ -767,6 +773,8 @@ final class GlanceController { } private func finish(_ session: GlanceSession, reason: String) { + let signpost = SystemLog.glanceSignposter.beginInterval("finish", id: SystemLog.glanceSignposter.makeSignpostID(), "\(reason, privacy: .public)") + defer { SystemLog.glanceSignposter.endInterval("finish", signpost) } if sessions[session.id] === session { sessions.removeValue(forKey: session.id) } diff --git a/prototype/App/GlanceProbe.swift b/prototype/App/GlanceProbe.swift index 3ba32a6e..836dc32e 100644 --- a/prototype/App/GlanceProbe.swift +++ b/prototype/App/GlanceProbe.swift @@ -1479,8 +1479,9 @@ final class GlanceProbe { } func onscreen(_ id: CGWindowID) -> Bool { - guard cgWindowInfo(id)?[kCGWindowIsOnscreen as String] as? Bool == true, - let b = bounds(id) else { return false } + // 一次 CGWindowList 查询同时拿在屏与框(原来查两次):等待循环每 8 ms 调一次,查询本身会占主线程。 + guard let info = cgWindowInfo(id), info[kCGWindowIsOnscreen as String] as? Bool == true, + let b = cgWindowBounds(info) else { return false } return b.minX > -2000 && b.minY > -2000 } diff --git a/prototype/App/HitchProbe.swift b/prototype/App/HitchProbe.swift index b3a970e0..501158e3 100644 --- a/prototype/App/HitchProbe.swift +++ b/prototype/App/HitchProbe.swift @@ -89,6 +89,13 @@ extension GlanceProbe { do { try await body() } catch { _ = recorder.stop(); throw error } return recorder.stop() } + /// 收起/展开走 Metal:主线程的显示链接之外,同时记 drawable 的上屏时刻(呈现侧,见 Effects/PresentTimeline.swift)。 + func measureWithPresents(_ body: () async throws -> Void) async throws -> (main: [Double], present: [Double]) { + PresentTimeline.start() + let main: [Double] + do { main = try await measure(body) } catch { _ = PresentTimeline.stop(); throw error } + return (main, PresentTimeline.stop()) + } /// 状态先翻、动画后到:判定条件成立后再量一小段尾巴,盖住剩下的动画。 func tail(_ ms: Int) async throws { try await Task.sleep(for: .milliseconds(ms), clock: .suspending) } @@ -98,6 +105,7 @@ extension GlanceProbe { // 下一次收起若在那之前开始,会和这些补丁抢主线程(也会把它们量进下一次收起里)。 // 一轮超时不整组中止:打印当时的状态、设法展开复原,记一次失败接着下一轮;连续 2 轮失败才放弃这一类。 var folds: [[Double]] = [], unfolds: [[Double]] = [] + var foldPresents: [[Double]] = [], unfoldPresents: [[Double]] = [] var foldFailures: [String] = [] var consecutive = 0 var hides: [String: Int] = [:] @@ -106,7 +114,7 @@ extension GlanceProbe { await ShareableContentCache.shared.prefetch() do { let started = CACurrentMediaTime() - let fold = try await measure { + let fold = try await measureWithPresents { owner.shade(element, id) try await wait("hitch fold \(round)", timeout: foldLimit) { self.owner.shaded[self.id]?.overlay.map { $0.isVisible && $0.alphaValue > 0.5 } == true @@ -116,16 +124,21 @@ extension GlanceProbe { } if let hide = owner.shaded[id]?.hide { hides["\(hide)", default: 0] += 1 } try await Task.sleep(for: .milliseconds(500), clock: .suspending) - let unfold = try await measure { + let unfold = try await measureWithPresents { _ = owner.unshade(id) + // 先看行程内的状态,动画跑完才去问 CGWindowList:量的正是这段时间的主线程, + // 探针自己每 8 ms 一次的窗口列表查询不能算进卡顿里。条件仍是三者同时成立。 try await wait("hitch unfold \(round)", timeout: unfoldLimit) { - self.onscreen(self.id) && self.owner.shaded[self.id] == nil + self.owner.shaded[self.id] == nil && self.owner.duoController.windowEffects.activeCount == 0 + && self.onscreen(self.id) } try await tail(150) } - folds.append(fold) - unfolds.append(unfold) + folds.append(fold.main) + unfolds.append(unfold.main) + foldPresents.append(fold.present) + unfoldPresents.append(unfold.present) consecutive = 0 if CACurrentMediaTime() - started > 6 { print(String(format: "INFO hitch fold round %d: slow round %.1f s", round, CACurrentMediaTime() - started)) @@ -150,6 +163,7 @@ extension GlanceProbe { print("FAIL hitch fold: \(foldFailures.count) of \(folds.count + foldFailures.count) rounds did not finish; first: \(foldFailures[0])") } results += [("fold", folds), ("unfold", unfolds)] + let presentResults = [("fold", foldPresents), ("unfold", unfoldPresents)] // 窗口浏览开/关(同 soak-browser:只开关面板,不对任何窗口发动作)。 if WindowBrowserSettings.keyboardPanelEnabled { @@ -161,6 +175,7 @@ extension GlanceProbe { browser.stop() } var opens: [[Double]] = [], closes: [[Double]] = [] + var refreshes: [Int] = [] for round in 1...rounds { var refused = false opens.append(try await measure { @@ -177,6 +192,7 @@ extension GlanceProbe { print("FAIL hitch browser: the panel refused to open at round \(round)") break } + refreshes.append(browser.refreshPanelCount) closes.append(try await measure { browser.probeClosePanel() try await wait("hitch browser close \(round)", timeout: 5) { !browser.probePanelVisible } @@ -185,6 +201,11 @@ extension GlanceProbe { try await Task.sleep(for: .milliseconds(200), clock: .suspending) } results += [("browser-open", opens), ("browser-close", closes)] + // 每次打开(含列表填满和 350 ms 尾巴)里 refreshPanel 真正刷新了几次:1A 合并刷新的直接读数。 + if !refreshes.isEmpty { + let sorted = refreshes.sorted() + print("INFO hitch browser-open: refreshPanel per open min=\(sorted[0]) median=\(sorted[sorted.count / 2]) max=\(sorted[sorted.count - 1]) total=\(sorted.reduce(0, +))") + } } else { print("SKIP hitch browser: Window browser is off in Settings; the probe does not change settings") } @@ -244,6 +265,23 @@ extension GlanceProbe { } fflush(stdout) } + + // 呈现侧:同一套算法、同一个预算,算的是 Metal drawable 真正上屏的间隔(GPU/窗口服务器掉的帧在这里才看得到)。 + // 一次交互首个到末个上屏之间才算;没有上屏记录(虚拟机里收起动画关着)就只打印 INFO,不当作结果。 + for (kind, runs) in presentResults { + let measured = runs.filter { $0.count >= 2 } + guard !measured.isEmpty else { + print("INFO hitch-present \(kind): no Metal presents recorded\(vm && !animatedInVM ? " (VM: fold cover animation off)" : "")") + continue + } + let stats = HitchMeter.merge(measured, refreshHz: recorder.refreshHz) + print(HitchMeter.line(kind: kind, stats, prefix: "HITCH-present")) + let problems = budget.violations(stats) + print(problems.isEmpty + ? "PASS hitch-present \(kind): \(vm ? "within the VM budget" : "within budget") (\(measured.count) of \(runs.count) rounds presented)" + : "FAIL hitch-present \(kind): \(problems.joined(separator: ", "))\(vm ? " (VM budget)" : "") (\(measured.count) of \(runs.count) rounds presented)") + fflush(stdout) + } } /// 超时那一刻的收起状态,一行:生命周期、隐藏方式、卷帘条、真窗口在不在屏、前台是谁、效果是否还在跑。 diff --git a/prototype/Core/HitchMeter.swift b/prototype/Core/HitchMeter.swift index b2ac4237..bfa8d876 100644 --- a/prototype/Core/HitchMeter.swift +++ b/prototype/Core/HitchMeter.swift @@ -97,9 +97,10 @@ enum HitchMeter { } /// `HITCH n=… ratio=… ms/s worst=… ms p95=… ms refresh=… Hz` 一行,便于 grep 和跨构建对比。 - static func line(kind: String, _ s: Stats) -> String { - String(format: "HITCH %@ n=%d ratio=%.2f ms/s worst=%.1f ms p95=%.1f ms refresh=%.0f Hz frames=%d duration=%.2f s tier=%@", - kind, s.interactions, s.ratioMsPerSecond, s.worstFrameMs, s.p95FrameMs, s.refreshHz, + /// 呈现侧(Metal drawable 真正上屏的时刻)用 `prefix: "HITCH-present"`,字段完全相同。 + static func line(kind: String, _ s: Stats, prefix: String = "HITCH") -> String { + String(format: "%@ %@ n=%d ratio=%.2f ms/s worst=%.1f ms p95=%.1f ms refresh=%.0f Hz frames=%d duration=%.2f s tier=%@", + prefix, kind, s.interactions, s.ratioMsPerSecond, s.worstFrameMs, s.p95FrameMs, s.refreshHz, s.intervals, s.duration, tier(ratioMsPerSecond: s.ratioMsPerSecond).rawValue) } } diff --git a/prototype/Effects/FoldRenderer.swift b/prototype/Effects/FoldRenderer.swift index a821acae..ef2b225e 100644 --- a/prototype/Effects/FoldRenderer.swift +++ b/prototype/Effects/FoldRenderer.swift @@ -504,6 +504,7 @@ import MetalKit let time = presented.presentedTime DispatchQueue.main.async { [weak self] in guard let self, epoch.accepts(token), !cleared, time > 0 else { return } + PresentTimeline.record(time) presentedCount += 1 if let previous = lastPresentedTime, time > previous { append(time - previous, to: &intervals) diff --git a/prototype/Effects/PresentTimeline.swift b/prototype/Effects/PresentTimeline.swift new file mode 100644 index 00000000..dbb5c2e1 --- /dev/null +++ b/prototype/Effects/PresentTimeline.swift @@ -0,0 +1,30 @@ +import QuartzCore + +/// 呈现侧的卡顿尺(性能计划第 0 阶段第 3 条):`HitchRecorder` 的显示链接只看得到主线程有没有按时让出每一帧, +/// GPU 或窗口服务器那一侧掉的帧它看不到。这里记收起/展开期间 Metal 路径每个 drawable 真正上屏的时刻 +/// (`MTLDrawable.presentedTime`),探针拿去用 `HitchMeter` 同一套算法算出 `HITCH-present` 一行。 +/// 只有探针在量的那段时间 `isRecording` 为真;平时 `FoldRenderer` 只多一次布尔判断,不存任何东西。 +@MainActor +enum PresentTimeline { + private(set) static var isRecording = false + private static var times: [CFTimeInterval] = [] + + static func start() { + times.removeAll(keepingCapacity: true) + isRecording = true + } + + /// 停止并交回这段时间里按上屏时刻排好序的时间戳(秒,和 `CACurrentMediaTime` 同一时基)。 + static func stop() -> [Double] { + isRecording = false + let out = times.sorted() + times.removeAll() + return out + } + + /// `FoldRenderer` 的 presented handler 回到主线程后调用;同一时刻(几扇窗同帧上屏)只记一次。 + static func record(_ time: CFTimeInterval) { + guard isRecording, time > 0, !times.contains(time) else { return } + times.append(time) + } +} diff --git a/prototype/Support/SystemLog.swift b/prototype/Support/SystemLog.swift index 79ab5ffe..c8c15742 100644 --- a/prototype/Support/SystemLog.swift +++ b/prototype/Support/SystemLog.swift @@ -15,4 +15,7 @@ enum SystemLog { /// 收起:从开始到收尾(成功或放弃);窗口浏览:从输入到达到面板关上,中间每个阶段一个事件。 static let foldSignposter = OSSignposter(subsystem: subsystem, category: "fold") static let windowBrowserSignposter = OSSignposter(subsystem: subsystem, category: "window-browser") + /// 性能计划第 0 阶段第 4 条:看一眼的 prepare/show/hide/finish 各是一段主线程区间, + /// 收起的每个安装步骤(foldPhase)是 fold 类目下的 `phase` 区间,展开的同步部分是 `unfold` 区间。 + static let glanceSignposter = OSSignposter(subsystem: subsystem, category: "glance") } diff --git a/prototype/Window/AppWindows.swift b/prototype/Window/AppWindows.swift index 6621df1b..dadfb203 100644 --- a/prototype/Window/AppWindows.swift +++ b/prototype/Window/AppWindows.swift @@ -40,7 +40,12 @@ nonisolated(unsafe) var foldPhaseTotals: [String: Double] = [:] @discardableResult func foldPhase(_ name: String, _ body: () throws -> T) rethrows -> T { let started = CFAbsoluteTimeGetCurrent() - defer { foldPhaseTotals[name, default: 0] += CFAbsoluteTimeGetCurrent() - started } + // 每个安装步骤也是一段 signpost 区间(Instruments 的 os_signpost 轨道上按步骤名看得到)。 + let signpost = SystemLog.foldSignposter.beginInterval("phase", id: SystemLog.foldSignposter.makeSignpostID(), "\(name, privacy: .public)") + defer { + SystemLog.foldSignposter.endInterval("phase", signpost) + foldPhaseTotals[name, default: 0] += CFAbsoluteTimeGetCurrent() - started + } return try body() } diff --git a/prototype/WindowBrowser/WindowBrowserController.swift b/prototype/WindowBrowser/WindowBrowserController.swift index ac6daf79..25b578ee 100644 --- a/prototype/WindowBrowser/WindowBrowserController.swift +++ b/prototype/WindowBrowser/WindowBrowserController.swift @@ -219,12 +219,15 @@ final class WindowBrowserController: NSObject { /// 规格 N3:一次面板会话一个区间(输入到达 → 面板关上),各阶段打事件。 private var browserSignpost: OSSignpostIntervalState? + /// 这次面板会话里 refreshPanel 真正刷新了几次(性能计划 1A 要合并它,先量)。面板关上时写进日志。 + private(set) var refreshPanelCount = 0 private func markInputArrival(_ source: String) { if let browserSignpost { SystemLog.windowBrowserSignposter.endInterval("session", browserSignpost, "superseded") } browserSignpost = SystemLog.windowBrowserSignposter.beginInterval( "session", id: SystemLog.windowBrowserSignposter.makeSignpostID(), "source=\(source, privacy: .public)") perfSessionID &+= 1 + refreshPanelCount = 0 perfMarks.removeAll() perfMarks["input-\(source)"] = CFAbsoluteTimeGetCurrent() didMarkFirstCatalogPublish = false @@ -1463,6 +1466,9 @@ final class WindowBrowserController: NSObject { private func refreshPanel() { dispatchPrecondition(condition: .onQueue(.main)) guard running, !environmentSuspended, let session, let contentView else { return } + refreshPanelCount += 1 + let signpost = SystemLog.windowBrowserSignposter.beginInterval("refreshPanel", id: SystemLog.windowBrowserSignposter.makeSignpostID(), "n=\(self.refreshPanelCount)") + defer { SystemLog.windowBrowserSignposter.endInterval("refreshPanel", signpost) } let excluded = WindowBrowserSettings.excludedBundleIDs var records = catalog.publish().filter { !excluded.contains($0.bundleIdentifier) } if let app = session.app { @@ -2682,8 +2688,9 @@ final class WindowBrowserController: NSObject { private func closePanel(reason: String) { if let browserSignpost { - SystemLog.windowBrowserSignposter.endInterval("session", browserSignpost, "closed \(reason, privacy: .public)") + SystemLog.windowBrowserSignposter.endInterval("session", browserSignpost, "closed \(reason, privacy: .public) refreshPanel=\(self.refreshPanelCount)") self.browserSignpost = nil + wlog("perf: refreshPanel count=\(refreshPanelCount) session=\(perfSessionID) reason=\(reason)") } dispatchPrecondition(condition: .onQueue(.main)) if menuTracking.requestClose(reason: reason) { diff --git a/scripts/perf-report.sh b/scripts/perf-report.sh index 6eeab05d..ebe20a0d 100755 --- a/scripts/perf-report.sh +++ b/scripts/perf-report.sh @@ -10,6 +10,7 @@ # 探针会在屏幕上短暂开一扇临时窗口,不碰你的窗口,也不动真鼠标 # scripts/perf-report.sh --vm lume@ [--rounds N] 虚拟机:走 tests/vm/run-core-probes.sh(先在本机跑过一次 tests/run-glance-probe.sh) # scripts/perf-report.sh --parse <日志文件> [--machine 文字] 只解析已有输出(包含 HITCH 行),不跑探针;用于补记和自测 +# 呈现侧的 HITCH-present 行一并解析,类名记作 present-fold、present-unfold。 # --no-ledger 只写 .build/perf/*.json,不改 docs/perf-ledger.md # --app <包> 读这个包的版本号与 build 号(默认 .build/duo-validation/WindowShade.app;intel-floor.sh 传 Intel 包) set -euo pipefail @@ -68,14 +69,15 @@ JSON=".build/perf/$TS-${BUILD:-nobuild}.json" python3 -I - "$out" "$JSON" "$LEDGER" "${VERSION:-?}" "${BUILD:-?}" "$COMMIT$DIRTY" "$MACHINE" "$MODE" "$STAMP" "$RUN_STATUS" <<'PY' import json, re, sys log, jpath, ledger, version, build, commit, machine, mode, stamp, status = sys.argv[1:] -pat = re.compile(r'^HITCH (\S+) n=(\d+) ratio=([\d.]+) ms/s worst=([\d.]+) ms p95=([\d.]+) ms refresh=([\d.]+) Hz frames=(\d+) duration=([\d.]+) s tier=(\w+)') +# 主线程(HITCH)与呈现侧(HITCH-present,Metal drawable 上屏间隔)同一格式;呈现侧的类记成 present-<类>。 +pat = re.compile(r'^HITCH(-present)? (\S+) n=(\d+) ratio=([\d.]+) ms/s worst=([\d.]+) ms p95=([\d.]+) ms refresh=([\d.]+) Hz frames=(\d+) duration=([\d.]+) s tier=(\w+)') text = open(log, errors='replace').read() rows = [] for line in text.splitlines(): m = pat.match(line.strip()) if m: - k, n, ratio, worst, p95, hz, frames, dur, tier = m.groups() - rows.append({"kind": k, "n": int(n), "ratio_ms_per_s": float(ratio), "worst_ms": float(worst), + side, k, n, ratio, worst, p95, hz, frames, dur, tier = m.groups() + rows.append({"kind": ("present-" + k) if side else k, "n": int(n), "ratio_ms_per_s": float(ratio), "worst_ms": float(worst), "p95_ms": float(p95), "refresh_hz": float(hz), "frames": int(frames), "duration_s": float(dur), "tier": tier}) if not rows: diff --git a/tests/HitchMeterTests.swift b/tests/HitchMeterTests.swift index 12c27dcb..c32c6968 100644 --- a/tests/HitchMeterTests.swift +++ b/tests/HitchMeterTests.swift @@ -79,6 +79,10 @@ struct HitchMeterTests { let line = HitchMeter.line(kind: "fold", stall) expect(line.hasPrefix("HITCH fold n=1 ratio=32.26 ms/s worst=50.0 ms p95=16.7 ms refresh=60 Hz"), "summary line format: \(line)") + // 呈现侧同一格式,只换前缀;perf-report.sh 靠 `HITCH ` 与 `HITCH-present ` 区分两组。 + let present = HitchMeter.line(kind: "fold", stall, prefix: "HITCH-present") + expect(present.hasPrefix("HITCH-present fold n=1 ratio=32.26 ms/s worst=50.0 ms") && present.dropFirst("HITCH-present".count) == line.dropFirst("HITCH".count), + "present line differs only in prefix: \(present)") print(failures == 0 ? "PASS hitch-meter tests" : "FAIL hitch-meter tests: \(failures)") exit(failures == 0 ? 0 : 1) From 2370ed6e05e640492383a85ba5a402faa22e88dc Mon Sep 17 00:00:00 2001 From: Aaron <12213433+surfine@users.noreply.github.com> Date: Mon, 23 Nov 2026 14:16:03 +0800 Subject: [PATCH 03/27] =?UTF-8?q?fix(=E6=80=A7=E8=83=BD):=20HITCH-present?= =?UTF-8?q?=20=E5=8F=AA=E7=AE=97=E5=8A=A8=E7=94=BB=E5=9C=A8=E5=8A=A8?= =?UTF-8?q?=E7=9A=84=E5=8F=AF=E8=A7=81=E5=B8=A7=EF=BC=8C=E8=B5=B7=E8=B7=91?= =?UTF-8?q?=E5=BB=B6=E8=BF=9F=E5=8F=A6=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 面板还透明(等 GPU 就绪)时的帧、盖板停在静止画面等藏窗/恢复确认时的帧都不是掉帧, 之前被算成 133–200 ms 的长间隔。现在编码时记可见性与进度是否变化,只用在动的帧算卡顿; 首个可见帧到首个在动帧的时长打印成 start delay(M5 上收起中位 233 ms、展开 67 ms)。 另印每次交互里超过 1.5 帧的间隔位置,分清中途掉帧和首尾空档。 Co-Authored-By: Claude Opus 5.5 --- prototype/App/HitchProbe.swift | 21 +++++++++++++--- prototype/Effects/FoldRenderer.swift | 9 ++++++- prototype/Effects/PresentTimeline.swift | 32 ++++++++++++++++++++----- 3 files changed, 52 insertions(+), 10 deletions(-) diff --git a/prototype/App/HitchProbe.swift b/prototype/App/HitchProbe.swift index 501158e3..d48b41eb 100644 --- a/prototype/App/HitchProbe.swift +++ b/prototype/App/HitchProbe.swift @@ -90,7 +90,7 @@ extension GlanceProbe { return recorder.stop() } /// 收起/展开走 Metal:主线程的显示链接之外,同时记 drawable 的上屏时刻(呈现侧,见 Effects/PresentTimeline.swift)。 - func measureWithPresents(_ body: () async throws -> Void) async throws -> (main: [Double], present: [Double]) { + func measureWithPresents(_ body: () async throws -> Void) async throws -> (main: [Double], present: PresentTimeline.Recording) { PresentTimeline.start() let main: [Double] do { main = try await measure(body) } catch { _ = PresentTimeline.stop(); throw error } @@ -105,7 +105,7 @@ extension GlanceProbe { // 下一次收起若在那之前开始,会和这些补丁抢主线程(也会把它们量进下一次收起里)。 // 一轮超时不整组中止:打印当时的状态、设法展开复原,记一次失败接着下一轮;连续 2 轮失败才放弃这一类。 var folds: [[Double]] = [], unfolds: [[Double]] = [] - var foldPresents: [[Double]] = [], unfoldPresents: [[Double]] = [] + var foldPresents: [PresentTimeline.Recording] = [], unfoldPresents: [PresentTimeline.Recording] = [] var foldFailures: [String] = [] var consecutive = 0 var hides: [String: Int] = [:] @@ -268,14 +268,29 @@ extension GlanceProbe { // 呈现侧:同一套算法、同一个预算,算的是 Metal drawable 真正上屏的间隔(GPU/窗口服务器掉的帧在这里才看得到)。 // 一次交互首个到末个上屏之间才算;没有上屏记录(虚拟机里收起动画关着)就只打印 INFO,不当作结果。 - for (kind, runs) in presentResults { + for (kind, recordings) in presentResults { + let runs = recordings.map(\.moving) let measured = runs.filter { $0.count >= 2 } + // 起跑延迟:盖板第一次看得见到动画开始动(中间是安装/藏窗或恢复确认)。不是卡顿,单独报。 + let delays = recordings.compactMap(\.startDelay).map { $0 * 1000 }.sorted() + if !delays.isEmpty { + print(String(format: "INFO hitch-present %@: start delay (first visible frame to first moving frame) median %.0f ms, max %.0f ms over %d rounds", + kind, delays[delays.count / 2], delays[delays.count - 1], delays.count)) + } guard !measured.isEmpty else { print("INFO hitch-present \(kind): no Metal presents recorded\(vm && !animatedInVM ? " (VM: fold cover animation off)" : "")") continue } let stats = HitchMeter.merge(measured, refreshHz: recorder.refreshHz) print(HitchMeter.line(kind: kind, stats, prefix: "HITCH-present")) + // 长间隔落在一次交互的哪一段:第几个间隔/共几个,便于分清「动画中途掉帧」和「首帧与动画之间的空档」。 + let frame = 1 / recorder.refreshHz + let late = measured.enumerated().flatMap { round, run in + HitchMeter.intervals(run).enumerated().compactMap { index, gap in + gap > frame * 1.5 ? String(format: "r%d#%d/%d:%.0f", round + 1, index + 1, run.count - 1, gap * 1000) : nil + } + } + print("INFO hitch-present \(kind): late intervals \(late.prefix(40).joined(separator: " "))\(late.count > 40 ? " …(\(late.count))" : "")") let problems = budget.violations(stats) print(problems.isEmpty ? "PASS hitch-present \(kind): \(vm ? "within the VM budget" : "within budget") (\(measured.count) of \(runs.count) rounds presented)" diff --git a/prototype/Effects/FoldRenderer.swift b/prototype/Effects/FoldRenderer.swift index ef2b225e..c55d5b3f 100644 --- a/prototype/Effects/FoldRenderer.swift +++ b/prototype/Effects/FoldRenderer.swift @@ -94,6 +94,8 @@ import MetalKit private var gpuTimes: [Double] = [] private var intervals: [Double] = [] private var lastPresentedTime: CFTimeInterval? + /// 呈现侧卡顿尺用:上一次编码时的动画进度(只在探针记录时更新)。 + private var lastEncodedProgress: Float? private var measuredFrame: UInt64? private(set) var presentedCount = 0 private(set) var skippedBusy = 0 @@ -499,12 +501,17 @@ import MetalKit readback: readback) let space = colorSpace let size = (drawable.texture.width, drawable.texture.height) + // 呈现侧卡顿尺只算看得见的帧:面板还透明(alpha 0,EffectSession 等 GPU 就绪)时编码的帧不算。 + let visibleAtEncode = PresentTimeline.isRecording + && view.window.map { $0.isVisible && $0.alphaValue > 0 } == true + let movingAtEncode = visibleAtEncode && lastEncodedProgress != parameters.progress + if PresentTimeline.isRecording { lastEncodedProgress = parameters.progress } // Presentation time is separate from GPU completion, and counted once per fresh captured frame. drawable.addPresentedHandler { [weak self] presented in let time = presented.presentedTime DispatchQueue.main.async { [weak self] in guard let self, epoch.accepts(token), !cleared, time > 0 else { return } - PresentTimeline.record(time) + if visibleAtEncode { PresentTimeline.record(time, moving: movingAtEncode) } presentedCount += 1 if let previous = lastPresentedTime, time > previous { append(time - previous, to: &intervals) diff --git a/prototype/Effects/PresentTimeline.swift b/prototype/Effects/PresentTimeline.swift index dbb5c2e1..56ee56a2 100644 --- a/prototype/Effects/PresentTimeline.swift +++ b/prototype/Effects/PresentTimeline.swift @@ -4,27 +4,47 @@ import QuartzCore /// GPU 或窗口服务器那一侧掉的帧它看不到。这里记收起/展开期间 Metal 路径每个 drawable 真正上屏的时刻 /// (`MTLDrawable.presentedTime`),探针拿去用 `HitchMeter` 同一套算法算出 `HITCH-present` 一行。 /// 只有探针在量的那段时间 `isRecording` 为真;平时 `FoldRenderer` 只多一次布尔判断,不存任何东西。 +/// +/// 只算「动画在动」的帧:面板还透明(等 GPU 就绪)时的帧看不见,盖板停在静止画面上等藏窗/恢复确认时 +/// 画面本来就不该变——这两段都不是掉帧。静止那段的长度另记成起跑延迟(首个可见帧到首个在动的帧)。 @MainActor enum PresentTimeline { + struct Recording { + /// 动画在动的帧的上屏时刻,排好序(秒,和 `CACurrentMediaTime` 同一时基)。 + var moving: [Double] + /// 第一个看得见的帧上屏的时刻;没有可见帧为 nil。 + var firstVisible: Double? + /// 起跑延迟:首个可见帧到首个在动的帧,秒。 + var startDelay: Double? { + guard let firstVisible, let first = moving.first, first >= firstVisible else { return nil } + return first - firstVisible + } + } + private(set) static var isRecording = false private static var times: [CFTimeInterval] = [] + private static var firstVisible: CFTimeInterval? static func start() { times.removeAll(keepingCapacity: true) + firstVisible = nil isRecording = true } - /// 停止并交回这段时间里按上屏时刻排好序的时间戳(秒,和 `CACurrentMediaTime` 同一时基)。 - static func stop() -> [Double] { + static func stop() -> Recording { isRecording = false - let out = times.sorted() + let out = Recording(moving: times.sorted(), firstVisible: firstVisible) times.removeAll() + firstVisible = nil return out } - /// `FoldRenderer` 的 presented handler 回到主线程后调用;同一时刻(几扇窗同帧上屏)只记一次。 - static func record(_ time: CFTimeInterval) { - guard isRecording, time > 0, !times.contains(time) else { return } + /// `FoldRenderer` 的 presented handler 回到主线程后调用,只给编码时面板已经看得见的帧; + /// `moving` 表示这一帧的动画进度和上一帧不同。同一时刻(几扇窗同帧上屏)只记一次。 + static func record(_ time: CFTimeInterval, moving: Bool) { + guard isRecording, time > 0 else { return } + if firstVisible.map({ time < $0 }) ?? true { firstVisible = time } + guard moving, !times.contains(time) else { return } times.append(time) } } From a2a4aa98b19eec1c2f36c2ae7316094a05a23cac Mon Sep 17 00:00:00 2001 From: Aaron <12213433+surfine@users.noreply.github.com> Date: Mon, 23 Nov 2026 14:22:04 +0800 Subject: [PATCH 04/27] =?UTF-8?q?docs(=E6=80=A7=E8=83=BD):=20=E6=96=B0?= =?UTF-8?q?=E5=B0=BA=E4=B8=8B=20M5=20=E5=9F=BA=E7=BA=BF=E4=B8=A4=E8=BD=AE?= =?UTF-8?q?=EF=BC=88=E5=90=AB=20present-fold=EF=BC=8Fpresent-unfold?= =?UTF-8?q?=EF=BC=89=EF=BC=9Bperf-report=20=E7=9A=84=20+dirty=20=E4=B8=8D?= =?UTF-8?q?=E5=86=8D=E7=AE=97=E5=8D=A1=E9=A1=BF=E8=B4=A6=E8=87=AA=E5=B7=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- docs/perf-ledger.md | 5 +++++ scripts/perf-report.sh | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/perf-ledger.md b/docs/perf-ledger.md index c9a162e9..b32c9f75 100644 --- a/docs/perf-ledger.md +++ b/docs/perf-ledger.md @@ -6,6 +6,9 @@ - 末列每类写作 `类 ratio(ms/s)/worst(ms)`;类有 fold、unfold、browser-open、browser-close、glance-show、glance-hide。 - 跑法:主机 `scripts/perf-report.sh --host`(先 `cd prototype && ./build.sh --stage`,本机闲置 20 秒以上);虚拟机 `scripts/perf-report.sh --vm lume@`。 - `scripts/release-gate.sh` 会打印候选包 build 号对应的最近一行(INFO)。 +- 从 2026-11-23(1254aa1f)起多记两类 `present-fold`、`present-unfold`:呈现侧,Metal drawable 真正上屏的间隔,同一预算。只算盖板看得见、动画在动的帧;盖板静止等藏窗/恢复确认的那段是起跑延迟,不算卡顿(探针另印 `start delay`)。主线程(不带 present-)照旧是显示链接量的。 +- Intel 真机用 `scripts/intel-floor.sh user@host`(编 x86_64 包、传过去、跑两遍 hitch 和静置能耗,各记一行)。 +- 2026-11-23 的 M5 browser-open 比 11-23 早先那两行高一倍(455–460 vs 196–226 ms/s):同一台机器,当时桌面上开着的 App 与窗口更多(refreshPanel 每次打开 17 次)。比较时只和同一天、同一桌面状态的基线比。 | 日期 | 版本 (build) 提交 | 机器 | 刷新率 | 对照预算 | 各类 ratio/worst | | --- | --- | --- | --- | --- | --- | @@ -14,3 +17,5 @@ | 2026-11-22 | 1.0.22.1 (build 20261116.01) 05e2024f3 | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 (OCLP) · x86_64 build | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show | fold 280.6/166; unfold 237.8/117; browser-open 669.4/664; browser-close 38.4/50; glance-show 62.2/59; glance-hide 1.5/33 | | 2026-11-23 | 1.0.22.1 (build 20261116.01) 05e2024f3 | Mac17,4 · Apple M5 · macOS 27.2.1 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show | fold 75.4/96; unfold 43.9/80; browser-open 195.7/136; browser-close 43.5/33; glance-show 27.8/54; glance-hide 0.6/33 | | 2026-11-23 | 1.0.22.1 (build 20261116.01) 05e2024f3 | Mac17,4 · Apple M5 · macOS 27.2.1 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show | fold 70.0/88; unfold 41.4/58; browser-open 226.4/133; browser-close 43.7/35; glance-show 24.9/36; glance-hide 0.0/17 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) 1254aa1f4 | Mac17,4 · Apple M5 · macOS 27.2.1 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show、present-unfold | fold 54.0/60; unfold 45.4/59; browser-open 460.5/241; browser-close 43.5/50; glance-show 59.2/60; glance-hide 0.0/17; present-fold 0.0/17; present-unfold 12.1/33 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) 1254aa1f4 | Mac17,4 · Apple M5 · macOS 27.2.1 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show | fold 56.2/74; unfold 40.8/54; browser-open 454.7/234; browser-close 45.6/50; glance-show 56.5/55; glance-hide 2.4/33; present-fold 0.0/17; present-unfold 4.1/33 | diff --git a/scripts/perf-report.sh b/scripts/perf-report.sh index ebe20a0d..a7f67a1a 100755 --- a/scripts/perf-report.sh +++ b/scripts/perf-report.sh @@ -37,7 +37,7 @@ APP=${APP_OVERRIDE:-.build/duo-validation/WindowShade.app} plist() { [ -f "$APP/Contents/Info.plist" ] && /usr/libexec/PlistBuddy -c "Print $1" "$APP/Contents/Info.plist" 2>/dev/null || true; } BUILD=$(plist CFBundleVersion); VERSION=$(plist CFBundleShortVersionString) COMMIT=$(git rev-parse --short=9 HEAD 2>/dev/null || echo unknown) -DIRTY=""; git diff --quiet HEAD -- 2>/dev/null || DIRTY="+dirty" +DIRTY=""; git diff --quiet HEAD -- . ':!docs/perf-ledger.md' 2>/dev/null || DIRTY="+dirty" # 卡顿账自己被写过不算改了代码 STAMP=$(date +%Y-%m-%d); TS=$(date +%Y%m%d-%H%M%S) mkdir -p .build/perf out=$(mktemp -t perf-report); trap 'rm -f "$out"' EXIT From e276a60b5d5a255917f8e08973ec2b80f59ce644 Mon Sep 17 00:00:00 2001 From: Aaron <12213433+surfine@users.noreply.github.com> Date: Mon, 23 Nov 2026 14:59:55 +0800 Subject: [PATCH 05/27] =?UTF-8?q?perf(=E7=AA=97=E5=8F=A3=E6=B5=8F=E8=A7=88?= =?UTF-8?q?):=20=E6=89=93=E5=BC=80=E6=97=B6=E5=90=88=E5=B9=B6=20refreshPan?= =?UTF-8?q?el=E3=80=81=E5=8F=B3=E9=94=AE=E8=8F=9C=E5=8D=95=E6=94=B9?= =?UTF-8?q?=E6=88=90=E5=8F=B3=E9=94=AE=E5=BD=93=E4=B8=8B=E6=89=8D=E5=BB=BA?= =?UTF-8?q?=EF=BC=88=E6=80=A7=E8=83=BD=E8=AE=A1=E5=88=92=201A=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 每个 App 的窗口探查结果回主线程后不再各自整面板刷新:目录先更新,刷新排到主队列已排着的结果之后做一次。 M5 上每次打开 refreshPanel 17 次 → 3 次。最终列表与逐个刷新的最后一次相同。 - 卡片/列表行拿右键菜单的闭包,右键时才由控制器按当前状态生成 NSMenu;原来每次刷新替每张卡建整份菜单(约 20 ms/次打开)。 M5 browser-open(6 轮快测)455 → 210 ms/s,worst 234 → 117 ms。 Co-Authored-By: Claude Opus 5.5 --- docs/perf-ledger.md | 2 +- .../WindowBrowser/WindowBrowserCardView.swift | 7 ++++--- .../WindowBrowserContentView.swift | 15 +++++++++---- .../WindowBrowserController.swift | 21 ++++++++++++++++++- .../WindowBrowserListRowView.swift | 7 ++++--- 5 files changed, 40 insertions(+), 12 deletions(-) diff --git a/docs/perf-ledger.md b/docs/perf-ledger.md index b32c9f75..12c1e350 100644 --- a/docs/perf-ledger.md +++ b/docs/perf-ledger.md @@ -8,7 +8,7 @@ - `scripts/release-gate.sh` 会打印候选包 build 号对应的最近一行(INFO)。 - 从 2026-11-23(1254aa1f)起多记两类 `present-fold`、`present-unfold`:呈现侧,Metal drawable 真正上屏的间隔,同一预算。只算盖板看得见、动画在动的帧;盖板静止等藏窗/恢复确认的那段是起跑延迟,不算卡顿(探针另印 `start delay`)。主线程(不带 present-)照旧是显示链接量的。 - Intel 真机用 `scripts/intel-floor.sh user@host`(编 x86_64 包、传过去、跑两遍 hitch 和静置能耗,各记一行)。 -- 2026-11-23 的 M5 browser-open 比 11-23 早先那两行高一倍(455–460 vs 196–226 ms/s):同一台机器,当时桌面上开着的 App 与窗口更多(refreshPanel 每次打开 17 次)。比较时只和同一天、同一桌面状态的基线比。 +- 2026-11-23 的 M5 browser-open 比 11-23 早先那两行高一倍(455–460 vs 196–226 ms/s):同一台机器,原因未查证,可能是当时桌面上开着的 App 与窗口不同(新尺下 refreshPanel 每次打开 17 次)。比较时只和同一天、同一桌面状态的基线比。 | 日期 | 版本 (build) 提交 | 机器 | 刷新率 | 对照预算 | 各类 ratio/worst | | --- | --- | --- | --- | --- | --- | diff --git a/prototype/WindowBrowser/WindowBrowserCardView.swift b/prototype/WindowBrowser/WindowBrowserCardView.swift index 77fe45c4..655a75ad 100644 --- a/prototype/WindowBrowser/WindowBrowserCardView.swift +++ b/prototype/WindowBrowser/WindowBrowserCardView.swift @@ -30,7 +30,8 @@ final class WindowBrowserCardView: NSView { private var mountedLiveView: NSView? /// 当前静态画面的像素尺寸:用来把画面区收成实际画面矩形(圆角落在画面上)。 private var imagePixelSize: CGSize? - private var providedMenu: NSMenu? + /// 右键菜单在右键当下才建(性能计划 1A):原来每次刷新都替每张卡建整份 NSMenu。 + private var providedMenu: (() -> NSMenu?)? private var statusIsWarning = false private(set) var cardSurface: WindowBrowserCardSurface = .solid /// 诊断:真正执行了内容配置的次数(未变化的刷新应保持为 0 增量)。 @@ -119,7 +120,7 @@ final class WindowBrowserCardView: NSView { selected: Bool, busy: Bool, params: WindowBrowserLayoutParams, - menu: NSMenu?) { + menu: (() -> NSMenu?)?) { let actionSignature = actions.map { "\($0.action.rawValue)\($0.isEnabled ? 1 : 0)" }.joined() + (record.isMinimized ? "m" : "") @@ -422,7 +423,7 @@ final class WindowBrowserCardView: NSView { delegate?.browserItem(self, contextMenu: key, event: event) } - override func menu(for event: NSEvent) -> NSMenu? { providedMenu } + override func menu(for event: NSEvent) -> NSMenu? { providedMenu?() } /// VoiceOver 的“按下”(VO-Space):与鼠标点击一样激活/展开该窗口。 override func accessibilityPerformPress() -> Bool { diff --git a/prototype/WindowBrowser/WindowBrowserContentView.swift b/prototype/WindowBrowser/WindowBrowserContentView.swift index 83b3f587..8e0fae8f 100644 --- a/prototype/WindowBrowser/WindowBrowserContentView.swift +++ b/prototype/WindowBrowser/WindowBrowserContentView.swift @@ -333,6 +333,13 @@ final class WindowBrowserContentView: NSView, NSSearchFieldDelegate, NSTextViewD contextMenuProvider = provider } + /// 卡片/列表行拿到的是「右键时再问控制器要菜单」的闭包,不是现成的 NSMenu。 + /// 菜单内容由控制器在右键当下按当前状态生成,和原来刷新时预先生成的逐项相同。 + private func lazyContextMenu(for key: WindowKey) -> (() -> NSMenu?)? { + guard contextMenuProvider != nil else { return nil } + return { [weak self] in self?.contextMenuProvider?(key) ?? nil } + } + /// 外观设置或系统辅助功能变化时局部刷新材质与层颜色,不改变窗口状态、 /// 不触发任何截图,也不重建数据。 func refreshMaterialAppearance() { @@ -613,7 +620,7 @@ final class WindowBrowserContentView: NSView, NSSearchFieldDelegate, NSTextViewD card.configure(record: record, actions: actions, status: status, selected: showsSelectionRing(for: record.key), busy: busyKeys.contains(record.key), - params: params, menu: contextMenuProvider?(record.key)) + params: params, menu: lazyContextMenu(for: record.key)) card.placeholderIcon = iconProvider.icon(for: record.key.application.pid) card.applyThumbnail(thumbnailImages[record.key], note: thumbnailNotes[record.key]) @@ -624,7 +631,7 @@ final class WindowBrowserContentView: NSView, NSSearchFieldDelegate, NSTextViewD busy: busyKeys.contains(record.key), params: params, icon: iconProvider.icon(for: record.key.application.pid), - menu: contextMenuProvider?(record.key)) + menu: lazyContextMenu(for: record.key)) } } } @@ -950,7 +957,7 @@ final class WindowBrowserContentView: NSView, NSSearchFieldDelegate, NSTextViewD selected: showsSelectionRing(for: record.key), busy: busyKeys.contains(record.key), params: params, - menu: contextMenuProvider?(record.key)) + menu: lazyContextMenu(for: record.key)) gridItem.card.placeholderIcon = iconProvider.icon(for: record.key.application.pid) gridItem.card.applyThumbnail(thumbnailImages[record.key], note: thumbnailNotes[record.key]) @@ -988,7 +995,7 @@ final class WindowBrowserContentView: NSView, NSSearchFieldDelegate, NSTextViewD busy: busyKeys.contains(record.key), params: params, icon: iconProvider.icon(for: record.key.application.pid), - menu: contextMenuProvider?(record.key)) + menu: lazyContextMenu(for: record.key)) return rowView } diff --git a/prototype/WindowBrowser/WindowBrowserController.swift b/prototype/WindowBrowser/WindowBrowserController.swift index 25b578ee..4088554f 100644 --- a/prototype/WindowBrowser/WindowBrowserController.swift +++ b/prototype/WindowBrowser/WindowBrowserController.swift @@ -1315,7 +1315,10 @@ final class WindowBrowserController: NSObject { currentAppInstance: catalog.identityAllocator.knownApplicationInstance(pid: pid)) if accepts && !activeDemand.execution.isCancelled { catalog.applyDiscovery(result, pid: pid) - refreshPanel() + // 性能计划 1A:每个 App 的探查结果各自回主线程,打开面板时十几个结果排在同一段主队列里, + // 原来每个都整个刷新一次(每次约 7 ms,M5)。目录先更新,刷新合并到这些结果之后做一次; + // 最终列表与逐个刷新的最后一次相同。 + scheduleCoalescedRefreshPanel() } else { wlog("window-browser: stale metadata dropped pid=\(pid) request=\(requestID.value)") } @@ -1463,8 +1466,24 @@ final class WindowBrowserController: NSObject { // MARK: 面板渲染 + /// 有一次合并刷新排在主队列里还没跑。期间任何一次直接的 refreshPanel() 都会清掉它(已经刷新到最新)。 + private var coalescedRefreshPending = false + + /// 把刷新排到主队列当前已排着的工作之后,期间再来的请求并进同一次。 + private func scheduleCoalescedRefreshPanel() { + guard !coalescedRefreshPending else { return } + coalescedRefreshPending = true + DispatchQueue.main.async { [weak self] in + MainActor.assumeIsolated { + guard let self, self.coalescedRefreshPending else { return } + self.refreshPanel() + } + } + } + private func refreshPanel() { dispatchPrecondition(condition: .onQueue(.main)) + coalescedRefreshPending = false guard running, !environmentSuspended, let session, let contentView else { return } refreshPanelCount += 1 let signpost = SystemLog.windowBrowserSignposter.beginInterval("refreshPanel", id: SystemLog.windowBrowserSignposter.makeSignpostID(), "n=\(self.refreshPanelCount)") diff --git a/prototype/WindowBrowser/WindowBrowserListRowView.swift b/prototype/WindowBrowser/WindowBrowserListRowView.swift index 9b39b923..b30be388 100644 --- a/prototype/WindowBrowser/WindowBrowserListRowView.swift +++ b/prototype/WindowBrowser/WindowBrowserListRowView.swift @@ -19,7 +19,8 @@ final class WindowBrowserListRowView: NSView { private var trackingAreaRef: NSTrackingArea? private var pressedInside = false private var configuredSignature: String? - private var providedMenu: NSMenu? + /// 右键菜单在右键当下才建(性能计划 1A):原来每次刷新都替每张卡建整份 NSMenu。 + private var providedMenu: (() -> NSMenu?)? private var statusIsWarning = false private(set) var cardSurface: WindowBrowserCardSurface = .solid /// 诊断:真正执行了内容配置的次数。 @@ -119,7 +120,7 @@ final class WindowBrowserListRowView: NSView { selected: Bool, busy: Bool, params: WindowBrowserLayoutParams, icon: NSImage?, - menu: NSMenu?) { + menu: (() -> NSMenu?)?) { let actionSignature = actions.map { "\($0.action.rawValue)\($0.isEnabled ? 1 : 0)" }.joined() @@ -268,7 +269,7 @@ final class WindowBrowserListRowView: NSView { delegate?.browserItem(self, contextMenu: key, event: event) } - override func menu(for event: NSEvent) -> NSMenu? { providedMenu } + override func menu(for event: NSEvent) -> NSMenu? { providedMenu?() } /// VoiceOver 的“按下”(VO-Space):与鼠标点击一样激活/展开该窗口。 override func accessibilityPerformPress() -> Bool { From 75acdfe79bbf07e11e4c91eae8169803c1726212 Mon Sep 17 00:00:00 2001 From: Aaron <12213433+surfine@users.noreply.github.com> Date: Mon, 23 Nov 2026 15:13:33 +0800 Subject: [PATCH 06/27] =?UTF-8?q?docs(=E6=80=A7=E8=83=BD):=20MacBook=20?= =?UTF-8?q?=E6=96=B0=E5=B0=BA=E5=9F=BA=E7=BA=BF=E4=B8=A4=E8=BD=AE=EF=BC=88?= =?UTF-8?q?da4b946c=EF=BC=8C=E5=87=8F=E5=B0=91=E5=8A=A8=E6=80=81=E6=95=88?= =?UTF-8?q?=E6=9E=9C=E5=BC=80=EF=BC=89=EF=BC=9B=E6=94=B6=E8=B5=B7=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E5=90=84=E6=AD=A5=E5=8A=A0=20signpost=20=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- docs/perf-ledger.md | 5 +++++ prototype/App/ShadeController.swift | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/perf-ledger.md b/docs/perf-ledger.md index 12c1e350..fe2874b3 100644 --- a/docs/perf-ledger.md +++ b/docs/perf-ledger.md @@ -8,6 +8,7 @@ - `scripts/release-gate.sh` 会打印候选包 build 号对应的最近一行(INFO)。 - 从 2026-11-23(1254aa1f)起多记两类 `present-fold`、`present-unfold`:呈现侧,Metal drawable 真正上屏的间隔,同一预算。只算盖板看得见、动画在动的帧;盖板静止等藏窗/恢复确认的那段是起跑延迟,不算卡顿(探针另印 `start delay`)。主线程(不带 present-)照旧是显示链接量的。 - Intel 真机用 `scripts/intel-floor.sh user@host`(编 x86_64 包、传过去、跑两遍 hitch 和静置能耗,各记一行)。 +- 2026-11-23 起的 MacBook10,1 行:那台机器开着「减少动态效果」(`com.apple.universalaccess reduceMotion = 1`),收起不播 Metal 卷帘、没有 present-* 两类;探针单窗口 fixture 第 1 轮之后都走最小化(focus handoff 判 stay-minimize)。和 11-22 那两行不是同一条路径,不能直接比。同一次的静置能耗:CPU 中位 0.07%、phys_footprint 29–31 MB。 - 2026-11-23 的 M5 browser-open 比 11-23 早先那两行高一倍(455–460 vs 196–226 ms/s):同一台机器,原因未查证,可能是当时桌面上开着的 App 与窗口不同(新尺下 refreshPanel 每次打开 17 次)。比较时只和同一天、同一桌面状态的基线比。 | 日期 | 版本 (build) 提交 | 机器 | 刷新率 | 对照预算 | 各类 ratio/worst | @@ -19,3 +20,7 @@ | 2026-11-23 | 1.0.22.1 (build 20261116.01) 05e2024f3 | Mac17,4 · Apple M5 · macOS 27.2.1 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show | fold 70.0/88; unfold 41.4/58; browser-open 226.4/133; browser-close 43.7/35; glance-show 24.9/36; glance-hide 0.0/17 | | 2026-11-23 | 1.0.22.1 (build 20261116.01) 1254aa1f4 | Mac17,4 · Apple M5 · macOS 27.2.1 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show、present-unfold | fold 54.0/60; unfold 45.4/59; browser-open 460.5/241; browser-close 43.5/50; glance-show 59.2/60; glance-hide 0.0/17; present-fold 0.0/17; present-unfold 12.1/33 | | 2026-11-23 | 1.0.22.1 (build 20261116.01) 1254aa1f4 | Mac17,4 · Apple M5 · macOS 27.2.1 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show | fold 56.2/74; unfold 40.8/54; browser-open 454.7/234; browser-close 45.6/50; glance-show 56.5/55; glance-hide 2.4/33; present-fold 0.0/17; present-unfold 4.1/33 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) edf691fdb | Mac17,4 · Apple M5 · macOS 27.2.1 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show | fold 49.8/64; unfold 40.9/67; browser-open 192.6/105; browser-close 58.9/50; glance-show 47.5/55; glance-hide 0.6/33; present-fold 0.0/17; present-unfold 3.3/33 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) edf691fdb | Mac17,4 · Apple M5 · macOS 27.2.1 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show、present-unfold | fold 60.5/67; unfold 40.1/67; browser-open 178.3/100; browser-close 45.6/38; glance-show 40.3/60; glance-hide 0.6/33; present-fold 0.0/17; present-unfold 8.1/33 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) da4b946c4 | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build · 减少动态效果开 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show、glance-hide | fold 514.3/382; unfold 597.6/292; browser-open 414.4/447; browser-close 21.3/47; glance-show 7.7/33; glance-hide 7.5/25 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) da4b946c4 | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build · 减少动态效果开 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show、glance-hide | fold 507.4/300; unfold 604.6/300; browser-open 412.5/412; browser-close 25.8/45; glance-show 11.5/33; glance-hide 6.8/24 | diff --git a/prototype/App/ShadeController.swift b/prototype/App/ShadeController.swift index 08c22fb6..cab0dd8a 100644 --- a/prototype/App/ShadeController.swift +++ b/prototype/App/ShadeController.swift @@ -374,7 +374,11 @@ extension AppDelegate { // 逐步打点(只记时间戳,慢的时候才拼成一行):VM 重负载下见过 install=9521ms、 // 已知分段却只有 ~1.5 s——差额落在哪一步,下一次日志直接写出来。 var installSteps: [(name: String, at: CFAbsoluteTime)] = [] - func installStep(_ name: String) { installSteps.append((name, CFAbsoluteTimeGetCurrent())) } + func installStep(_ name: String) { + installSteps.append((name, CFAbsoluteTimeGetCurrent())) + // 每一步也打一个 signpost 事件(fold 类目),Instruments 上不必等到超过 150 ms 才看得到。 + SystemLog.foldSignposter.emitEvent("install-step", "\(name, privacy: .public)") + } defer { let installMilliseconds = (CFAbsoluteTimeGetCurrent() - installStartedAt) * 1000 foldPhaseTotals["▸安装阶段合计", default: 0] += installMilliseconds / 1000 From 3d525c80382fe832a962ce7e53a60ea5ebaef5d8 Mon Sep 17 00:00:00 2001 From: Aaron <12213433+surfine@users.noreply.github.com> Date: Mon, 23 Nov 2026 15:13:42 +0800 Subject: [PATCH 07/27] =?UTF-8?q?feat(=E6=80=A7=E8=83=BD):=20intel-floor?= =?UTF-8?q?=20=E5=9C=A8=E6=9C=BA=E5=99=A8=E6=8F=8F=E8=BF=B0=E9=87=8C?= =?UTF-8?q?=E6=A0=87=E5=87=BA=E8=BF=9C=E7=AB=AF=E3=80=8C=E5=87=8F=E5=B0=91?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=95=88=E6=9E=9C=E3=80=8D=E5=BC=80=E7=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- scripts/intel-floor.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/intel-floor.sh b/scripts/intel-floor.sh index 2fcd78e5..b1906826 100755 --- a/scripts/intel-floor.sh +++ b/scripts/intel-floor.sh @@ -110,6 +110,8 @@ wait_load() { MACHINE=$(rsh 'echo "$(sysctl -n hw.model) · $(sysctl -n machdep.cpu.brand_string | sed "s/(R)//g; s/(TM)//g; s/ CPU.*//; s/ */ /g") · macOS $(sw_vers -productVersion)"') MACHINE="$MACHINE · x86_64 build" +# 「减少动态效果」开着时收起不播 Metal 卷帘(没有 present-* 两类),路径不同,记进机器描述里,比较时分开。 +[ "$(rsh 'defaults read com.apple.universalaccess reduceMotion 2>/dev/null' || true)" != 1 ] || MACHINE="$MACHINE · 减少动态效果开" OUT=.build/perf/intel-floor/$(date +%Y%m%d-%H%M%S) mkdir -p "$OUT" ledger_flag=(); [ "$LEDGER" = 1 ] || ledger_flag=(--no-ledger) From c0fc153fb4ae8f41dd70029c57f2b9698b36989d Mon Sep 17 00:00:00 2001 From: Aaron <12213433+surfine@users.noreply.github.com> Date: Mon, 23 Nov 2026 15:22:43 +0800 Subject: [PATCH 08/27] =?UTF-8?q?docs(=E6=80=A7=E8=83=BD):=201A=20?= =?UTF-8?q?=E4=B9=8B=E5=90=8E=20MacBook=20=E4=B8=A4=E8=BD=AE=E4=B8=8E=20M5?= =?UTF-8?q?=20=E4=B8=A4=E8=BD=AE=E8=AE=B0=E5=B8=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- docs/perf-ledger.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/perf-ledger.md b/docs/perf-ledger.md index fe2874b3..79f33f48 100644 --- a/docs/perf-ledger.md +++ b/docs/perf-ledger.md @@ -24,3 +24,5 @@ | 2026-11-23 | 1.0.22.1 (build 20261116.01) edf691fdb | Mac17,4 · Apple M5 · macOS 27.2.1 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show、present-unfold | fold 60.5/67; unfold 40.1/67; browser-open 178.3/100; browser-close 45.6/38; glance-show 40.3/60; glance-hide 0.6/33; present-fold 0.0/17; present-unfold 8.1/33 | | 2026-11-23 | 1.0.22.1 (build 20261116.01) da4b946c4 | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build · 减少动态效果开 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show、glance-hide | fold 514.3/382; unfold 597.6/292; browser-open 414.4/447; browser-close 21.3/47; glance-show 7.7/33; glance-hide 7.5/25 | | 2026-11-23 | 1.0.22.1 (build 20261116.01) da4b946c4 | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build · 减少动态效果开 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show、glance-hide | fold 507.4/300; unfold 604.6/300; browser-open 412.5/412; browser-close 25.8/45; glance-show 11.5/33; glance-hide 6.8/24 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) 12fe1220b | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build · 减少动态效果开 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show、glance-hide | fold 505.8/296; unfold 592.8/292; browser-open 349.9/429; browser-close 34.7/47; glance-show 5.1/25; glance-hide 5.7/25 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) 12fe1220b | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build · 减少动态效果开 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show、glance-hide | fold 519.0/292; unfold 603.3/300; browser-open 355.6/413; browser-close 32.0/46; glance-show 5.4/25; glance-hide 5.4/24 | From bb8e5f4b7a3e9ce675608b0ef2a0bca406c0edb5 Mon Sep 17 00:00:00 2001 From: Aaron <12213433+surfine@users.noreply.github.com> Date: Mon, 23 Nov 2026 15:51:22 +0800 Subject: [PATCH 09/27] =?UTF-8?q?perf(=E6=94=B6=E8=B5=B7):=20=E3=80=8C?= =?UTF-8?q?=E8=A2=AB=E5=88=AB=E4=BA=BA=E6=8F=AD=E5=BC=80=E3=80=8D=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E7=9A=84=20AX=20=E6=B3=A8=E5=86=8C=E7=A7=BB=E5=88=B0?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E4=B8=B2=E8=A1=8C=E9=98=9F=E5=88=97=EF=BC=88?= =?UTF-8?q?=E6=80=A7=E8=83=BD=E8=AE=A1=E5=88=92=201B=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AXObserverAddNotification 是发给目标 App 的同步 IPC,目标正忙着最小化/隐藏时要等它回话: 2017 MacBook 的 sample 里每次收起约 96 ms 都压在主线程上(M5 上不到 1 ms)。 观察者、路由和主线程 runloop source 照旧在主线程建好,只把三个注册放到后台串行队列; 注册生效的时刻取决于目标 App 何时处理这条消息,不变。三个都失败时在主线程撤掉路由与 source。 新增 --reveal-observer 探针:收起后从外面揭开,核对注册成功、窗口回来; 只计数的 revealObserverRegistrations/revealNotificationUnfolds/foldAXNotificationsReceived 供它读。 Co-Authored-By: Claude Opus 5.5 --- prototype/App/FoldTransaction.swift | 59 ++++++++++++++++++---- prototype/App/GlanceProbe.swift | 7 ++- prototype/App/RevealObserverProbe.swift | 64 ++++++++++++++++++++++++ prototype/App/WS2FoldCallbackGuard.swift | 1 + prototype/WindowShade.swift | 7 +++ 5 files changed, 126 insertions(+), 12 deletions(-) create mode 100644 prototype/App/RevealObserverProbe.swift diff --git a/prototype/App/FoldTransaction.swift b/prototype/App/FoldTransaction.swift index 5bb86028..8a57dea1 100644 --- a/prototype/App/FoldTransaction.swift +++ b/prototype/App/FoldTransaction.swift @@ -1148,21 +1148,35 @@ extension AppDelegate { let serial = foldObserverSerial let route = WS2FoldObserverRoute(window: id, pid: pid, transaction: transaction) foldObserverRoutes[serial] = route - let app = AXUIElementCreateApplication(pid) - let refcon = UnsafeMutableRawPointer(bitPattern: serial) - let results = [ - AXObserverAddNotification(obs, app, kAXApplicationShownNotification as CFString, refcon), - AXObserverAddNotification(obs, win, kAXWindowDeminiaturizedNotification as CFString, refcon), - AXObserverAddNotification(obs, win, kAXUIElementDestroyedNotification as CFString, refcon) - ] - guard results.contains(.success), shaded[id]?.foldTransactionID == transaction else { - foldObserverRoutes.removeValue(forKey: serial) - return nil - } + let registration = RevealObserverRegistration( + observer: obs, app: AXUIElementCreateApplication(pid), window: win, serial: serial) + // 回调照旧走主线程的 runloop source;先挂上,注册一生效就能收到。 CFRunLoopAddSource(CFRunLoopGetMain(), AXObserverGetRunLoopSource(obs), .defaultMode) + // 性能计划 1B:AXObserverAddNotification 是发给目标 App 的同步 IPC,目标正忙着最小化/隐藏时 + // 要等它回话(2017 MacBook 上每次收起约 96 ms,全压在主线程)。注册何时生效取决于目标 App + // 何时处理这条消息,放到后台串行队列发出,生效时刻不变,主线程不再陪等。 + // 三个都失败(原来返回 nil 的那种)就在主线程撤掉路由和 source,和原来一样不留观察者。 + Self.revealObserverQueue.async { [weak self] in + let succeeded = registration.register() + DispatchQueue.main.async { [weak self] in + guard let self else { return } + guard !succeeded else { + self.revealObserverRegistrations += 1 + return + } + self.foldObserverRoutes.removeValue(forKey: registration.serial) + CFRunLoopRemoveSource(CFRunLoopGetMain(), AXObserverGetRunLoopSource(registration.observer), .defaultMode) + if let current = self.shaded[id]?.observer, CFEqual(current, registration.observer) { + self.shaded[id]?.observer = nil + } + } + } return obs } + /// 收起时注册「被别人揭开」通知的后台串行队列:顺序和原来在主线程上逐个注册一致。 + static let revealObserverQueue = DispatchQueue(label: "WindowShade.fold-reveal-observer", qos: .userInitiated) + func removeObserver(_ state: ShadeState) { // Withdraw routes before removing a source. Old queued notifications remain harmless. for (serial, route) in foldObserverRoutes where route.transaction == state.foldTransactionID { @@ -1196,6 +1210,7 @@ extension AppDelegate { revealFocusShelfMemberFromOutside(id: id, state: state, reason: "deminiaturized") return } + revealNotificationUnfolds += 1 unshade(id) } } else if notification == (kAXApplicationShownNotification as String) { @@ -1214,6 +1229,7 @@ extension AppDelegate { revealFocusShelfMemberFromOutside(id: id, state: state, reason: "app-shown") return } + revealNotificationUnfolds += 1 unshade(id) } } else { @@ -1382,3 +1398,24 @@ extension AppDelegate { DispatchQueue.main.asyncAfter(deadline: .now() + 0.3, execute: work) } } + +/// 收起时要在后台队列上发出的三个 AX 通知注册。观察者与元素都是指向系统/别的进程对象的不可变引用, +/// AXObserverAddNotification 可以在任意线程发起(回调仍由主线程 runloop 上的 source 投递); +/// 这里只把引用带过去,注册完不再碰。 +private struct RevealObserverRegistration: @unchecked Sendable { + let observer: AXObserver + let app: AXUIElement + let window: AXUIElement + let serial: UInt + + /// 三个里至少一个成功就算注册上了(和原来的判断相同)。 + func register() -> Bool { + let refcon = UnsafeMutableRawPointer(bitPattern: serial) + let results = [ + AXObserverAddNotification(observer, app, kAXApplicationShownNotification as CFString, refcon), + AXObserverAddNotification(observer, window, kAXWindowDeminiaturizedNotification as CFString, refcon), + AXObserverAddNotification(observer, window, kAXUIElementDestroyedNotification as CFString, refcon) + ] + return results.contains(.success) + } +} diff --git a/prototype/App/GlanceProbe.swift b/prototype/App/GlanceProbe.swift index 836dc32e..251240bd 100644 --- a/prototype/App/GlanceProbe.swift +++ b/prototype/App/GlanceProbe.swift @@ -71,7 +71,7 @@ final class GlanceProbe { // 折叠计时只打一扇:两扇时整 App 隐藏路径和另一扇抢焦点,会在第二三轮踩到 SIGTRAP。 let foldTiming = ["--fold-timing", "--orphan", "--soak", "--menubar-owner", "--focus-steal", "--switch-cpu", "--idle-first-op", "--second-display", "--capsule-color", "--close-quit", "--hitch", "--dock-autohide-frames", "--reduce-transparency", "--overlay-input", "--display-hotplug", "--fold-desktops", "--second-display-desktops", - "--permission-card"] + "--permission-card", "--reveal-observer"] .contains { CommandLine.arguments.contains($0) } var fixtureArguments: [String] = [] // --hold:多数场景只要一扇窗;pins 要两扇(默认的参考窗加另一扇)。 @@ -170,6 +170,11 @@ final class GlanceProbe { finish(nil) return } + if CommandLine.arguments.contains("--reveal-observer") { + try await revealObserver(element: element, pid: process.processIdentifier) + finish(nil) + return + } if CommandLine.arguments.contains("--close-quit") { try await closeQuit(element: element, pid: process.processIdentifier) finish(nil) diff --git a/prototype/App/RevealObserverProbe.swift b/prototype/App/RevealObserverProbe.swift new file mode 100644 index 00000000..0143b6a3 --- /dev/null +++ b/prototype/App/RevealObserverProbe.swift @@ -0,0 +1,64 @@ +import Cocoa + +extension GlanceProbe { + /// `--reveal-observer`(性能计划 1B 的回归探针):收起临时窗口后,从外面把它揭开 + /// (整 App 隐藏的就 unhide 这个 App,最小化的就用 AX 取消最小化,和点程序坞一样), + /// WindowShade 要靠收起时注册的「被别人揭开」通知自己展开:卷帘条撤掉、记录清掉、真窗口回到屏上。 + /// 注册改在后台队列发出之后,这条路一旦断了,窗口会回来、卷帘条却还挂着。跑 3 轮,每轮都要过。 + func revealObserver(element: AXUIElement, pid: pid_t) async throws { + var passed = 0, skipped = 0 + for round in 1...3 { + let registrationsBefore = owner.revealObserverRegistrations + owner.shade(element, id) + try await wait("reveal-observer fold \(round)", timeout: 10) { + self.owner.shaded[self.id]?.overlay.map { $0.isVisible && $0.alphaValue > 0.5 } == true + && self.owner.duoController.windowEffects.activeCount == 0 + } + guard let state = owner.shaded[id] else { throw EffectError.unavailable("reveal-observer: not shaded after fold \(round)") } + // 收起后 1 秒内的揭开通知按设计忽略(revealGrace),等过这段再从外面揭开。 + try await Task.sleep(for: .milliseconds(1500), clock: .suspending) + // 1. 注册:后台发出的三个 AX 通知注册要有一次成功,观察者要挂在这次收起的状态上。 + let registered = owner.revealObserverRegistrations > registrationsBefore && owner.shaded[id]?.observer != nil + let hide = state.hide + let notifiedBefore = owner.revealNotificationUnfolds + let receivedBefore = owner.foldAXNotificationsReceived + // 2. 从外面揭开,窗口要回来、卷帘条要撤掉(通知或对账巡检,哪条先到都行)。 + switch hide { + case .hidden: + NSRunningApplication(processIdentifier: pid)?.unhide() + case .minimized: + AXUIElementSetAttributeValue(state.element, kAXMinimizedAttribute as CFString, kCFBooleanFalse) + default: + print("INFO reveal-observer round \(round): hide=\(hide.rawValue) has no outside reveal; unfolding normally") + _ = owner.unshade(id) + skipped += 1 + try await wait("reveal-observer restore \(round)", timeout: 8) { self.onscreen(self.id) && self.owner.shaded[self.id] == nil } + if !registered { print("FAIL reveal-observer round \(round): hide=\(hide.rawValue) the reveal observer was not registered") } + continue + } + var unfolded = true + do { + try await wait("reveal-observer auto-unfold \(round)", timeout: 6) { + self.owner.shaded[self.id] == nil && self.onscreen(self.id) + } + } catch { + unfolded = false + if owner.shaded[id] != nil { _ = owner.unshade(id) } + try await wait("reveal-observer recover \(round)", timeout: 8) { self.onscreen(self.id) && self.owner.shaded[self.id] == nil } + } + try await Task.sleep(for: .milliseconds(300), clock: .suspending) + let received = owner.foldAXNotificationsReceived.filter { $0.value > (receivedBefore[$0.key] ?? 0) } + .map { "\($0.key)×\($0.value - (receivedBefore[$0.key] ?? 0))" }.sorted().joined(separator: " ") + let path = owner.revealNotificationUnfolds > notifiedBefore ? "reveal notification" : "reconcile" + print("INFO reveal-observer round \(round): hide=\(hide.rawValue) registered=\(registered) unfolded=\(unfolded) by=\(unfolded ? path : "-") AX notifications received: \(received.isEmpty ? "none" : received)") + if registered && unfolded { + passed += 1 + print("PASS reveal-observer round \(round): observer registered off the main thread, outside reveal unfolded the window") + } else { + print("FAIL reveal-observer round \(round): registered=\(registered) unfolded=\(unfolded) (\(hitchFoldState()))") + } + try await Task.sleep(for: .milliseconds(1500), clock: .suspending) + } + print("INFO reveal-observer: \(passed) passed, \(skipped) rounds without an outside reveal path") + } +} diff --git a/prototype/App/WS2FoldCallbackGuard.swift b/prototype/App/WS2FoldCallbackGuard.swift index 68b063d4..7e51ba32 100644 --- a/prototype/App/WS2FoldCallbackGuard.swift +++ b/prototype/App/WS2FoldCallbackGuard.swift @@ -108,6 +108,7 @@ extension AppDelegate { /// AX observers are installed on CFRunLoopGetMain. The C callback verifies that /// assumption; only Sendable route/stamp/string values cross the queued boundary. func receiveFoldAXNotification(routeID: UInt, notification: String) { + foldAXNotificationsReceived[notification, default: 0] += 1 guard let route = foldObserverRoutes[routeID], let state = shaded[route.window], state.foldTransactionID == route.transaction, state.pid == route.pid else { return } let stamp = foldCallbackStamp(id: route.window, state: state) diff --git a/prototype/WindowShade.swift b/prototype/WindowShade.swift index 6fdb3a1c..352084ef 100644 --- a/prototype/WindowShade.swift +++ b/prototype/WindowShade.swift @@ -237,6 +237,13 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate { var foldWaiters: [CGWindowID: [UUID: (Bool) -> Void]] = [:] var foldWaiterTransactions: [UUID: UUID] = [:] var foldObserverSerial: UInt = 0 + /// 「被别人揭开」通知(取消最小化/App 重新显示)直接触发展开的次数。只计数,--reveal-observer 探针读它, + /// 用来分清是通知这条路展开的,还是对账巡检兜底展开的。 + var revealNotificationUnfolds = 0 + /// 收起时注册的 AX 通知实际送到了几次(按通知名)。只计数,--reveal-observer 探针读它。 + var foldAXNotificationsReceived: [String: Int] = [:] + /// 「被别人揭开」通知注册成功的次数(三个里至少一个成功)。只计数,--reveal-observer 探针读它。 + var revealObserverRegistrations = 0 var foldObserverRoutes: [UInt: WS2FoldObserverRoute] = [:] var foldPresentationID = UUID() var foldEvidence = WS2FoldEvidence() From 8fc7b966b5afe8e94f8c3d56a01c8564e2479473 Mon Sep 17 00:00:00 2001 From: Aaron <12213433+surfine@users.noreply.github.com> Date: Mon, 23 Nov 2026 16:12:39 +0800 Subject: [PATCH 10/27] =?UTF-8?q?perf(=E6=94=B6=E8=B5=B7):=20=E8=97=8F?= =?UTF-8?q?=E6=B2=A1=E8=97=8F=E4=BD=8F=E7=9A=84=E9=AA=8C=E8=AF=81=E6=94=B9?= =?UTF-8?q?=E5=9C=A8=E5=90=8E=E5=8F=B0=E8=AF=BB=20AX=E3=80=81=E5=9B=9E?= =?UTF-8?q?=E4=B8=BB=E7=BA=BF=E7=A8=8B=E5=88=A4=E5=AE=9A=EF=BC=88=E6=80=A7?= =?UTF-8?q?=E8=83=BD=E8=AE=A1=E5=88=92=201B=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2017 MacBook 的 sample:收起验证每次约 74 ms 卡在 windowID(of:)——发给正在最小化的目标 App 的同步 IPC。 FoldVerifier 的读数改成回调(同步 init 保留,包一层当场回调,旧用例逐字不变); observeFoldHide 拆出 readFoldHideAX:按原顺序只读 AX、前一项不对即止,可在后台跑; offscreen/cornerParked/hidden/minimized 四种在后台读、回主线程按原逻辑判定, 不读 AX 的与走私有 SkyLight 的照旧在主线程当场判。读数什么时候出来、判定就什么时候做,时序不变。 新增 tests/run-fold-verifier-tests.sh(15 项):延后读数与同步判定一致、读数在途时过期不出结果、补救后的迟到观察顺序。 Co-Authored-By: Claude Opus 5.5 --- prototype/App/FoldTransaction.swift | 12 +-- prototype/App/WS2FoldCallbackGuard.swift | 76 +++++++++++++-- prototype/Core/FoldVerifier.swift | 52 +++++++--- tests/FoldVerifierTests.swift | 115 +++++++++++++++++++++++ tests/run-fold-verifier-tests.sh | 8 ++ 5 files changed, 234 insertions(+), 29 deletions(-) create mode 100644 tests/FoldVerifierTests.swift create mode 100755 tests/run-fold-verifier-tests.sh diff --git a/prototype/App/FoldTransaction.swift b/prototype/App/FoldTransaction.swift index 8a57dea1..3a68ea64 100644 --- a/prototype/App/FoldTransaction.swift +++ b/prototype/App/FoldTransaction.swift @@ -120,9 +120,9 @@ extension AppDelegate { FoldVerifier( schedule: { delay, action in DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: action) }, isCurrent: { [weak self] in self?.foldCallbackIsCurrent(expected, maximumAge: maxAge) == true }, - observation: { [weak self] in - guard let self, self.foldCallbackIsCurrent(expected, maximumAge: maxAge), let state = self.shaded[id] else { return .unknown } - return self.observeFoldHide(state.hide, win: state.element, pid: state.pid, id: id) + asyncObservation: { [weak self] done in + guard let self, self.foldCallbackIsCurrent(expected, maximumAge: maxAge), let state = self.shaded[id] else { done(.unknown); return } + self.observeFoldHideOffMain(state.hide, win: state.element, pid: state.pid, id: id, completion: done) }, salvage: { [weak self] in guard let self, self.foldCallbackIsCurrent(expected, maximumAge: maxAge), let state = self.shaded[id], @@ -135,9 +135,9 @@ extension AppDelegate { setAXMinimized(state.element, true) return true }, - salvagedObservation: { [weak self] in - guard let self, self.foldCallbackIsCurrent(expected, maximumAge: maxAge), let state = self.shaded[id] else { return .unknown } - return self.observeFoldHide(.minimized, win: state.element, pid: state.pid, id: id) + asyncSalvagedObservation: { [weak self] done in + guard let self, self.foldCallbackIsCurrent(expected, maximumAge: maxAge), let state = self.shaded[id] else { done(.unknown); return } + self.observeFoldHideOffMain(.minimized, win: state.element, pid: state.pid, id: id, completion: done) }, lateObservationWindow: late, onExpired: { [weak self] in diff --git a/prototype/App/WS2FoldCallbackGuard.swift b/prototype/App/WS2FoldCallbackGuard.swift index 7e51ba32..4ff7b8cc 100644 --- a/prototype/App/WS2FoldCallbackGuard.swift +++ b/prototype/App/WS2FoldCallbackGuard.swift @@ -37,8 +37,52 @@ extension AppDelegate { return expected.sameFold(as: foldCallbackStamp(id: expected.window, state: state)) } + /// 后台读 AX、回主线程判定(性能计划 1B):读目标 App 的 AX 属性要等它回话,正在最小化/隐藏的 App + /// 常让这一读等几十毫秒(2017 MacBook 上每次收起约 74 ms)。读的内容、判定逻辑与同步版逐字相同; + /// 不读 AX 的几种(自己的窗、Quick Look、无)和走私有 SkyLight 的两种照旧在主线程当场判。 + func observeFoldHideOffMain(_ hide: HideMethod, win: AXUIElement, pid: pid_t, id: CGWindowID, + completion: @escaping (FoldVerifier.Observation) -> Void) { + switch hide { + case .offscreen, .cornerParked, .hidden, .minimized: + let callback = MainQueueObservationCallback(call: completion) + Self.foldHideReadQueue.async { [weak self] in + let reading = Self.readFoldHideAX(hide, win: win, pid: pid, id: id) + DispatchQueue.main.async { [weak self] in + guard let self else { callback.call(.unknown); return } + callback.call(self.observeFoldHide(hide, win: win, pid: pid, id: id, reading: reading)) + } + } + default: + completion(observeFoldHide(hide, win: win, pid: pid, id: id)) + } + } + + static let foldHideReadQueue = DispatchQueue(label: "WindowShade.fold-hide-read", qos: .userInitiated) + + /// 判定收起是否藏住要读的那几项 AX:按同步版的顺序读,前一项不对就不再往下读(窗口号不对、pid 不对即止)。 + nonisolated static func readFoldHideAX(_ hide: HideMethod, win: AXUIElement, pid: pid_t, + id: CGWindowID) -> FoldHideAXReading { + var reading = FoldHideAXReading() + guard windowID(of: win) == id else { return reading } + reading.windowMatches = true + var actualPID: pid_t = 0 + guard AXUIElementGetPid(win, &actualPID) == .success, actualPID == pid else { return reading } + reading.pidMatches = true + switch hide { + case .offscreen, .cornerParked: + reading.position = axPosition(win) + if reading.position != nil { reading.size = axSize(win) } + case .minimized: + reading.minimized = axObservedBoolAttribute(win, kAXMinimizedAttribute as String) + if reading.minimized == false { reading.size = axSize(win) } + default: + break + } + return reading + } + func observeFoldHide(_ hide: HideMethod, win: AXUIElement, pid: pid_t, - id: CGWindowID) -> FoldVerifier.Observation { + id: CGWindowID, reading: FoldHideAXReading? = nil) -> FoldVerifier.Observation { guard MainActor.assumeIsolated({ AuthorizationService.shared.lockState() == .unlocked }) else { return .unknown } if hide == .ownWindowOrderedOut { guard pid == getpid(), let local = ownWindow(id: id) else { return .unknown } @@ -51,19 +95,19 @@ extension AppDelegate { else { return .unknown } return list.isEmpty ? .hidden : .unknown } - guard hide != .none, let app = NSRunningApplication(processIdentifier: pid), !app.isTerminated, - windowID(of: win) == id else { return .unknown } - var actualPID: pid_t = 0 - guard AXUIElementGetPid(win, &actualPID) == .success, actualPID == pid else { return .unknown } + guard hide != .none, let app = NSRunningApplication(processIdentifier: pid), !app.isTerminated + else { return .unknown } + let ax = reading ?? Self.readFoldHideAX(hide, win: win, pid: pid, id: id) + guard ax.windowMatches, ax.pidMatches else { return .unknown } switch hide { case .offscreen: - guard let pos = axPosition(win), let size = axSize(win), + guard let pos = ax.position, let size = ax.size, pos.x.isFinite, pos.y.isFinite, size.width.isFinite, size.height.isFinite, size.width > 0, size.height > 0 else { return .unknown } return windowIsVisible(pos: pos, size: size) ? .visible : .hidden case .cornerParked: // 角落停放故意留 1 像素,1×1 的相交不算看得见。 - guard let pos = axPosition(win), let size = axSize(win), + guard let pos = ax.position, let size = ax.size, pos.x.isFinite, pos.y.isFinite, size.width.isFinite, size.height.isFinite, size.width > 0, size.height > 0 else { return .unknown } return windowIsVisible(pos: pos, size: size, @@ -74,10 +118,10 @@ extension AppDelegate { return privateOffscreenObservation(id: id, win: win, fallbackSize: axSize(win) ?? .zero) case .hidden: return app.isHidden ? .hidden : .visible case .minimized: - guard let value = axObservedBoolAttribute(win, kAXMinimizedAttribute as String) else { return .unknown } + guard let value = ax.minimized else { return .unknown } if value { return .hidden } // 台前调度把“最小化”做成侧条卡片,AXMinimized 不变(规格 R19)。台前调度关着时这一支恒为 visible。 - if let size = axSize(win), windowParkedInStageStrip(id: id, axSize: size) { return .hidden } + if let size = ax.size, windowParkedInStageStrip(id: id, axSize: size) { return .hidden } return .visible case .privateAlpha: guard let alpha = PrivateSLSWindowMover.shared.windowAlpha(id: id), @@ -125,3 +169,17 @@ func axObservedBoolAttribute(_ win: AXUIElement, _ attribute: String) -> Bool? { guard AXUIElementCopyAttributeValue(win, attribute as CFString, &raw) == .success else { return nil } return ws2ObservedBoolean(raw) } + +/// observeFoldHide 要的 AX 读数。全是值,读完可以从后台线程交回主线程。 +struct FoldHideAXReading: Sendable { + var windowMatches = false + var pidMatches = false + var position: CGPoint? + var size: CGSize? + var minimized: Bool? +} + +/// 验证链的回调:在主线程造好,经后台读数队列带过去,只在回到主队列后调用一次,从不在别的线程调用。 +private struct MainQueueObservationCallback: @unchecked Sendable { + let call: (FoldVerifier.Observation) -> Void +} diff --git a/prototype/Core/FoldVerifier.swift b/prototype/Core/FoldVerifier.swift index 549dbfc6..6069af24 100644 --- a/prototype/Core/FoldVerifier.swift +++ b/prototype/Core/FoldVerifier.swift @@ -4,11 +4,15 @@ import Foundation final class FoldVerifier { enum Observation: Equatable, Sendable { case hidden, visible, unknown } typealias Schedule = (TimeInterval, @escaping () -> Void) -> Void + /// 一次读数:读完调用一次回调(可以当场调,也可以读完别处的 AX 再回到调度所在的线程调)。 + /// 性能计划 1B:读目标 App 的 AX 属性要等它回话,正在最小化/隐藏的 App 常常让这一读等上几十毫秒; + /// 生产路径在后台读、回主线程交结果,主线程不陪等。读数什么时候出来,判定就什么时候做,顺序不变。 + typealias AsyncObservation = (@escaping (Observation) -> Void) -> Void private let schedule: Schedule private let isCurrent: () -> Bool - private let observation: () -> Observation + private let observation: AsyncObservation private let salvage: () -> Bool - private let salvagedObservation: () -> Observation + private let salvagedObservation: AsyncObservation private let quickObservation: (() -> Observation)? private let result: (Observation) -> Void private let lateObservationWindow: TimeInterval @@ -78,9 +82,24 @@ final class FoldVerifier { } } + /// 同步读数:当场读、当场回调。行为与改成回调之前逐字相同。 + convenience init(schedule: @escaping Schedule, isCurrent: @escaping () -> Bool, + observation: @escaping () -> Observation, salvage: @escaping () -> Bool, + salvagedObservation: @escaping () -> Observation, + quickObservation: (() -> Observation)? = nil, + lateObservationWindow: TimeInterval = 0, + onExpired: (() -> Void)? = nil, + result: @escaping (Observation) -> Void) { + self.init(schedule: schedule, isCurrent: isCurrent, + asyncObservation: { done in done(observation()) }, salvage: salvage, + asyncSalvagedObservation: { done in done(salvagedObservation()) }, + quickObservation: quickObservation, lateObservationWindow: lateObservationWindow, + onExpired: onExpired, result: result) + } + init(schedule: @escaping Schedule, isCurrent: @escaping () -> Bool, - observation: @escaping () -> Observation, salvage: @escaping () -> Bool, - salvagedObservation: @escaping () -> Observation, + asyncObservation observation: @escaping AsyncObservation, salvage: @escaping () -> Bool, + asyncSalvagedObservation salvagedObservation: @escaping AsyncObservation, quickObservation: (() -> Observation)? = nil, lateObservationWindow: TimeInterval = 0, onExpired: (() -> Void)? = nil, @@ -128,7 +147,10 @@ final class FoldVerifier { private func check(attempt: Int) { guard live() else { return } - let seen = observation() + observation { seen in self.checked(attempt: attempt, seen: seen) } + } + + private func checked(attempt: Int, seen: Observation) { guard live() else { return } if seen == .hidden { finish(.hidden) } else if attempt == 1 { @@ -142,10 +164,11 @@ final class FoldVerifier { guard attempted else { finish(.visible); return } schedule(0.35) { guard self.live() else { return } - let seen = self.salvagedObservation() - guard self.live() else { return } - if seen == .hidden || self.lateObservationWindow <= 0 { self.finish(seen); return } - self.observeLate(remaining: self.lateObservationWindow) + self.salvagedObservation { seen in + guard self.live() else { return } + if seen == .hidden || self.lateObservationWindow <= 0 { self.finish(seen); return } + self.observeLate(remaining: self.lateObservationWindow) + } } } } @@ -155,11 +178,12 @@ final class FoldVerifier { let step = min(Self.lateObservationInterval, remaining) schedule(step) { guard self.live() else { return } - let seen = self.salvagedObservation() - guard self.live() else { return } - let left = remaining - step - if seen == .hidden || left <= 0.001 { self.finish(seen); return } - self.observeLate(remaining: left) + self.salvagedObservation { seen in + guard self.live() else { return } + let left = remaining - step + if seen == .hidden || left <= 0.001 { self.finish(seen); return } + self.observeLate(remaining: left) + } } } diff --git a/tests/FoldVerifierTests.swift b/tests/FoldVerifierTests.swift new file mode 100644 index 00000000..a69b6393 --- /dev/null +++ b/tests/FoldVerifierTests.swift @@ -0,0 +1,115 @@ +// FoldVerifier 的读数改成回调之后(性能计划 1B):生产路径在后台读 AX、回到主线程才交结果。 +// 这里钉住三件事:读数延后到来时,判定与当场读完全相同;读数到来时验证链已过期,不出结果、只交给 onExpired; +// 补救之后的延后读数照样按 0.35 s/迟到观察的顺序走。DuoCoreTests 里同步版的用例在门禁之外(Metal), +// 所以这一组单独成脚本进 L1。 +import Foundation + +@main +@MainActor +struct FoldVerifierTests { + final class Clock { + var time = 0.0 + var tasks: [(Double, () -> Void)] = [] + func schedule(_ delay: Double, _ action: @escaping () -> Void) { tasks.append((time + delay, action)) } + func advance(_ delta: Double) { + let end = time + delta + while let next = tasks.enumerated().min(by: { $0.element.0 < $1.element.0 }), next.element.0 <= end { + tasks.remove(at: next.offset) + time = next.element.0 + next.element.1() + } + time = end + } + } + typealias V = FoldVerifier + static var failures = 0 + static func expect(_ ok: Bool, _ name: String) { + print(ok ? "ok \(name)" : "FAIL \(name)") + if !ok { failures += 1 } + } + + /// 读数要过 `lag` 秒才回来(模拟后台读 AX 再回主线程)。lag = nil 表示当场同步回调。 + final class Scenario { + let clock = Clock() + var fresh = true + var reading: V.Observation + var salvaged: V.Observation + var reads = 0, salvages = 0, expired = 0 + var results: [V.Observation] = [] + var resultTimes: [Double] = [] + let lag: Double? + var late: Double = 0 + init(reading: V.Observation, salvaged: V.Observation, lag: Double?, late: Double = 0) { + self.reading = reading; self.salvaged = salvaged; self.lag = lag; self.late = late + } + func deliver(_ value: @escaping () -> V.Observation, _ done: @escaping (V.Observation) -> Void) { + if let lag { clock.schedule(lag) { done(value()) } } else { done(value()) } + } + lazy var verifier: V = { + if lag == nil { + return V(schedule: clock.schedule, isCurrent: { [unowned self] in fresh }, + observation: { [unowned self] in reads += 1; return reading }, + salvage: { [unowned self] in salvages += 1; return true }, + salvagedObservation: { [unowned self] in reads += 1; return salvaged }, + lateObservationWindow: late, + onExpired: { [unowned self] in expired += 1 }, + result: { [unowned self] in results.append($0); resultTimes.append(clock.time) }) + } + return V(schedule: clock.schedule, isCurrent: { [unowned self] in fresh }, + asyncObservation: { [unowned self] done in reads += 1; deliver({ self.reading }, done) }, + salvage: { [unowned self] in salvages += 1; return true }, + asyncSalvagedObservation: { [unowned self] done in reads += 1; deliver({ self.salvaged }, done) }, + lateObservationWindow: late, + onExpired: { [unowned self] in expired += 1 }, + result: { [unowned self] in results.append($0); resultTimes.append(clock.time) }) + }() + } + + static func main() { + // 1. 每种读数组合:延后 40 ms 回来,结果与同步完全相同,只是晚 40 ms/每次读。 + let cases: [(V.Observation, V.Observation)] = [(.hidden, .hidden), (.visible, .hidden), (.visible, .visible), (.unknown, .hidden), (.visible, .unknown)] + for (reading, salvaged) in cases { + let sync = Scenario(reading: reading, salvaged: salvaged, lag: nil) + sync.verifier.start(); sync.clock.advance(5) + let async = Scenario(reading: reading, salvaged: salvaged, lag: 0.04) + async.verifier.start(); async.clock.advance(5) + expect(sync.results == async.results && sync.salvages == async.salvages && sync.reads == async.reads && async.results.count == 1, + "reading=\(reading) salvaged=\(salvaged): async result \(async.results) == sync \(sync.results), salvages \(async.salvages)") + if let s = sync.resultTimes.first, let a = async.resultTimes.first { + expect(a > s && a - s < 0.2, "reading=\(reading) salvaged=\(salvaged): async verdict lands only the read lag later (\(String(format: "%.2f", a - s)) s)") + } + } + + // 2. 读数回来之前验证链过期:不出结果、不补救,onExpired 恰好一次。 + for expireAfter in [0.16, 0.62, 1.0] { + let s = Scenario(reading: .visible, salvaged: .hidden, lag: 0.04) + s.verifier.start() + s.clock.advance(expireAfter) + s.fresh = false + let salvagesBefore = s.salvages + s.clock.advance(5) + expect(s.results.isEmpty && s.expired == 1 && s.salvages == salvagesBefore, + "expire at \(expireAfter) s with a read in flight: results=\(s.results) expired=\(s.expired)") + } + + // 3. 补救之后的迟到观察(台前调度那种):延后读数照样每 0.25 s 一读,读到 hidden 即结案。 + do { + let s = Scenario(reading: .visible, salvaged: .visible, lag: 0.03, late: 1.0) + s.verifier.start() + s.clock.advance(1.2) + s.salvaged = .hidden + s.clock.advance(3) + expect(s.results == [.hidden] && s.salvages == 1, "late observation with lagged reads ends hidden after one salvage: \(s.results)") + } + + // 4. 一直读不准:结果是 unknown,从不补救(unknown 不许发起新的写入)。 + do { + let s = Scenario(reading: .unknown, salvaged: .hidden, lag: 0.05) + s.verifier.start(); s.clock.advance(5) + expect(s.results == [.unknown] && s.salvages == 0, "unknown readings never license a salvage") + } + + print(failures == 0 ? "PASS fold-verifier tests" : "FAIL fold-verifier tests: \(failures)") + exit(failures == 0 ? 0 : 1) + } +} diff --git a/tests/run-fold-verifier-tests.sh b/tests/run-fold-verifier-tests.sh new file mode 100755 index 00000000..b10a3b25 --- /dev/null +++ b/tests/run-fold-verifier-tests.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# FoldVerifier 读数改成回调后的单测(性能计划 1B):延后到来的读数与同步读数判定一致、过期不出结果。 +set -euo pipefail +cd "$(dirname "$0")/.." +mkdir -p .build/fold-verifier-tests +swiftc -parse-as-library -swift-version 6 -strict-concurrency=complete -module-cache-path "$(pwd)/.build/module-cache" \ + prototype/Core/FoldVerifier.swift tests/FoldVerifierTests.swift -o .build/fold-verifier-tests/fold-verifier +.build/fold-verifier-tests/fold-verifier From b3f0c8a3dcac0469d0c89c6676d3dbe19eea33b8 Mon Sep 17 00:00:00 2001 From: Aaron <12213433+surfine@users.noreply.github.com> Date: Mon, 23 Nov 2026 16:55:43 +0800 Subject: [PATCH 11/27] =?UTF-8?q?perf(=E5=B1=95=E5=BC=80):=20=E5=B8=A6?= =?UTF-8?q?=E5=88=B0=E5=89=8D=E5=8F=B0=E7=9A=84=20raise=EF=BC=8Ffocus=20?= =?UTF-8?q?=E6=94=B9=E4=BB=8E=E4=B8=B2=E8=A1=8C=20AX=20=E9=98=9F=E5=88=97?= =?UTF-8?q?=E5=8F=91=E5=87=BA=EF=BC=88=E6=80=A7=E8=83=BD=E8=AE=A1=E5=88=92?= =?UTF-8?q?=201C=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2017 MacBook 的 sample:每次展开约 144 ms 卡在 AXUIElementPerformAction(raise),目标 App 正从最小化里出来。 activate/unhide 照旧在主线程;raise 与 focus 按原顺序在串行队列发出(立即、80 ms、250 ms 三次时刻不变), 做完回主线程再套一次兄弟窗的藏法、记日志,先后与原来相同。restore-guard(展开的那扇在最前)照过。 Co-Authored-By: Claude Opus 5.5 --- prototype/App/FoldTransaction.swift | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/prototype/App/FoldTransaction.swift b/prototype/App/FoldTransaction.swift index 3a68ea64..97c198fc 100644 --- a/prototype/App/FoldTransaction.swift +++ b/prototype/App/FoldTransaction.swift @@ -343,11 +343,19 @@ extension AppDelegate { } else { runningApp(pid: pid)?.unhide() } - raiseAXWindow(win) - focusAXWindow(win, pid: pid) - // unhide / activate 会把同一 App 里仍收着的窗一起摆回屏幕。记录不动,只把藏法再套一次。 - reapplySiblingHides(pid: pid) - wlog("front: \(reason) \(label)") + // 性能计划 1C:raise/focus 是发给目标 App 的同步 AX 调用,它正从最小化/隐藏里出来时要等它回话 + // (2017 MacBook 上每次展开约 144 ms 卡在 raise)。放到串行的 AX 队列发出,发出的时刻与顺序不变; + // 做完再回主线程把兄弟窗的藏法再套一次、记日志,和原来「raise → focus → 再藏」的先后相同。 + Self.restoreFrontQueue.async { [weak self] in + raiseAXWindow(win) + focusAXWindow(win, pid: pid) + DispatchQueue.main.async { [weak self] in + guard let self else { return } + // unhide / activate 会把同一 App 里仍收着的窗一起摆回屏幕。记录不动,只把藏法再套一次。 + self.reapplySiblingHides(pid: pid) + wlog("front: \(reason) \(label)") + } + } } attempt("immediate") @@ -362,6 +370,9 @@ extension AppDelegate { } } + /// 展开后把窗口带到前台的 raise/focus 走这条串行队列:几次重试(立即、80 ms、250 ms)按原顺序发出。 + static let restoreFrontQueue = DispatchQueue(label: "WindowShade.restore-front-ax", qos: .userInitiated) + /// 展开一扇窗之后,同一个 App 里其余仍在 `shaded` 的窗再藏一次。不改它们的记录。 func reapplySiblingHides(pid: pid_t) { for state in shaded.values where state.pid == pid && state.lifecycleStage == .folded { From d1588e5e0770b569169253883ba068f099ca50dd Mon Sep 17 00:00:00 2001 From: Aaron <12213433+surfine@users.noreply.github.com> Date: Mon, 23 Nov 2026 17:14:55 +0800 Subject: [PATCH 12/27] =?UTF-8?q?perf(=E5=B1=95=E5=BC=80):=20=E5=B1=95?= =?UTF-8?q?=E5=BC=80=E9=AA=8C=E8=AF=81=E7=9A=84=2050=20ms=20=E8=BD=AE?= =?UTF-8?q?=E8=AF=A2=E6=94=B9=E5=9C=A8=E5=90=8E=E5=8F=B0=E8=AF=BB=20AX?= =?UTF-8?q?=EF=BC=8FCG=E3=80=81=E5=9B=9E=E4=B8=BB=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E5=88=A4=E5=AE=9A=EF=BC=88=E6=80=A7=E8=83=BD=E8=AE=A1=E5=88=92?= =?UTF-8?q?=201C=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1C 第一项之后,2017 MacBook 的等待挪到了 RestoreVerifier.check → resolvedWindowElement 的 AX 读(6 次展开 631 ms)。 RestoreVerifier 的读数改成回调(同步 init 保留,旧用例逐字不变);读数在途时被取消,不确认、不回调。 observeRestoredWindow 拆出 readRestoredWindow(按原短路顺序只读 AX/CG,可在后台跑), NSRunningApplication 与屏幕安全区照旧在主线程判;resolvedWindowElement 的本体抽成 nonisolated 共用。 tests/run-fold-verifier-tests.sh 加 7 项 RestoreVerifier 用例。 Co-Authored-By: Claude Opus 5.5 --- prototype/App/FoldTransaction.swift | 16 ++-- prototype/Effects/RestoreVerification.swift | 91 +++++++++++++++++---- prototype/Effects/RestoreVerifier.swift | 26 +++++- tests/FoldVerifierTests.swift | 50 +++++++++++ tests/run-fold-verifier-tests.sh | 4 +- 5 files changed, 161 insertions(+), 26 deletions(-) diff --git a/prototype/App/FoldTransaction.swift b/prototype/App/FoldTransaction.swift index 97c198fc..3e62aeee 100644 --- a/prototype/App/FoldTransaction.swift +++ b/prototype/App/FoldTransaction.swift @@ -960,17 +960,23 @@ extension AppDelegate { // App 并不一致,比对会系统性失配,于是每次几何校正都先付一次失败比对再付 // 一次整 App 枚举。而这里本来就不需要精确校验:元素死了写入会失败, // applyRestoredGeometry 会重新解析后重写。 - if axPosition(state.element) != nil { return state.element } + Self.resolveWindowElement(state.element, pid: state.pid, sourceWindowID: state.sourceWindowID) + } + + /// resolvedWindowElement 的本体:只用 AX,可在任意线程调用(展开验证在后台读时用同一份)。 + nonisolated static func resolveWindowElement(_ element: AXUIElement, pid: pid_t, + sourceWindowID: CGWindowID) -> AXUIElement { + if axPosition(element) != nil { return element } - let windows = appWindows(pid: state.pid) - guard !windows.isEmpty else { return state.element } + let windows = appWindows(pid: pid) + guard !windows.isEmpty else { return element } - if let match = windows.first(where: { windowID(of: $0) == state.sourceWindowID }) { + if let match = windows.first(where: { windowID(of: $0) == sourceWindowID }) { return match } // A surviving sibling (even the sole remaining window) is not the source. // Keep the original element on failure; AX then fails safely instead of moving another window. - return state.element + return element } // verify=false 时跳过回读。回读的两次 AX 往返只用来拼日志里的 actual=(不参与 diff --git a/prototype/Effects/RestoreVerification.swift b/prototype/Effects/RestoreVerification.swift index bb501e05..6ded9fd2 100644 --- a/prototype/Effects/RestoreVerification.swift +++ b/prototype/Effects/RestoreVerification.swift @@ -2,24 +2,62 @@ import Cocoa /// No input/focus changes here: observation and journal acknowledgement only. extension AppDelegate { - func observeRestoredWindow(_ state: ShadeState, to pos: CGPoint) -> RestoreObservation { - guard let app = NSRunningApplication(processIdentifier: state.pid), !app.isTerminated else { - return .closed - } - let element = resolvedWindowElement(for: state) - guard let info = cgWindowInfo(state.sourceWindowID), - (info[kCGWindowOwnerPID as String] as? NSNumber)?.int32Value == state.pid + /// 展开验证要的 AX/CG 读数(性能计划 1C)。按同步版的顺序读,前一项不成立就不再往下读。 + nonisolated static func readRestoredWindow(element original: AXUIElement, pid: pid_t, + sourceWindowID: CGWindowID) -> RestoredWindowReading { + var reading = RestoredWindowReading() + let element = resolveWindowElement(original, pid: pid, sourceWindowID: sourceWindowID) + guard let info = cgWindowInfo(sourceWindowID), + (info[kCGWindowOwnerPID as String] as? NSNumber)?.int32Value == pid else { var role: CFTypeRef? - let error = AXUIElementCopyAttributeValue(state.element, kAXRoleAttribute as CFString, &role) - return error == .invalidUIElement ? .closed : .pending + reading.roleInvalid = AXUIElementCopyAttributeValue(original, kAXRoleAttribute as CFString, &role) == .invalidUIElement + return reading } - guard windowID(of: element) == state.sourceWindowID, - !app.isHidden, !axBoolAttribute(element, kAXMinimizedAttribute as String), - (info[kCGWindowIsOnscreen as String] as? Bool) == true, - ((info[kCGWindowAlpha as String] as? NSNumber)?.doubleValue ?? 1) > 0, - let bounds = cgWindowBounds(info), let size = axSize(element), - let actual = axPosition(element) + reading.hasInfo = true + reading.onscreen = (info[kCGWindowIsOnscreen as String] as? Bool) == true + reading.alphaPositive = ((info[kCGWindowAlpha as String] as? NSNumber)?.doubleValue ?? 1) > 0 + reading.bounds = cgWindowBounds(info) + guard windowID(of: element) == sourceWindowID else { return reading } + reading.windowMatches = true + reading.minimized = axBoolAttribute(element, kAXMinimizedAttribute as String) + guard !reading.minimized, reading.onscreen, reading.alphaPositive, reading.bounds != nil else { return reading } + reading.size = axSize(element) + if reading.size != nil { reading.position = axPosition(element) } + return reading + } + + /// 后台读、回主线程判定;判定逻辑与同步版相同(NSRunningApplication 与屏幕安全区照旧在主线程看)。 + func observeRestoredWindowOffMain(_ state: ShadeState, to pos: CGPoint, + completion: @escaping (RestoreObservation) -> Void) { + let element = state.element, pid = state.pid, source = state.sourceWindowID + // 判定要用的状态(ShadeState)留在主线程这一侧:后台只带走 AX 元素与值,回来后在主线程判。 + let judge = MainQueueRestoreCallback { [weak self] reading in + guard let self else { completion(.pending); return } + completion(self.observeRestoredWindow(state, to: pos, reading: reading)) + } + Self.restoreReadQueue.async { + let reading = Self.readRestoredWindow(element: element, pid: pid, sourceWindowID: source) + DispatchQueue.main.async { judge.call(reading) } + } + } + + static let restoreReadQueue = DispatchQueue(label: "WindowShade.restore-read", qos: .userInitiated) + + func observeRestoredWindow(_ state: ShadeState, to pos: CGPoint, + reading: RestoredWindowReading? = nil) -> RestoreObservation { + guard let app = NSRunningApplication(processIdentifier: state.pid), !app.isTerminated else { + return .closed + } + let r = reading ?? Self.readRestoredWindow(element: state.element, pid: state.pid, + sourceWindowID: state.sourceWindowID) + guard r.hasInfo else { return r.roleInvalid ? .closed : .pending } + guard r.windowMatches, + !app.isHidden, !r.minimized, + r.onscreen, + r.alphaPositive, + let bounds = r.bounds, let size = r.size, + let actual = r.position else { return .pending } let safe = safeRestorePosition(for: state, desired: pos) let expected = CGRect(origin: safe, size: state.originalSize) @@ -49,7 +87,10 @@ extension AppDelegate { schedule: { delay, action in DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: action) }, isCurrent: { [weak self] in self?.duoRestoreVerificationTokens[id] == token }, - observe: { [weak self] in self?.observeRestoredWindow(state, to: position) ?? .pending }, + asyncObserve: { [weak self] done in + guard let self else { done(.pending); return } + self.observeRestoredWindowOffMain(state, to: position, completion: done) + }, acknowledge: { [weak self] in self?.clearShadeJournal(id: id) }, completion: { [weak self] success in self?.duoRestoreVerificationTokens.removeValue(forKey: id) @@ -63,3 +104,21 @@ extension AppDelegate { ).start() } } + +/// observeRestoredWindow 要的读数。全是值,读完可以从后台线程交回主线程。 +struct RestoredWindowReading: Sendable { + var hasInfo = false + var roleInvalid = false + var onscreen = false + var alphaPositive = false + var bounds: CGRect? + var windowMatches = false + var minimized = false + var size: CGSize? + var position: CGPoint? +} + +/// 展开验证的回调:主线程造好,经后台读数队列带过去,只在回到主队列后调用一次。 +private struct MainQueueRestoreCallback: @unchecked Sendable { + let call: (RestoredWindowReading) -> Void +} diff --git a/prototype/Effects/RestoreVerifier.swift b/prototype/Effects/RestoreVerifier.swift index 1116f06b..2d4d4f93 100644 --- a/prototype/Effects/RestoreVerifier.swift +++ b/prototype/Effects/RestoreVerifier.swift @@ -6,20 +6,33 @@ enum RestoreObservation { case pending, visible, closed } /// acknowledgement are injected so timeouts, cancellation and retry use the same production logic. final class RestoreVerifier { typealias Schedule = (TimeInterval, @escaping () -> Void) -> Void + /// 一次读数,读完回调一次。性能计划 1C:生产路径在后台读 AX/CG、回主线程交结果,主线程不陪等。 + typealias AsyncObserve = (@escaping (RestoreObservation) -> Void) -> Void private let now: () -> TimeInterval private let schedule: Schedule private let isCurrent: () -> Bool - private let observe: () -> RestoreObservation + private let observe: AsyncObserve private let acknowledge: () -> Void private let completion: (Bool) -> Void private var started = 0.0 private var closedCount = 0 private var finished = false - init( + /// 同步读数:当场读、当场回调,与改成回调之前逐字相同。 + convenience init( now: @escaping () -> TimeInterval, schedule: @escaping Schedule, isCurrent: @escaping () -> Bool, observe: @escaping () -> RestoreObservation, acknowledge: @escaping () -> Void, completion: @escaping (Bool) -> Void + ) { + self.init(now: now, schedule: schedule, isCurrent: isCurrent, + asyncObserve: { done in done(observe()) }, + acknowledge: acknowledge, completion: completion) + } + + init( + now: @escaping () -> TimeInterval, schedule: @escaping Schedule, + isCurrent: @escaping () -> Bool, asyncObserve observe: @escaping AsyncObserve, + acknowledge: @escaping () -> Void, completion: @escaping (Bool) -> Void ) { self.now = now self.schedule = schedule @@ -37,7 +50,14 @@ final class RestoreVerifier { finished = true return } - let result = observe() + observe { result in self.checked(result) } + } + private func checked(_ result: RestoreObservation) { + // 读数在途时被取消(展开被打断、又收起):和同步版在读之前就发现一样,不确认、不回调。 + guard !finished, isCurrent() else { + finished = true + return + } closedCount = result == .closed ? closedCount + 1 : 0 if result == .visible || closedCount >= 2 { finished = true diff --git a/tests/FoldVerifierTests.swift b/tests/FoldVerifierTests.swift index a69b6393..71a9d09d 100644 --- a/tests/FoldVerifierTests.swift +++ b/tests/FoldVerifierTests.swift @@ -65,6 +65,55 @@ struct FoldVerifierTests { }() } + /// RestoreVerifier 的读数改成回调之后(性能计划 1C):延后读数与同步读数结果相同; + /// 读数在途时被取消,不确认、不回调;连读两次「关了」才算关;1.5 s 还没看见就判失败。 + static func restoreVerifierTests() { + final class Run { + let clock = Clock() + var current = true + var readings: [RestoreObservation] + var acks = 0 + var completions: [Bool] = [] + let lag: Double? + init(_ readings: [RestoreObservation], lag: Double?) { self.readings = readings; self.lag = lag } + func next() -> RestoreObservation { readings.count > 1 ? readings.removeFirst() : readings[0] } + lazy var verifier: RestoreVerifier = { + let now: () -> TimeInterval = { [unowned self] in clock.time } + if lag == nil { + return RestoreVerifier(now: now, schedule: clock.schedule, isCurrent: { [unowned self] in current }, + observe: { [unowned self] in next() }, + acknowledge: { [unowned self] in acks += 1 }, completion: { [unowned self] in completions.append($0) }) + } + return RestoreVerifier(now: now, schedule: clock.schedule, isCurrent: { [unowned self] in current }, + asyncObserve: { [unowned self] done in + let value = next() + clock.schedule(lag!) { done(value) } + }, + acknowledge: { [unowned self] in acks += 1 }, completion: { [unowned self] in completions.append($0) }) + }() + } + let scripts: [[RestoreObservation]] = [[.visible], [.pending, .pending, .visible], [.closed, .closed], [.closed, .pending, .closed, .closed], [.pending]] + for script in scripts { + let sync = Run(script, lag: nil); sync.verifier.start(); sync.clock.advance(5) + let async = Run(script, lag: 0.03); async.verifier.start(); async.clock.advance(5) + expect(sync.completions == async.completions && sync.acks == async.acks && async.completions.count == 1, + "restore \(script): async \(async.completions)/acks \(async.acks) == sync \(sync.completions)/acks \(sync.acks)") + } + do { + let run = Run([.visible], lag: 0.03) + run.verifier.start() + run.clock.advance(0.01) // 读数在途 + run.current = false + run.clock.advance(1) + expect(run.completions.isEmpty && run.acks == 0, "a restore cancelled while a read is in flight neither acknowledges nor completes") + } + do { + let run = Run([.pending], lag: 0.03) + run.verifier.start(); run.clock.advance(3) + expect(run.completions == [false] && run.acks == 0, "never visible within 1.5 s: completes false, keeps the record") + } + } + static func main() { // 1. 每种读数组合:延后 40 ms 回来,结果与同步完全相同,只是晚 40 ms/每次读。 let cases: [(V.Observation, V.Observation)] = [(.hidden, .hidden), (.visible, .hidden), (.visible, .visible), (.unknown, .hidden), (.visible, .unknown)] @@ -109,6 +158,7 @@ struct FoldVerifierTests { expect(s.results == [.unknown] && s.salvages == 0, "unknown readings never license a salvage") } + restoreVerifierTests() print(failures == 0 ? "PASS fold-verifier tests" : "FAIL fold-verifier tests: \(failures)") exit(failures == 0 ? 0 : 1) } diff --git a/tests/run-fold-verifier-tests.sh b/tests/run-fold-verifier-tests.sh index b10a3b25..ebce0d81 100755 --- a/tests/run-fold-verifier-tests.sh +++ b/tests/run-fold-verifier-tests.sh @@ -1,8 +1,8 @@ #!/bin/bash -# FoldVerifier 读数改成回调后的单测(性能计划 1B):延后到来的读数与同步读数判定一致、过期不出结果。 +# FoldVerifier/RestoreVerifier 读数改成回调后的单测(性能计划 1B、1C):延后到来的读数与同步读数判定一致、过期不出结果。 set -euo pipefail cd "$(dirname "$0")/.." mkdir -p .build/fold-verifier-tests swiftc -parse-as-library -swift-version 6 -strict-concurrency=complete -module-cache-path "$(pwd)/.build/module-cache" \ - prototype/Core/FoldVerifier.swift tests/FoldVerifierTests.swift -o .build/fold-verifier-tests/fold-verifier + prototype/Core/FoldVerifier.swift prototype/Effects/RestoreVerifier.swift tests/FoldVerifierTests.swift -o .build/fold-verifier-tests/fold-verifier .build/fold-verifier-tests/fold-verifier From 5dc8037c80270ae5bae30d20d553b894ac5c3cf4 Mon Sep 17 00:00:00 2001 From: Aaron <12213433+surfine@users.noreply.github.com> Date: Mon, 23 Nov 2026 17:41:39 +0800 Subject: [PATCH 13/27] =?UTF-8?q?fix(=E9=9A=90=E7=A7=81=E7=99=BB=E8=AE=B0)?= =?UTF-8?q?:=20=E5=B1=95=E5=BC=80=E9=AA=8C=E8=AF=81=E7=9A=84=20AX=20role?= =?UTF-8?q?=20=E8=AF=BB=E5=8F=96=E7=82=B9=E6=90=AC=E8=BF=9B=20readRestored?= =?UTF-8?q?Window=20=E5=90=8E=E6=9B=B4=E6=96=B0=E7=99=BB=E8=AE=B0=E5=8E=9F?= =?UTF-8?q?=E6=96=87=EF=BC=9B1B=EF=BC=8F1C=20=E7=9A=84=20M5=20=E4=B8=8E=20?= =?UTF-8?q?MacBook=20=E8=AE=B0=E5=B8=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 同一个读取点(window-ax),只是改写进后台读数函数。 Co-Authored-By: Claude Opus 5.5 --- docs/perf-ledger.md | 12 ++++++++++++ tools/privacy/registry.json | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/perf-ledger.md b/docs/perf-ledger.md index 79f33f48..a0bf1467 100644 --- a/docs/perf-ledger.md +++ b/docs/perf-ledger.md @@ -26,3 +26,15 @@ | 2026-11-23 | 1.0.22.1 (build 20261116.01) da4b946c4 | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build · 减少动态效果开 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show、glance-hide | fold 507.4/300; unfold 604.6/300; browser-open 412.5/412; browser-close 25.8/45; glance-show 11.5/33; glance-hide 6.8/24 | | 2026-11-23 | 1.0.22.1 (build 20261116.01) 12fe1220b | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build · 减少动态效果开 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show、glance-hide | fold 505.8/296; unfold 592.8/292; browser-open 349.9/429; browser-close 34.7/47; glance-show 5.1/25; glance-hide 5.7/25 | | 2026-11-23 | 1.0.22.1 (build 20261116.01) 12fe1220b | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build · 减少动态效果开 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show、glance-hide | fold 519.0/292; unfold 603.3/300; browser-open 355.6/413; browser-close 32.0/46; glance-show 5.4/25; glance-hide 5.4/24 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) 4f941e5fa | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build · 减少动态效果开 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show、glance-hide | fold 350.4/285; unfold 600.9/295; browser-open 370.7/427; browser-close 32.6/42; glance-show 5.4/33; glance-hide 6.1/24 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) 4f941e5fa | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build · 减少动态效果开 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show、glance-hide | fold 356.2/272; unfold 595.7/292; browser-open 355.3/410; browser-close 22.6/50; glance-show 5.2/33; glance-hide 7.0/24 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) d18697556 | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build · 减少动态效果开 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-hide | fold 176.6/208; unfold 593.9/284; browser-open 356.8/430; browser-close 13.5/44; glance-show 4.2/24; glance-hide 6.1/24 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) d18697556 | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build · 减少动态效果开 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show、glance-hide | fold 187.6/286; unfold 604.4/302; browser-open 357.0/411; browser-close 22.6/50; glance-show 8.6/33; glance-hide 6.7/25 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) d18697556 | Mac17,4 · Apple M5 · macOS 27.2.1 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show、present-unfold | fold 59.3/71; unfold 43.9/67; browser-open 184.9/117; browser-close 45.7/43; glance-show 49.7/55; glance-hide 1.8/33; present-fold 4.9/33; present-unfold 8.9/33 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) d18697556 | Mac17,4 · Apple M5 · macOS 27.2.1 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show、present-fold、present-unfold | fold 64.2/72; unfold 35.2/50; browser-open 181.3/117; browser-close 45.5/50; glance-show 43.5/54; glance-hide 0.6/33; present-fold 11.4/33; present-unfold 8.9/33 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) b7db1b465 | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build · 减少动态效果开 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show、glance-hide | fold 198.7/284; unfold 625.5/284; browser-open 360.2/413; browser-close 28.4/45; glance-show 5.6/25; glance-hide 6.6/24 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) b7db1b465 | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build · 减少动态效果开 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-hide | fold 194.6/274; unfold 603.0/295; browser-open 353.6/431; browser-close 24.3/40; glance-show 4.4/25; glance-hide 6.5/24 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) 0272e3145 | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build · 减少动态效果开 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show、glance-hide | fold 155.5/200; unfold 600.7/285; browser-open 367.2/446; browser-close 17.9/40; glance-show 5.7/33; glance-hide 6.3/24 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) 0272e3145 | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build · 减少动态效果开 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show、glance-hide | fold 179.1/261; unfold 587.6/289; browser-open 353.2/470; browser-close 23.6/51; glance-show 5.6/25; glance-hide 5.1/25 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) 0272e3145 | Mac17,4 · Apple M5 · macOS 27.2.1 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show | fold 58.3/75; unfold 20.6/50; browser-open 192.3/117; browser-close 47.5/50; glance-show 50.8/56; glance-hide 0.6/33; present-fold 3.3/33; present-unfold 0.8/33 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) 0272e3145 | Mac17,4 · Apple M5 · macOS 27.2.1 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show | fold 63.9/68; unfold 24.0/67; browser-open 191.4/117; browser-close 52.2/50; glance-show 48.5/72; glance-hide 0.6/33; present-fold 0.0/17; present-unfold 0.0/17 | diff --git a/tools/privacy/registry.json b/tools/privacy/registry.json index 17e8e7a6..df821b20 100644 --- a/tools/privacy/registry.json +++ b/tools/privacy/registry.json @@ -7625,7 +7625,7 @@ "path": "prototype/Effects/RestoreVerification.swift", "line": 14, "symbol": "AXUIElementCopyAttributeValue", - "source": "let error = AXUIElementCopyAttributeValue(state.element, kAXRoleAttribute as CFString, &role)", + "source": "reading.roleInvalid = AXUIElementCopyAttributeValue(original, kAXRoleAttribute as CFString, &role) == .invalidUIElement", "signal": "window-ax" }, { From 3685afd66021cf269e994dd848aa65e4da35ebae Mon Sep 17 00:00:00 2001 From: Aaron <12213433+surfine@users.noreply.github.com> Date: Mon, 23 Nov 2026 18:00:40 +0800 Subject: [PATCH 14/27] =?UTF-8?q?perf(=E7=9C=8B=E4=B8=80=E7=9C=BC):=20?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E6=97=B6=E7=9A=84=E8=83=8C=E6=99=AF=E5=90=88?= =?UTF-8?q?=E6=88=90=E6=94=B9=E5=9C=A8=E5=90=8E=E5=8F=B0=E6=88=AA=E3=80=81?= =?UTF-8?q?=E6=88=AA=E5=AE=8C=E5=9B=9E=E4=B8=BB=E7=BA=BF=E7=A8=8B=E6=8E=A5?= =?UTF-8?q?=E7=9D=80=E6=89=93=E5=BC=80=EF=BC=88=E6=80=A7=E8=83=BD=E8=AE=A1?= =?UTF-8?q?=E5=88=92=201D=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 等待线程的 Time Profiler(M5):每次看一眼出现,主线程 22–30 ms 卡在 FastCapture.composite (SLWindowListCreateImageFromArray 等窗口服务器合成),在 open() 里同步做。 现在需要背景图时先在后台截,截完回主线程走同一段后半流程(finishOpen),沿用开头的 now; 画面出现的时刻与原来相同、截的是同一时刻的画面。等待期间会话被收回或换掉就丢掉这次,不重复开。 M5 glance-show(10 轮快测)40–59 → 2.7 ms/s。看一眼主探针 9 项、L2 appkit 全过。 Co-Authored-By: Claude Opus 5.5 --- prototype/App/Glance.swift | 64 +++++++++++++++++++++++++++++++++----- 1 file changed, 56 insertions(+), 8 deletions(-) diff --git a/prototype/App/Glance.swift b/prototype/App/Glance.swift index f87fe4a0..a36cc1d9 100644 --- a/prototype/App/Glance.swift +++ b/prototype/App/Glance.swift @@ -118,6 +118,8 @@ private final class GlanceSession { /// 卡片在屏幕上的位置:“指针在画面上”只看卡片,不算投影边距。 var cardScreen: NSRect? var hasBackdrop = false + /// 背景图正在后台截(性能计划 1D):这段时间里不再开第二次。 + var backdropPending = false /// 缩略图:卡片从这里(面板坐标)长出来、缩回这里。 var growFrom: NSRect? @@ -650,7 +652,7 @@ final class GlanceController { let signpost = SystemLog.glanceSignposter.beginInterval("show", id: SystemLog.glanceSignposter.makeSignpostID(), "window=\(id)") defer { SystemLog.glanceSignposter.endInterval("show", signpost) } guard let session = sessions[id] else { return } - if session.stage == .shown || session.stage == .waitingForFrame { return } + if session.stage == .shown || session.stage == .waitingForFrame || session.backdropPending { return } guard let target = target(for: id) else { // 卷帘条还在,但背后的窗口不再能看一眼:忘掉这条卷帘条的意图, // 立刻收掉已经开始准备的会话,别留下没人管的准备。 @@ -671,18 +673,50 @@ final class GlanceController { session.growFrom = target.growFrom if session.viaUnhide { // 真窗口还藏着:此刻那块区域的样子就是它背后的背景。截不到就不取消隐藏,只给截图。 - if let area = target.backdropArea, - let backdrop = FastCapture.composite( - excluding: [], rect: CGRect(origin: axPosition(fromCocoaFrame: area), size: area.size)) { - content.setBackdrop(backdrop, frame: area.offsetBy(dx: -target.panel.minX, - dy: -target.panel.minY)) - session.hasBackdrop = true - } else { + // 性能计划 1D:这一截要等窗口服务器合成(M5 上每次 22–30 ms),原来压在主线程上。 + // 现在在后台截、截完回主线程接着往下做;画面出现的时刻与原来相同(原来也是截完才显示), + // 截的是同一时刻的画面,`now` 也沿用开头取的那个。等待期间被收回或换了会话就丢掉这次。 + guard let area = target.backdropArea else { session.viaUnhide = false session.captureFailed = true wlog("glance: no backdrop id=\(id); snapshot only") + finishOpen(session, target: target, panel: panel, content: content, now: now) + return + } + let rect = CGRect(origin: axPosition(fromCocoaFrame: area), size: area.size) + session.backdropPending = true + let handoff = GlanceOpenHandoff(session: session, target: target, panel: panel, content: content) + Self.backdropQueue.async { [weak self] in + let backdrop = FastCapture.composite(excluding: [], rect: rect).map(SendableCGImage.init) + DispatchQueue.main.async { [weak self] in + guard let self else { return } + let session = handoff.session + session.backdropPending = false + guard self.sessions[session.id] === session, session.stage == .preparing else { return } + if let backdrop { + handoff.content.setBackdrop(backdrop.image, frame: area.offsetBy(dx: -handoff.target.panel.minX, + dy: -handoff.target.panel.minY)) + session.hasBackdrop = true + } else { + session.viaUnhide = false + session.captureFailed = true + wlog("glance: no backdrop id=\(session.id); snapshot only") + } + self.finishOpen(session, target: handoff.target, panel: handoff.panel, content: handoff.content, now: now) + } } + return } + finishOpen(session, target: target, panel: panel, content: content, now: now) + } + + /// 截背景用的后台队列(串行:同一时刻最多一张在截)。 + private static let backdropQueue = DispatchQueue(label: "WindowShade.glance-backdrop", qos: .userInitiated) + + /// open 的后半段:装内容、挂面板、按情况显示或等首帧。 + private func finishOpen(_ session: GlanceSession, target: GlanceTarget, panel: GlancePanel, + content: GlanceContentView, now: TimeInterval) { + let id = session.id content.setSnapshot(target.snapshot) if let capture = session.capture { content.attachVideo(capture.videoLayer) } content.onClick = { [weak self] in self?.expand(id) } @@ -1024,3 +1058,17 @@ final class GlanceController { return GlancePointerSample(strip: strip, overGlance: overGlance, overControls: overControls) } } + +/// 截好的背景图从后台队列交回主线程。CGImage 建好后不可变,跨线程只传引用。 +private struct SendableCGImage: @unchecked Sendable { + let image: CGImage +} + +/// open 前半段在主线程建好的会话、目标、面板和内容视图:经后台截图队列带过去, +/// 只在回到主队列后取用,后台那一侧不碰它们。 +private struct GlanceOpenHandoff: @unchecked Sendable { + let session: GlanceSession + let target: GlanceTarget + let panel: GlancePanel + let content: GlanceContentView +} From a23fa6ff145ec2fed715e73a275e46946d8cb8cc Mon Sep 17 00:00:00 2001 From: Aaron <12213433+surfine@users.noreply.github.com> Date: Mon, 23 Nov 2026 18:19:39 +0800 Subject: [PATCH 15/27] =?UTF-8?q?perf(=E7=AA=97=E5=8F=A3=E6=B5=8F=E8=A7=88?= =?UTF-8?q?):=20=E5=85=B3=E9=97=AD=E6=B7=A1=E5=87=BA=E7=BB=93=E6=9D=9F?= =?UTF-8?q?=E5=90=8E=EF=BC=8Cclose=20=E6=8B=86=E5=88=B0=E4=B8=8B=E4=B8=80?= =?UTF-8?q?=E8=BD=AE=20runloop=EF=BC=88=E6=80=A7=E8=83=BD=E8=AE=A1?= =?UTF-8?q?=E5=88=92=201E=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 等待线程的 Time Profiler(M5):关闭时主线程只在淡出完成回调里忙,orderOut 加 close(连带一次 becomeKey) 约 11 ms 挤在同一帧,形成一个 33 ms 的帧。面板这时已透明并 orderOut;close 改到下一轮做, 这一轮强持有面板保证照样 close。焦点交还前一个 App 原本就在淡出开始时,不改。 M5 browser-close(20 轮×2)37–59 → 0.0/2.4 ms/s。 Co-Authored-By: Claude Opus 5.5 --- prototype/WindowBrowser/WindowBrowserController.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/prototype/WindowBrowser/WindowBrowserController.swift b/prototype/WindowBrowser/WindowBrowserController.swift index 4088554f..6444fd81 100644 --- a/prototype/WindowBrowser/WindowBrowserController.swift +++ b/prototype/WindowBrowser/WindowBrowserController.swift @@ -2752,8 +2752,14 @@ final class WindowBrowserController: NSObject { releasePrewarmedDockPanel() if let closingPanel { closingPanel.dismiss(animated: running) { [weak closingPanel] in - closingPanel?.orderOut(nil) - closingPanel?.close() + guard let closingPanel else { return } + closingPanel.orderOut(nil) + // 性能计划 1E:淡出结束时面板已经透明、刚 orderOut;拆整棵卡片树(close)挪到下一轮 runloop, + // 不和 orderOut 挤在同一帧里(M5 上这一帧原来约 11 ms)。看得见的结果不变; + // 这一轮强持有面板,保证 close 照样做到(和原来在同一个回调里 close 一样)。 + DispatchQueue.main.async { + closingPanel.close() + } } } session = nil From 8069654156163ffd901a2f438310d018830c460d Mon Sep 17 00:00:00 2001 From: Aaron <12213433+surfine@users.noreply.github.com> Date: Mon, 23 Nov 2026 18:50:10 +0800 Subject: [PATCH 16/27] =?UTF-8?q?docs(=E6=80=A7=E8=83=BD):=20Intel=20?= =?UTF-8?q?=E6=9C=80=E4=BD=8E=E6=A0=87=E7=AC=AC=E4=B8=80=E9=98=B6=E6=AE=B5?= =?UTF-8?q?=201A=E2=80=931E=20=E7=9A=84=E5=89=8D=E5=90=8E=E6=95=B0?= =?UTF-8?q?=E5=AD=97=E4=B8=8E=E6=B2=A1=E5=81=9A=E7=9A=84=E9=A1=B9=EF=BC=9B?= =?UTF-8?q?1D=EF=BC=8F1E=20=E4=B8=A4=E5=8F=B0=E6=9C=BA=E5=99=A8=E8=AE=B0?= =?UTF-8?q?=E5=B8=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- docs/perf-ledger.md | 6 ++++++ docs/performance.md | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/docs/perf-ledger.md b/docs/perf-ledger.md index a0bf1467..9c4273ce 100644 --- a/docs/perf-ledger.md +++ b/docs/perf-ledger.md @@ -38,3 +38,9 @@ | 2026-11-23 | 1.0.22.1 (build 20261116.01) 0272e3145 | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build · 减少动态效果开 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show、glance-hide | fold 179.1/261; unfold 587.6/289; browser-open 353.2/470; browser-close 23.6/51; glance-show 5.6/25; glance-hide 5.1/25 | | 2026-11-23 | 1.0.22.1 (build 20261116.01) 0272e3145 | Mac17,4 · Apple M5 · macOS 27.2.1 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show | fold 58.3/75; unfold 20.6/50; browser-open 192.3/117; browser-close 47.5/50; glance-show 50.8/56; glance-hide 0.6/33; present-fold 3.3/33; present-unfold 0.8/33 | | 2026-11-23 | 1.0.22.1 (build 20261116.01) 0272e3145 | Mac17,4 · Apple M5 · macOS 27.2.1 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show | fold 63.9/68; unfold 24.0/67; browser-open 191.4/117; browser-close 52.2/50; glance-show 48.5/72; glance-hide 0.6/33; present-fold 0.0/17; present-unfold 0.0/17 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) 52e5177a0+dirty | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build · 减少动态效果开 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show、glance-hide | fold 207.5/286; unfold 617.5/192; browser-open 358.8/421; browser-close 13.0/44; glance-show 10.1/33; glance-hide 7.3/25 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) 52e5177a0+dirty | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build · 减少动态效果开 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-hide | fold 187.4/279; unfold 565.5/276; browser-open 355.2/403; browser-close 20.0/44; glance-show 4.8/25; glance-hide 8.0/34 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) 792ccab92 | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build · 减少动态效果开 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show、glance-hide | fold 199.9/280; unfold 598.2/192; browser-open 358.1/454; browser-close 9.5/36; glance-show 7.7/33; glance-hide 6.9/25 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) 792ccab92 | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build · 减少动态效果开 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show、glance-hide | fold 214.9/284; unfold 599.5/283; browser-open 365.5/414; browser-close 11.0/42; glance-show 7.7/33; glance-hide 8.7/25 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) 792ccab92 | Mac17,4 · Apple M5 · macOS 27.2.1 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close | fold 62.9/69; unfold 21.8/50; browser-open 190.5/117; browser-close 11.0/38; glance-show 4.0/33; glance-hide 0.0/17; present-fold 1.6/33; present-unfold 0.0/17 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) 792ccab92 | Mac17,4 · Apple M5 · macOS 27.2.1 | 60 Hz | 超预算:fold、unfold、browser-open | fold 53.2/63; unfold 23.5/50; browser-open 181.2/117; browser-close 0.0/17; glance-show 2.7/33; glance-hide 1.2/33; present-fold 0.0/17; present-unfold 0.8/33 | diff --git a/docs/performance.md b/docs/performance.md index dc69dc10..9813d423 100644 --- a/docs/performance.md +++ b/docs/performance.md @@ -581,3 +581,24 @@ Apple Silicon 上全绿(含自检);唯一的架构阻塞点(卡顿采样 **探针:** 改动后构建上 `--pins`、`--pin-follow`、`--slide-over`、`--slide-over-spaces --other-space`、`--strip`、`--browser-identity`、`--browser-more`、`--elsewhere --other-space` 通过;`--slide-over-border` 4 项里 3 项通过,1 项点击落在“通知中心”窗口上(当时屏幕上有通知)。`--split`、`--pip`、`--slide-over-desktops` 与默认看一眼流程在改动前构建上逐行同样失败,登记在 `docs/known-failures.md`。 **后续:** 侧拉停靠时空闲约 265–525 次/秒、置顶约 525–780 次/秒的上下文切换不是轮询造成的,值得单独查。 + +## 九、2026-11-23/24:Intel 最低标第一阶段(perf/intel-floor) + +目标:2017 MacBook(MacBook10,1,Core m3-7Y32,HD 615,macOS 26.7.3 OCLP)上六类交互全部进 Apple 卡顿预算(ratio < 5 ms/s 且 worst < 100 ms)。只做帕累托改进。数字一律来自 `--hitch`(20 轮×每类,两遍);MacBook 用 `scripts/intel-floor.sh`,M5(Mac17,4)用 `scripts/perf-report.sh --host`。逐行原始数字在 `docs/perf-ledger.md`。 + +**量法先补齐(第 0 阶段)。** hitch 探针的展开等待先看进程内状态再问 CGWindowList;新增呈现侧 `HITCH-present`(Metal drawable 的 presentedTime,只算盖板看得见、进度在变的帧;盖板静止等藏窗那段另报 start delay,M5 收起中位 233 ms);glance/unfold/fold 安装各步与 refreshPanel 都有 signpost。MacBook 开着「减少动态效果」,收起不播 Metal 卷帘、没有 present 两类,单窗口 fixture 第 1 轮后走最小化——这一节的 MacBook 数字都是这条路径。 + +**热点怎么找到的。** M5 用 `xctrace` Time Profiler(`recordWaitingThreads: true` 才看得到等待)+ signpost;MacBook 没有 Xcode,用系统自带的 `sample 22 1` 在跑 6 轮 hitch 时抓主线程。慢机上的大头几乎都是「主线程对一个正忙着最小化/恢复的目标 App 发同步 AX IPC」:注册通知、读 windowID、raise。挪走一个,等待会转到下一个同步 AX 调用(1C 第一项单独量时就是这样),要整条链一起挪。 + +| 批 | 改了什么 | MacBook 前 → 后(ms/s,两遍) | M5 前 → 后(ms/s) | +| --- | --- | --- | --- | +| 1A | 窗口浏览打开:每个 App 的探查结果合并成一次 refreshPanel(每次打开 17→3 次);右键菜单右键时才建 | browser-open 412–414 → 350–356(worst 413–447 → 413–429,第 1 轮冷启动) | browser-open 455–460 → 178–193(worst 234–241 → 100–105);同一桌面状态 A/B 319–320 → 187–191 | +| 1B-1 | 「被别人揭开」通知的 AXObserverAddNotification 改在后台串行队列发出 | fold 506–519 → 350–356(p95 227–264 → 74–77) | 不变(这一步在 M5 上本来不到 1 ms) | +| 1B-2 | 收起验证的 AX 读数在后台读、回主线程判(FoldVerifier 读数改回调) | fold 350–356 → 177–188(p95 33–38) | 同状态 A/B 无退步(波动 ±15) | +| 1C | 展开带到前台的 raise/focus 走串行 AX 队列;展开验证的 50 ms 轮询在后台读 | unfold ratio 594–604 → 566–601 不变,但每次展开的卡顿总时间 263 → 150–175 ms、p95 278–283 → 176–190,展开早约 150 ms 完成(量测窗变短,ratio 看不出) | unfold 35–45 → 20.6–24.0 | +| 1D | 看一眼出现时的背景合成(FastCapture.composite)在后台截、截完回主线程接着打开 | glance-show 不变(MacBook 走最小化,不经过这一步;4–10) | glance-show 40–59 → 2.7–4.0(进预算) | +| 1E | 窗口浏览关闭:淡出结束后 orderOut,close 拆到下一轮 | browser-close 13–20 → 9.5–11.0 | browser-close 37–59 → 0.0–11.0 | + +**没做的项和原因。** 键盘面板预热:要常驻一个面板,静置内存会涨,不是帕累托,交 Aaron 决定。收起/展开的写盘移出主线程:实测每次交互 5–11 ms,属于崩溃恢复顺序的语义改动,暂缓。重复排版、SystemAppearanceCapabilities 只读一次:剖析里每次打开 ≤ 4 ms,不值得碰 AppKit 的校验兜底。即时预览改用缓存:那是 async 调用、不占主线程,且失败语义会变。展开开头的 `windowID(of:)`(MacBook 约 170 ms):换成已知窗号会改 token 守卫语义,挪到后台会让 activate 晚约 170 ms,两样都不是帕累托。`target()` 只算一次:CPU 上可忽略。 + +**顺手发现、没改的。** 外部揭开(unhide/取消最小化)收起的窗口时,「被揭开」AX 通知在 M5、MacBook 上都一次也没送到,是对账巡检兜底展开的——改之前的同步注册也一样(`--reveal-observer` 探针会印出走的是哪条路)。刘海的标题监看 `NotchController.syncWatchers → WindowTitleWatcher.watch` 同样卡在 AXObserverAddNotification(MacBook 22 秒里 187 ms)。`tests/run-duo-tests.sh` 第 61 行的弹簧断言在 main 上就失败(在门禁排除表里),挡住了后面 FoldVerifier 的老用例,新用例放在 `tests/run-fold-verifier-tests.sh`。`browser-more` 的「卡片退场动画」随桌面上开着的 App 时过时不过,main 也一样。 From ed5fa4cde4cb4aba8d53a6502ed8e91a79ece137 Mon Sep 17 00:00:00 2001 From: Aaron <12213433+surfine@users.noreply.github.com> Date: Mon, 23 Nov 2026 22:32:25 +0800 Subject: [PATCH 17/27] =?UTF-8?q?docs(=E6=80=A7=E8=83=BD):=20MacBook=20?= =?UTF-8?q?=E5=85=B3=E6=8E=89=E5=87=8F=E5=B0=91=E5=8A=A8=E6=80=81=E6=95=88?= =?UTF-8?q?=E6=9E=9C=E5=90=8E=E7=9A=84=E9=87=8D=E6=B5=8B=EF=BC=9B=E7=94=BB?= =?UTF-8?q?=E9=9D=A2=E6=95=88=E6=9E=9C=E6=89=93=E5=BC=80=E6=97=B6=E7=9A=84?= =?UTF-8?q?=E5=91=88=E7=8E=B0=E4=BE=A7=E4=B8=8E=20GPU=20=E6=97=B6=E9=97=B4?= =?UTF-8?q?=EF=BC=88HD=20615=20=E6=AF=8F=E5=B8=A7=20p95=2010=E2=80=9317=20?= =?UTF-8?q?ms=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- docs/perf-ledger.md | 2 ++ docs/performance.md | 3 +++ 2 files changed, 5 insertions(+) diff --git a/docs/perf-ledger.md b/docs/perf-ledger.md index 9c4273ce..e8f922b0 100644 --- a/docs/perf-ledger.md +++ b/docs/perf-ledger.md @@ -44,3 +44,5 @@ | 2026-11-23 | 1.0.22.1 (build 20261116.01) 792ccab92 | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build · 减少动态效果开 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close、glance-show、glance-hide | fold 214.9/284; unfold 599.5/283; browser-open 365.5/414; browser-close 11.0/42; glance-show 7.7/33; glance-hide 8.7/25 | | 2026-11-23 | 1.0.22.1 (build 20261116.01) 792ccab92 | Mac17,4 · Apple M5 · macOS 27.2.1 | 60 Hz | 超预算:fold、unfold、browser-open、browser-close | fold 62.9/69; unfold 21.8/50; browser-open 190.5/117; browser-close 11.0/38; glance-show 4.0/33; glance-hide 0.0/17; present-fold 1.6/33; present-unfold 0.0/17 | | 2026-11-23 | 1.0.22.1 (build 20261116.01) 792ccab92 | Mac17,4 · Apple M5 · macOS 27.2.1 | 60 Hz | 超预算:fold、unfold、browser-open | fold 53.2/63; unfold 23.5/50; browser-open 181.2/117; browser-close 0.0/17; glance-show 2.7/33; glance-hide 1.2/33; present-fold 0.0/17; present-unfold 0.8/33 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) 7cd367750 | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build | 60 Hz | 超预算:fold、unfold、browser-open、browser-close | fold 193.9/274; unfold 600.4/290; browser-open 358.1/426; browser-close 7.0/44; glance-show 0.5/17; glance-hide 1.0/33 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) 7cd367750 | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build | 60 Hz | 超预算:fold、unfold、browser-open、browser-close | fold 172.3/252; unfold 627.4/289; browser-open 364.8/437; browser-close 5.2/36; glance-show 0.5/17; glance-hide 0.5/17 | diff --git a/docs/performance.md b/docs/performance.md index 9813d423..f03f44c0 100644 --- a/docs/performance.md +++ b/docs/performance.md @@ -602,3 +602,6 @@ Apple Silicon 上全绿(含自检);唯一的架构阻塞点(卡顿采样 **没做的项和原因。** 键盘面板预热:要常驻一个面板,静置内存会涨,不是帕累托,交 Aaron 决定。收起/展开的写盘移出主线程:实测每次交互 5–11 ms,属于崩溃恢复顺序的语义改动,暂缓。重复排版、SystemAppearanceCapabilities 只读一次:剖析里每次打开 ≤ 4 ms,不值得碰 AppKit 的校验兜底。即时预览改用缓存:那是 async 调用、不占主线程,且失败语义会变。展开开头的 `windowID(of:)`(MacBook 约 170 ms):换成已知窗号会改 token 守卫语义,挪到后台会让 activate 晚约 170 ms,两样都不是帕累托。`target()` 只算一次:CPU 上可忽略。 **顺手发现、没改的。** 外部揭开(unhide/取消最小化)收起的窗口时,「被揭开」AX 通知在 M5、MacBook 上都一次也没送到,是对账巡检兜底展开的——改之前的同步注册也一样(`--reveal-observer` 探针会印出走的是哪条路)。刘海的标题监看 `NotchController.syncWatchers → WindowTitleWatcher.watch` 同样卡在 AXObserverAddNotification(MacBook 22 秒里 187 ms)。`tests/run-duo-tests.sh` 第 61 行的弹簧断言在 main 上就失败(在门禁排除表里),挡住了后面 FoldVerifier 的老用例,新用例放在 `tests/run-fold-verifier-tests.sh`。`browser-more` 的「卡片退场动画」随桌面上开着的 App 时过时不过,main 也一样。 + +**2026-11-24 补:MacBook 关掉「减少动态效果」之后。** 收起仍不走 Metal 卷帘:WindowShade 的「画面效果」(`Effects.enabled`)全新安装默认关,这台机器也是关的,收起走描边代理。所以上表 MacBook 的数字就是 Intel 用户的默认路径。关掉减少动态效果后看一眼进了预算(glance-show 0.5、glance-hide 0.5–1.0 ms/s),其余不变。 +临时把这台测试机的「画面效果」打开量呈现侧(量完改回关):present-fold 84–124 ms/s(worst 50 ms)、present-unfold 47–58(worst 33–50),掉帧集中在动画开头;主线程 fold 149–190(worst 289–460)、unfold 50–54(开了效果后收起走整 App 隐藏,不再最小化);收起起跑延迟中位 350–417 ms。`WINDOWSHADE_DUO_DIAGNOSTICS=1` 显示 HD 615 上每帧 GPU 时间 p95 10–17 ms、只允许一帧在途,每段动画跳过 7–36 帧,`gpuToBusyP95=0`(主线程没拖完成回调)——呈现侧的掉帧是 GPU 那一侧。现成的 `WINDOWSHADE_FOLD_TWO_IN_FLIGHT=1` 在这台机器上第一帧可见呈现等了 15 分钟(首帧 0.5 s 超时也没触发),不能用。 From b27edd6e5302dfd210d877c3c61c0a0162ebd760 Mon Sep 17 00:00:00 2001 From: Aaron <12213433+surfine@users.noreply.github.com> Date: Mon, 23 Nov 2026 23:08:09 +0800 Subject: [PATCH 18/27] =?UTF-8?q?perf(=E5=B1=95=E5=BC=80/=E5=88=98?= =?UTF-8?q?=E6=B5=B7):=20=E5=B1=95=E5=BC=80=E5=90=8E=E7=9A=84=E5=87=A0?= =?UTF-8?q?=E4=BD=95=E6=A0=A1=E6=AD=A3=E4=B8=8E=E5=88=98=E6=B5=B7=E6=A0=87?= =?UTF-8?q?=E9=A2=98=E7=9B=91=E7=9C=8B=E7=9A=84=20AX=20=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E7=A7=BB=E5=87=BA=E4=B8=BB=E7=BA=BF=E7=A8=8B=EF=BC=88=E6=80=A7?= =?UTF-8?q?=E8=83=BD=E8=AE=A1=E5=88=92=E7=AC=AC=E4=BA=8C=E8=BD=AE=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2017 MacBook 70 秒 sample: - 展开后 80/250/550/1100 ms 的几何校正(applyRestoredGeometry 与 raise/focus)611 ms 压在主线程。 AX 部分抽成 applyRestoredGeometryAX,按原时刻在串行 AX 队列(与带到前台同一条)发出; 屏幕安全区照旧主线程算,日志与解析出的元素回主线程记。 - 刘海标题监看 WindowTitleWatcher.watch 的 AXObserverAddNotification 183 ms。 注册改在后台串行队列,在途的也算「在盯」(基准标题只记一次、收起结束照样撤), 在途时被撤或 App 退出就把注册上的那条撤掉。--notch 探针加一条:2 秒后已真的注册上。 (--notch 里「标题变了刘海短暂展开」那条在改动前的 HEAD 上同样失败,是既有问题。) Co-Authored-By: Claude Opus 5.5 --- prototype/App/FoldTransaction.swift | 76 ++++++++++++++++++----- prototype/App/GestureProbe.swift | 3 + prototype/App/Notch/NotchController.swift | 1 + prototype/App/NotchWatch.swift | 67 +++++++++++++++++--- 4 files changed, 123 insertions(+), 24 deletions(-) diff --git a/prototype/App/FoldTransaction.swift b/prototype/App/FoldTransaction.swift index 3e62aeee..57e005ad 100644 --- a/prototype/App/FoldTransaction.swift +++ b/prototype/App/FoldTransaction.swift @@ -992,13 +992,25 @@ extension AppDelegate { label: String, reason: String, verify: Bool = true, element: AXUIElement? = nil) -> AXUIElement { - var win = element ?? resolvedWindowElement(for: state) let safePos = safeRestorePosition(for: state, desired: pos) - var sizeErr = setAXSize(win, state.originalSize) + let result = Self.applyRestoredGeometryAX( + element: element, original: state.element, pid: state.pid, sourceWindowID: state.sourceWindowID, + size: state.originalSize, position: safePos, verify: verify) + logRestoredGeometry(result, state: state, desired: pos, safePos: safePos, label: label, reason: reason) + return result.window + } + + /// applyRestoredGeometry 的 AX 部分:只用 AX,可在任意线程调用(展开后的几次校正在串行 AX 队列上做)。 + nonisolated static func applyRestoredGeometryAX( + element: AXUIElement?, original: AXUIElement, pid: pid_t, sourceWindowID: CGWindowID, + size: CGSize, position safePos: CGPoint, verify: Bool + ) -> RestoredGeometryResult { + var win = element ?? resolveWindowElement(original, pid: pid, sourceWindowID: sourceWindowID) + var sizeErr = setAXSize(win, size) var posErr = setAXPositionReturningError(win, safePos) if element != nil, sizeErr != .success || posErr != .success { - win = resolvedWindowElement(for: state) - sizeErr = setAXSize(win, state.originalSize) + win = resolveWindowElement(original, pid: pid, sourceWindowID: sourceWindowID) + sizeErr = setAXSize(win, size) posErr = setAXPositionReturningError(win, safePos) } let failed = sizeErr != .success || posErr != .success @@ -1012,11 +1024,15 @@ extension AppDelegate { } else { actual = "" } - wlog("geometry: \(reason) \(label) target=(\(Int(safePos.x)),\(Int(safePos.y)) \(Int(state.originalSize.width))x\(Int(state.originalSize.height))) err=(size:\(sizeErr),pos:\(posErr))\(actual)") + return RestoredGeometryResult(window: win, sizeError: sizeErr, positionError: posErr, actual: actual) + } + + func logRestoredGeometry(_ result: RestoredGeometryResult, state: ShadeState, desired pos: CGPoint, + safePos: CGPoint, label: String, reason: String) { + wlog("geometry: \(reason) \(label) target=(\(Int(safePos.x)),\(Int(safePos.y)) \(Int(state.originalSize.width))x\(Int(state.originalSize.height))) err=(size:\(result.sizeError),pos:\(result.positionError))\(result.actual)") if safePos != pos { wlog("restore: clamped invisible target app=\(state.appName) pos=(\(Int(safePos.x)),\(Int(safePos.y)))") } - return win } // 按隐藏方式把真窗口恢复可见,并放到指定位置 @@ -1074,17 +1090,29 @@ extension AppDelegate { // 前几次尝试只校正几何,最后一次才 raise+focus:旧实现每次尝试都重新 // 激活/聚焦,restoreAll 批量展开时会造成焦点连环跳(每次 3~4 次 focus)。 - var resolvedElement: AXUIElement? + // 性能计划第二轮:这几次校正的 AX 写入(尺寸、位置、raise、focus)是发给刚恢复的目标 App 的同步 IPC, + // 慢机上它还在忙,每次展开约 100 ms 压在主线程(2017 MacBook sample)。时刻与次数不变, + // 改在串行的 AX 队列上按原顺序发出(和带到前台的 raise/focus 同一条队列,先后不乱); + // 屏幕安全区照旧在主线程算,日志与解析出的元素回主线程记。 + let pinBox = PinElementBox() func attempt(_ label: String, focus: Bool, verify: Bool = true) { guard restorePinTokens[id] == token else { return } - let win = marking("restore: 几何校正") { - applyRestoredGeometry(state, to: pos, label: label, reason: reason, - verify: verify, element: resolvedElement) + let safePos = safeRestorePosition(for: state, desired: pos) + let original = state.element, pid = state.pid, source = state.sourceWindowID, size = state.originalSize + let element = pinBox.element + let report = MainQueueGeometryReport { [weak self] result in + pinBox.element = result.window + self?.logRestoredGeometry(result, state: state, desired: pos, safePos: safePos, label: label, reason: reason) } - resolvedElement = win - if focus { - raiseAXWindow(win) - focusAXWindow(win, pid: state.pid) + Self.restoreFrontQueue.async { + let result = Self.applyRestoredGeometryAX( + element: element, original: original, pid: pid, sourceWindowID: source, + size: size, position: safePos, verify: verify) + if focus { + raiseAXWindow(result.window) + focusAXWindow(result.window, pid: pid) + } + DispatchQueue.main.async { report.call(result) } } } @@ -1101,7 +1129,7 @@ extension AppDelegate { } DispatchQueue.main.asyncAfter(deadline: .now() + 1.10) { // 这时还原动画早已走完:窗口又是最小化的,是人(或 App)刚把它收回去了,不再拉出来、不抢焦点。 - if let win = resolvedElement, axBoolAttribute(win, kAXMinimizedAttribute as String) { + if let win = pinBox.element, axBoolAttribute(win, kAXMinimizedAttribute as String) { self.restorePinTokens[id] = UUID() wlog("restore: id=\(id) minimized again after restore; late pin skipped") return @@ -1436,3 +1464,21 @@ private struct RevealObserverRegistration: @unchecked Sendable { return results.contains(.success) } } + +/// applyRestoredGeometryAX 的结果:值与 AX 元素引用,可从 AX 队列交回主线程。 +struct RestoredGeometryResult: Sendable { + let window: AXUIElement + let sizeError: AXError + let positionError: AXError + let actual: String +} + +/// 展开后几次校正共用的「上一档解析出的元素」:只在主线程读写。 +private final class PinElementBox { + var element: AXUIElement? +} + +/// 校正结果的回调:主线程造好,经 AX 队列带过去,只在回到主队列后调用。 +private struct MainQueueGeometryReport: @unchecked Sendable { + let call: (RestoredGeometryResult) -> Void +} diff --git a/prototype/App/GestureProbe.swift b/prototype/App/GestureProbe.swift index 8fdaf480..1b49f00c 100644 --- a/prototype/App/GestureProbe.swift +++ b/prototype/App/GestureProbe.swift @@ -1992,6 +1992,9 @@ extension GlanceProbe { notch.syncWatchersForProbe() let watching = notch.isWatchingTitle(id) try await Task.sleep(for: .milliseconds(2200), clock: .suspending) + // 标题通知的 AX 注册在后台发出(性能计划第二轮):2 秒后要已经真的注册上。 + let registered = notch.isTitleWatchRegistered(id) + print("\(registered ? "PASS" : "FAIL") notch: the tucked window's title notification is registered with the app (off the main thread)") let before = notch.panelFrame ?? .zero notch.simulateTitleChange(id, title: "Build Succeeded") try await Task.sleep(for: .milliseconds(700), clock: .suspending) diff --git a/prototype/App/Notch/NotchController.swift b/prototype/App/Notch/NotchController.swift index 1c05ebba..39247ce4 100644 --- a/prototype/App/Notch/NotchController.swift +++ b/prototype/App/Notch/NotchController.swift @@ -2686,6 +2686,7 @@ final class NotchController { var isAlerting: Bool { panels.values.contains { $0.isAlerting } } func syncWatchersForProbe() { syncWatchers() } func isWatchingTitle(_ id: CGWindowID) -> Bool { watcher.isWatching(id) } + func isTitleWatchRegistered(_ id: CGWindowID) -> Bool { watcher.isRegistered(id) } var tileKindsForProbe: [(id: CGWindowID, kind: NotchTile.Kind)] { tiles().map { ($0.id, $0.kind) } } // MARK: - 飞 diff --git a/prototype/App/NotchWatch.swift b/prototype/App/NotchWatch.swift index 3cea7db0..3eabfbac 100644 --- a/prototype/App/NotchWatch.swift +++ b/prototype/App/NotchWatch.swift @@ -16,11 +16,19 @@ final class WindowTitleWatcher { private var pending: [CGWindowID: DispatchWorkItem] = [:] /// 挂失败的窗口:到点前不再问(syncWatchers 每 2 秒来一次,每次都是同步的辅助功能调用)。 private var failures: [CGWindowID: (retryAt: TimeInterval, delay: TimeInterval)] = [:] + /// 正在后台注册标题通知的窗口(性能计划第二轮):值是这次注册的序号,unwatch/App 退出时删掉即作废。 + private var registering: [CGWindowID: (pid: pid_t, serial: UInt64)] = [:] + private var registrationSerial: UInt64 = 0 + /// 标题通知注册是发给目标 App 的同步 IPC,它忙的时候要等(2017 MacBook 上 70 秒里约 180 ms 压在主线程)。 + private static let registrationQueue = DispatchQueue(label: "WindowShade.title-watch-ax", qos: .utility) private var terminateObserver: NSObjectProtocol? static let settle: TimeInterval = 1.0 - var watchedIDs: [CGWindowID] { Array(watched.keys) } - func isWatching(_ id: CGWindowID) -> Bool { watched[id] != nil } + /// 注册在途的也算「在盯」:和原来同步注册时一样,基准标题只在开始盯时记一次,收起结束时照样撤掉。 + var watchedIDs: [CGWindowID] { Array(watched.keys) + registering.keys.filter { watched[$0] == nil } } + func isWatching(_ id: CGWindowID) -> Bool { watched[id] != nil || registering[id] != nil } + /// 标题通知已经真的注册上(不含在途)。只给探针用。 + func isRegistered(_ id: CGWindowID) -> Bool { watched[id] != nil } init() { // pid 会被复用:退出的 App 留下的观察者不能让新进程碰到。 @@ -33,16 +41,37 @@ final class WindowTitleWatcher { } func watch(id: CGWindowID, pid: pid_t, element: AXUIElement) { - guard watched[id] == nil else { return } + guard watched[id] == nil, registering[id] == nil else { return } let now = CACurrentMediaTime() if let failure = failures[id], now < failure.retryAt { return } - let refcon = Unmanaged.passUnretained(self).toOpaque() - if let observer = observer(for: pid), - AXObserverAddNotification(observer, element, kAXTitleChangedNotification as CFString, refcon) == .success { - failures.removeValue(forKey: id) - watched[id] = (pid, element) - return + guard let observer = observer(for: pid) else { registrationFailed(id: id, pid: pid, now: now); return } + // 注册在后台串行队列发出,结果回主线程记账;成败的处理与原来同步注册时相同。 + registrationSerial &+= 1 + let serial = registrationSerial + registering[id] = (pid, serial) + let request = TitleWatchRegistration(observer: observer, element: element, + refcon: UInt(bitPattern: Unmanaged.passUnretained(self).toOpaque())) + Self.registrationQueue.async { [weak self] in + let ok = request.register() + DispatchQueue.main.async { [weak self] in + guard let self else { return } + guard self.registering[id]?.serial == serial else { + // 在途时被 unwatch 或 App 退出:注册上的这一条撤掉,不留。 + if ok { Self.registrationQueue.async { request.unregister() } } + return + } + self.registering.removeValue(forKey: id) + if ok { + self.failures.removeValue(forKey: id) + self.watched[id] = (pid, element) + } else { + self.registrationFailed(id: id, pid: pid, now: CACurrentMediaTime()) + } + } } + } + + private func registrationFailed(id: CGWindowID, pid: pid_t, now: TimeInterval) { let delay = AXWatchRetryPolicy.nextDelay(after: failures[id]?.delay) failures[id] = (now + delay, delay) // 窗口早已不在了的记录没人来 unwatch,过了重试时间的顺手清掉。 @@ -51,6 +80,7 @@ final class WindowTitleWatcher { } private func dropApp(_ pid: pid_t) { + for (id, entry) in registering where entry.pid == pid { registering.removeValue(forKey: id) } for (id, entry) in watched where entry.pid == pid { pending.removeValue(forKey: id)?.cancel() watched.removeValue(forKey: id) @@ -60,6 +90,7 @@ final class WindowTitleWatcher { private func removeObserverIfIdle(_ pid: pid_t) { guard !watched.values.contains(where: { $0.pid == pid }), + !registering.values.contains(where: { $0.pid == pid }), let observer = observers.removeValue(forKey: pid) else { return } CFRunLoopRemoveSource(CFRunLoopGetMain(), AXObserverGetRunLoopSource(observer), .defaultMode) } @@ -67,6 +98,7 @@ final class WindowTitleWatcher { func unwatch(_ id: CGWindowID) { pending.removeValue(forKey: id)?.cancel() failures.removeValue(forKey: id) + if let inFlight = registering.removeValue(forKey: id) { removeObserverIfIdle(inFlight.pid) } guard let entry = watched.removeValue(forKey: id) else { return } if let observer = observers[entry.pid] { AXObserverRemoveNotification(observer, entry.element, kAXTitleChangedNotification as CFString) @@ -501,3 +533,20 @@ extension MenuBarRoom { return path.hasPrefix("/System/") || path.hasPrefix("/usr/") } } + +/// 标题通知的注册请求:观察者与元素是不可变引用,AXObserverAdd/RemoveNotification 可在任意线程发起, +/// 回调仍由主线程 runloop 上的 source 投递。只在 WindowTitleWatcher 的串行注册队列上用。 +private struct TitleWatchRegistration: @unchecked Sendable { + let observer: AXObserver + let element: AXUIElement + let refcon: UInt + + func register() -> Bool { + AXObserverAddNotification(observer, element, kAXTitleChangedNotification as CFString, + UnsafeMutableRawPointer(bitPattern: refcon)) == .success + } + + func unregister() { + AXObserverRemoveNotification(observer, element, kAXTitleChangedNotification as CFString) + } +} From c448f2b24fd4d0280acc33d38024e387f2006978 Mon Sep 17 00:00:00 2001 From: Aaron <12213433+surfine@users.noreply.github.com> Date: Mon, 23 Nov 2026 23:28:00 +0800 Subject: [PATCH 19/27] =?UTF-8?q?perf(=E7=AA=97=E5=8F=A3=E6=B5=8F=E8=A7=88?= =?UTF-8?q?):=20=E9=A1=B5=E8=84=9A=E3=80=8C=E6=89=93=E5=BC=80=E5=B1=8F?= =?UTF-8?q?=E5=B9=95=E5=BD=95=E5=88=B6=E8=AE=BE=E7=BD=AE=E3=80=8D=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E7=AC=AC=E4=B8=80=E6=AC=A1=E8=A6=81=E9=9C=B2=E5=87=BA?= =?UTF-8?q?=E6=97=B6=E6=89=8D=E5=BB=BA=EF=BC=88=E6=80=A7=E8=83=BD=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E7=AC=AC=E4=BA=8C=E8=BD=AE=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2017 MacBook sample:每次建面板约 34 ms 花在 NSButton(title:) 的 sizeToFit(macOS 26 走 SwiftUI 按钮排版), 而这颗按钮只在缺屏幕录制权限时才露出。建法与配置逐项不变,插回原来的层次(caption 之下),只是延后到要露出时。 Co-Authored-By: Claude Opus 5.5 --- .../WindowBrowserContentView.swift | 41 +++++++++++++------ 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/prototype/WindowBrowser/WindowBrowserContentView.swift b/prototype/WindowBrowser/WindowBrowserContentView.swift index 8e0fae8f..3aeb3d6e 100644 --- a/prototype/WindowBrowser/WindowBrowserContentView.swift +++ b/prototype/WindowBrowser/WindowBrowserContentView.swift @@ -80,7 +80,9 @@ final class WindowBrowserContentView: NSView, NSSearchFieldDelegate, NSTextViewD /// 列表为空时列表区中央的一行说明(搜索无结果 / 没有窗口)。 private let emptyStateField = NSTextField(labelWithString: "") /// 缺少屏幕录制权限时页脚右侧的入口:走现有的系统设置深链,不在悬停时弹授权框。 - private let permissionButton = NSButton(title: WSL10n.text("browser.permission.openSettings", zh: "打开“屏幕录制”设置…"), target: nil, action: nil) + /// 性能计划第二轮:NSButton(title:) 建好就 sizeToFit,macOS 26 上要走一遍 SwiftUI 的按钮排版 + /// (2017 MacBook 上每次建面板约 34 ms),而它只在缺屏幕录制权限时才露出来。建法不变,只是第一次要露出时才建。 + private var permissionButtonStorage: NSButton? /// 页脚“打开设置”入口的回调(控制器接到现有权限页面)。 var onOpenScreenRecordingSettings: (() -> Void)? // 只在主线程写;deinit 里移除时已没有别的引用。 @@ -221,17 +223,9 @@ final class WindowBrowserContentView: NSView, NSSearchFieldDelegate, NSTextViewD emptyStateField.lineBreakMode = .byTruncatingTail emptyStateField.isHidden = true - permissionButton.isBordered = false - permissionButton.font = WindowBrowserTypography.detail - permissionButton.contentTintColor = .linkColor - permissionButton.target = self - permissionButton.action = #selector(openScreenRecordingSettings) - permissionButton.setAccessibilityLabel(WSL10n.text("browser.permission.settingsLabel", zh: "打开屏幕录制设置")) - permissionButton.isHidden = true - for view in [iconView, appNameField, detailStatusField, searchField, styleControl, scrollView, detailPane, footerStatusField, emptyStateField, - permissionButton, captionField] { + captionField] { materialHost.contentHost.addSubview(view) } setAccessibilityElement(true) @@ -281,7 +275,11 @@ final class WindowBrowserContentView: NSView, NSSearchFieldDelegate, NSTextViewD } if params.headerVisible { appNameField.isHidden = false } footerStatusField.stringValue = status - permissionButton.isHidden = screenRecordingAvailable || status.isEmpty + if screenRecordingAvailable || status.isEmpty { + permissionButtonStorage?.isHidden = true + } else { + (permissionButtonStorage ?? makePermissionButton()).isHidden = false + } if records.isEmpty { emptyStateField.stringValue = mode == .keyboard && !searchField.stringValue.isEmpty ? WSL10n.text("browser.empty.noMatch", zh: "没有匹配的窗口") @@ -340,6 +338,22 @@ final class WindowBrowserContentView: NSView, NSSearchFieldDelegate, NSTextViewD return { [weak self] in self?.contextMenuProvider?(key) ?? nil } } + /// 页脚“打开屏幕录制设置”入口:第一次要露出时才建,配置与原来逐项相同,插在原来的层次位置(caption 之下)。 + private func makePermissionButton() -> NSButton { + let button = NSButton(title: WSL10n.text("browser.permission.openSettings", zh: "打开“屏幕录制”设置…"), target: nil, action: nil) + button.isBordered = false + button.font = WindowBrowserTypography.detail + button.contentTintColor = .linkColor + button.target = self + button.action = #selector(openScreenRecordingSettings) + button.setAccessibilityLabel(WSL10n.text("browser.permission.settingsLabel", zh: "打开屏幕录制设置")) + button.isHidden = true + materialHost.contentHost.addSubview(button, positioned: .below, relativeTo: captionField) + permissionButtonStorage = button + needsLayout = true + return button + } + /// 外观设置或系统辅助功能变化时局部刷新材质与层颜色,不改变窗口状态、 /// 不触发任何截图,也不重建数据。 func refreshMaterialAppearance() { @@ -852,8 +866,9 @@ final class WindowBrowserContentView: NSView, NSSearchFieldDelegate, NSTextViewD detailStatusField.frame = NSRect(x: textLeft, y: blockBottom, width: textWidth, height: detailHeight) searchField.frame = plan.searchRect - let buttonSize = permissionButton.isHidden ? .zero : permissionButton.intrinsicContentSize - permissionButton.frame = NSRect( + let permissionButton = permissionButtonStorage + let buttonSize = permissionButton.map { $0.isHidden ? .zero : $0.intrinsicContentSize } ?? .zero + permissionButton?.frame = NSRect( x: plan.footerRect.maxX - buttonSize.width, y: floor(plan.footerRect.midY - buttonSize.height / 2), width: buttonSize.width, height: buttonSize.height) From efb3506053992c62b17791d73c12d1bf08ea4d1c Mon Sep 17 00:00:00 2001 From: Aaron <12213433+surfine@users.noreply.github.com> Date: Tue, 24 Nov 2026 00:14:34 +0800 Subject: [PATCH 20/27] =?UTF-8?q?docs(=E6=80=A7=E8=83=BD):=20=E7=AC=AC?= =?UTF-8?q?=E4=BA=8C=E8=BD=AE=E4=B8=BB=E7=BA=BF=E7=A8=8B=E7=9A=84=20MacBoo?= =?UTF-8?q?k=20=E5=89=8D=E5=90=8E=E6=95=B0=E5=AD=97=E4=B8=8E=20M5=20?= =?UTF-8?q?=E5=90=8C=E6=97=B6=E6=AE=B5=20A/B=EF=BC=9B=E6=B2=A1=E5=81=9A?= =?UTF-8?q?=E7=9A=84=E9=A1=B9=E4=B8=8E=E6=97=A2=E6=9C=89=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- docs/perf-ledger.md | 2 ++ docs/performance.md | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/docs/perf-ledger.md b/docs/perf-ledger.md index e8f922b0..b0c82ead 100644 --- a/docs/perf-ledger.md +++ b/docs/perf-ledger.md @@ -46,3 +46,5 @@ | 2026-11-23 | 1.0.22.1 (build 20261116.01) 792ccab92 | Mac17,4 · Apple M5 · macOS 27.2.1 | 60 Hz | 超预算:fold、unfold、browser-open | fold 53.2/63; unfold 23.5/50; browser-open 181.2/117; browser-close 0.0/17; glance-show 2.7/33; glance-hide 1.2/33; present-fold 0.0/17; present-unfold 0.8/33 | | 2026-11-23 | 1.0.22.1 (build 20261116.01) 7cd367750 | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build | 60 Hz | 超预算:fold、unfold、browser-open、browser-close | fold 193.9/274; unfold 600.4/290; browser-open 358.1/426; browser-close 7.0/44; glance-show 0.5/17; glance-hide 1.0/33 | | 2026-11-23 | 1.0.22.1 (build 20261116.01) 7cd367750 | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build | 60 Hz | 超预算:fold、unfold、browser-open、browser-close | fold 172.3/252; unfold 627.4/289; browser-open 364.8/437; browser-close 5.2/36; glance-show 0.5/17; glance-hide 0.5/17 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) 53c3d5d49 | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build | 60 Hz | 超预算:fold、unfold、browser-open、browser-close | fold 133.0/219; unfold 118.6/51; browser-open 355.8/301; browser-close 7.4/36; glance-show 1.9/33; glance-hide 0.5/17 | +| 2026-11-23 | 1.0.22.1 (build 20261116.01) 53c3d5d49 | MacBook10,1 · Intel Core m3-7Y32 · macOS 26.7.3 · x86_64 build | 60 Hz | 超预算:fold、unfold、browser-open、browser-close | fold 130.6/165; unfold 169.7/283; browser-open 351.8/370; browser-close 7.1/35; glance-show 1.9/33; glance-hide 0.5/17 | diff --git a/docs/performance.md b/docs/performance.md index f03f44c0..f83206f6 100644 --- a/docs/performance.md +++ b/docs/performance.md @@ -605,3 +605,14 @@ Apple Silicon 上全绿(含自检);唯一的架构阻塞点(卡顿采样 **2026-11-24 补:MacBook 关掉「减少动态效果」之后。** 收起仍不走 Metal 卷帘:WindowShade 的「画面效果」(`Effects.enabled`)全新安装默认关,这台机器也是关的,收起走描边代理。所以上表 MacBook 的数字就是 Intel 用户的默认路径。关掉减少动态效果后看一眼进了预算(glance-show 0.5、glance-hide 0.5–1.0 ms/s),其余不变。 临时把这台测试机的「画面效果」打开量呈现侧(量完改回关):present-fold 84–124 ms/s(worst 50 ms)、present-unfold 47–58(worst 33–50),掉帧集中在动画开头;主线程 fold 149–190(worst 289–460)、unfold 50–54(开了效果后收起走整 App 隐藏,不再最小化);收起起跑延迟中位 350–417 ms。`WINDOWSHADE_DUO_DIAGNOSTICS=1` 显示 HD 615 上每帧 GPU 时间 p95 10–17 ms、只允许一帧在途,每段动画跳过 7–36 帧,`gpuToBusyP95=0`(主线程没拖完成回调)——呈现侧的掉帧是 GPU 那一侧。现成的 `WINDOWSHADE_FOLD_TWO_IN_FLIGHT=1` 在这台机器上第一帧可见呈现等了 15 分钟(首帧 0.5 s 超时也没触发),不能用。 + +**2026-11-24 第二轮主线程(MacBook 默认路径:减少动态效果关、画面效果关)。** 70 秒 sample 找出的三处: + +| 改了什么 | MacBook 前 → 后(ms/s,两遍) | +| --- | --- | +| 展开后 80/250/550/1100 ms 的几何校正(尺寸、位置、raise、focus)改在串行 AX 队列发出;刘海标题监看的通知注册改在后台 | unfold 600–627 → 119–170(p95 175–181 → 33–34,worst 289 → 51/283);fold 172–194 → 131–133(worst 252–274 → 165–219) | +| 窗口浏览页脚「打开屏幕录制设置」按钮第一次要露出时才建(NSButton(title:) 的 sizeToFit 在 macOS 26 走 SwiftUI 排版,每次建面板约 34 ms) | browser-open ratio 352–365 不变,worst 426–437 → 301–370;Panel.init 每次约 56 → 11 ms | + +M5 这段时间被别的任务占着(load 5),绝对数不准,改做同一时段 A/B(3fd9b1c8 对 HEAD,交替各两遍):fold、unfold HEAD 更低,browser-open 持平,browser-close 互有高低,没看到退步。 +browser-open 剩下的主要是每次新建面板+第一次排版(`update` 里的 layoutSubtreeIfNeeded,每次约 30 ms)——同一轮显示前怎样都要付,只有预热常驻面板(拿静置内存换)或简化视图树(画面会变)能消掉。`refreshHelperMap` 对每个 App 问 isTerminated(同步 XPC,每次约 13 ms),挪到后台会让紧接着那段用旧的对照表,没做。 +既有问题(改动前的 HEAD 一样):`--notch` 的「标题变了刘海短暂展开」在 M5 上失败(MacBook 上过);`run-notch-minimal-tests`/`run-notch-token-tests` 的弹簧令牌断言失败。 From 565970f5603c6b7cb0d6bc1c456fd2a83e9f6dbb Mon Sep 17 00:00:00 2001 From: Aaron <12213433+surfine@users.noreply.github.com> Date: Sun, 29 Nov 2026 02:06:49 +0800 Subject: [PATCH 21/27] =?UTF-8?q?release:=201.0.23=EF=BC=88build=202026112?= =?UTF-8?q?9.01=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Intel 实验版第一次在真机量测后收尾:perf/intel-floor 的 20 个 unique 提交 按序 cherry-pick 进 main 之后,升版本、写发布说明,并如实改三份 README 与官网。 - 1.0.23 / 20261129.01;docs/releases/v1.0.23.md 带「一句话摘要」与「Intel 摘要」 - README 三份:Intel 从「没在真机测过」改成 MacBook10,1 实测,列出仍超预算的四类 - docs/performance.md 第九节与 perf-ledger:标明本版未在真机重跑,数字来自同一批修正的最后一次量测 - 官网事实行、问答与开发中一段同步;窗口浏览滚动条裁行修正写进说明 --- CHANGELOG.md | 1 + README.md | 6 +-- README_CN.md | 6 +-- README_TW.md | 6 +-- docs/DEVELOPMENT.md | 5 +- docs/perf-ledger.md | 1 + docs/performance.md | 2 + docs/releases/README.md | 2 +- docs/releases/v1.0.23.md | 105 +++++++++++++++++++++++++++++++++++++++ prototype/Info.plist | 4 +- site/scripts/content.mjs | 8 +-- 11 files changed, 129 insertions(+), 17 deletions(-) create mode 100644 docs/releases/v1.0.23.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 87fd2b66..71a8d7b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ One line per release. Full notes, downloads and checksums are on [GitHub Release | Version | Date | Highlights | | --- | --- | --- | +| [1.0.23](docs/releases/v1.0.23.md) | 2026-11-29 | Intel build measured on a real 2017 MacBook: Glance inside Apple's hitch budget, roll-up / unfold / window browser 2–4× cheaper but still over; the same fixes help Apple Silicon; the window browser no longer clips the last line with always-on scroll bars. / Intel 实验版首次在真机量测:看一眼进预算,收起/展开/窗口浏览快 2–4 倍但仍超;同一批修正也带回 Apple Silicon;窗口浏览不再裁掉最后一行。 | | [1.0.22](docs/releases/v1.0.22.md) | 2026-11-16 | Notch edges settled, three Stage Manager edge cases, one title-bar target rule, Bluetooth permission, four dead switches gone, shortcuts for new setups. / 刘海边界收拾干净,台前调度三处边界;标题栏目标统一、蓝牙授权、四个假开关下架、新装带回快捷键。 | | [1.0.21](docs/releases/v1.0.21.md) | 2026-11-09 | First experimental Intel build; the notch's springs and expanded shape match the macOS 27.3 system island. Beta channel only. / 首个 Intel 实验版;刘海的弹簧与展开几何对齐 macOS 27.3 系统灵动岛。只走测试频道。 | | [1.0.20](docs/releases/v1.0.20.md) | 2026-11-02 | A Features page with eight real switches, seeded from what you already use; window fixes for macOS 26 double-click, fold flash and corner parking. / 功能页与 8 个真开关,升级保持原样;修好 macOS 26 双击缩放、收起闪屏与角落停车。 | diff --git a/README.md b/README.md index c04f207c..1fcc702d 100644 --- a/README.md +++ b/README.md @@ -48,8 +48,8 @@ Unlike minimizing, the window never leaves the desktop. Drag the bar somewhere e Get the latest DMG from [Releases](https://github.com/surfine/WindowShade/releases/latest), open it, drag `WindowShade.app` onto Applications, then open it and follow the permission prompts. (The ZIP is the same app and is what in-app updates use.) It lives in the menu bar and stays out of your Dock. - **Needs macOS 15 or later.** Apple Silicon is the main build. -- **Intel Macs (experimental, from 1.0.21).** Releases also has a separate ZIP whose name ends in `-intel.zip`. It has not been tried on a real Intel Mac, only in a Rosetta smoke test, so expect rough edges. Face unlock, voiceprint and the lid-close desktop effect are off and hidden on Intel; pinned previews, Picture in Picture and everything else work the same. The Intel build updates from its own feed, so it is never offered the Apple Silicon ZIP, and Apple Silicon Macs are never offered the Intel one. If something goes wrong, please [open an issue](https://github.com/surfine/WindowShade/issues/new). -- **1.0.21 download (decimal MB):** 22.49 MB ZIP, or a 23.54 MB DMG for a first install. The experimental Intel ZIP is 11.24 MB. +- **Intel Macs (experimental, from 1.0.21).** Releases also has a separate ZIP whose name ends in `-intel.zip`. From 1.0.23 it has been measured and tuned on a real 2017 MacBook (MacBook10,1): Glance meets Apple’s hitch budget, and rolling up, unfolding and opening or closing the window browser are 2–4× cheaper than in 1.0.22. Those four are still over budget, so it stays experimental. Face unlock, voiceprint and the lid-close desktop effect are off and hidden on Intel; pinned previews, Picture in Picture and everything else work the same. The Intel build updates from its own feed, so it is never offered the Apple Silicon ZIP, and Apple Silicon Macs are never offered the Intel one. If something goes wrong, please [open an issue](https://github.com/surfine/WindowShade/issues/new). +- **Download sizes:** the [latest release](https://github.com/surfine/WindowShade/releases/latest) lists the ZIP, the DMG and the separate Intel ZIP, each with a SHA-256 file. - **Notarized by Apple.** macOS checks it on first launch, so there’s nothing to override. - **Updating from 1.0.16 or earlier:** download this one by hand, then reopen Accessibility (and Screen Recording, if you had turned it on) in System Settings → Privacy & Security. From here on, updates install from the menu. - **With Homebrew:** `brew install --cask surfine/tap/windowshade`. @@ -123,7 +123,7 @@ WindowShade changes one system setting: the Dock’s minimize effect. When it ne ## In development -The current download is **1.0.21**. Everything described above is in it; this version adds an experimental Intel package and aligns the notch’s transition springs and empty expanded width with the macOS 27.3 system island. The Intel package has not been tried on a real Intel Mac. [Release notes](docs/releases/v1.0.21.md) +The current download is **1.0.23**. Everything described above is in it. This version finishes the Intel performance pass on a real 2017 MacBook: Glance now meets Apple's hitch budget, and roll-up, unfold and the window browser are 2–4× cheaper but still over budget, which is why the Intel build stays experimental. The same fixes also make Apple Silicon unfold about twice as cheap. It also fixes the window browser clipping the last line of a document when scroll bars are always shown. [Release notes](docs/releases/v1.0.23.md) What comes next is **WindowShade 2**: your Mac’s windows taking direction, and answering to the devices at hand. The notch's new look and gestures ship in 1.0.19; the conductor, remote and coding sessions remain behind a preview switch — not shown in Settings and not running: diff --git a/README_CN.md b/README_CN.md index c1737b33..79f0ddba 100644 --- a/README_CN.md +++ b/README_CN.md @@ -48,8 +48,8 @@ 到 [Releases](https://github.com/surfine/WindowShade/releases/latest) 下载最新的 DMG,打开后把 `WindowShade.app` 拖到“应用程序”,再打开它,按提示给权限。(ZIP 是同一个 App,应用内更新用的就是它。)它住在菜单栏里,不占 Dock 位置。 - **要 macOS 15 以上。** 主力是 Apple Silicon 版。 -- **Intel Mac(实验,1.0.21 起)。** Releases 里另有一个文件名以 `-intel.zip` 结尾的 ZIP。它没有在真实的 Intel Mac 上试过,只在 Rosetta 下做过冒烟测试,难免有毛病。刷脸解锁、声纹和合盖桌面效果在 Intel 上是关的,设置里也不显示;置顶预览、画中画和其余功能照常。Intel 版从自己的更新清单取更新,不会收到 Apple Silicon 的包,Apple Silicon 的 Mac 也不会收到 Intel 的包。遇到问题,请[提一个 issue](https://github.com/surfine/WindowShade/issues/new)。 -- **1.0.21 下载包(十进制):** ZIP 22.49 MB;第一次安装也可以下 DMG(23.54 MB)。Intel 实验版 ZIP 11.24 MB。 +- **Intel Mac(实验,1.0.21 起)。** Releases 里另有一个文件名以 `-intel.zip` 结尾的 ZIP。从 1.0.23 起,它在真实的 2017 MacBook(MacBook10,1)上量过也改过:看一眼进了 Apple 卡顿预算,收起、展开与窗口浏览的开关比 1.0.22 快 2–4 倍;这四类仍超预算,所以还是实验版。刷脸解锁、声纹和合盖桌面效果在 Intel 上是关的,设置里也不显示;置顶预览、画中画和其余功能照常。Intel 版从自己的更新清单取更新,不会收到 Apple Silicon 的包,Apple Silicon 的 Mac 也不会收到 Intel 的包。遇到问题,请[提一个 issue](https://github.com/surfine/WindowShade/issues/new)。 +- **下载包大小:** [最新 Releases](https://github.com/surfine/WindowShade/releases/latest) 会列出 ZIP、DMG 和单独的 Intel ZIP,各带一份 SHA-256。 - **已通过 Apple 公证。** 第一次打开时系统会自己检查,不用再手动放行。 - **从 1.0.16 及以前升级:** 这一版要手动下载一次,装好后在“系统设置 → 隐私与安全性”里重新打开辅助功能(开过屏幕录制的,也重新打开)。之后就能在菜单里更新。 - **用 Homebrew:** `brew install --cask surfine/tap/windowshade`。 @@ -123,7 +123,7 @@ WindowShade 只改过一项系统设置:程序坞的「最小化效果」。 ## 开发中 -当前下载版是 **1.0.21**。上面写的都在里面;这一版另有 Intel 实验包,并把刘海的转场弹簧和空展开宽度对齐 macOS 27.3 的系统岛。Intel 包没有在真 Intel Mac 上试过。[发布说明](docs/releases/v1.0.21.md) +当前下载版是 **1.0.23**。上面写的都在里面。这一版在真实的 2017 MacBook 上把 Intel 实验版的性能收尾:看一眼进了 Apple 卡顿预算,收起、展开与窗口浏览快了 2–4 倍但仍超预算,所以 Intel 版仍是实验版;同一批修正也让 Apple Silicon 的展开快了一倍。另外修好窗口浏览在“始终显示滚动条”时裁掉文档最后一行的问题。[发布说明](docs/releases/v1.0.23.md) 接下来的方向是 **WindowShade 2**:让 Mac 的窗口听你指挥,也能被手边的设备遥控。刘海的新样子和新手势已在 1.0.19 里;指挥模式、遥控和编程会话仍在预览开关后面——设置里看不到,也不会运行: diff --git a/README_TW.md b/README_TW.md index f90c3a28..07cfd3e4 100644 --- a/README_TW.md +++ b/README_TW.md @@ -48,8 +48,8 @@ 到 [Releases](https://github.com/surfine/WindowShade/releases/latest) 下載最新的 DMG,開啟後把 `WindowShade.app` 拖進“應用程式”,再開啟它,按提示給權限。(ZIP 是同一個 App,應用程式內更新用的就是它。)它住在選單列裡,不佔 Dock 位置。 - **要 macOS 15 以上。** 主力是 Apple Silicon 版。 -- **Intel Mac(實驗,1.0.21 起)。** Releases 裡另有一個檔名以 `-intel.zip` 結尾的 ZIP。它沒有在真實的 Intel Mac 上試過,只在 Rosetta 下做過冒煙測試,難免有毛病。刷臉解鎖、聲紋和合蓋桌面效果在 Intel 上是關的,設定裡也不顯示;置頂預覽、畫中畫和其餘功能照常。Intel 版從自己的更新清單取更新,不會收到 Apple Silicon 的包,Apple Silicon 的 Mac 也不會收到 Intel 的包。遇到問題,請[提一個 issue](https://github.com/surfine/WindowShade/issues/new)。 -- **1.0.21 下載包(十進位):** ZIP 22.49 MB;第一次安裝也可以下 DMG(23.54 MB)。Intel 實驗版 ZIP 11.24 MB。 +- **Intel Mac(實驗,1.0.21 起)。** Releases 裡另有一個檔名以 `-intel.zip` 結尾的 ZIP。從 1.0.23 起,它在真實的 2017 MacBook(MacBook10,1)上量過也改過:看一眼進了 Apple 卡頓預算,收起、展開與視窗瀏覽的開關比 1.0.22 快 2–4 倍;這四類仍超預算,所以還是實驗版。刷臉解鎖、聲紋和合蓋桌面效果在 Intel 上是關的,設定裡也不顯示;置頂預覽、畫中畫和其餘功能照常。Intel 版從自己的更新清單取更新,不會收到 Apple Silicon 的包,Apple Silicon 的 Mac 也不會收到 Intel 的包。遇到問題,請[提一個 issue](https://github.com/surfine/WindowShade/issues/new)。 +- **下載包大小:** [最新 Releases](https://github.com/surfine/WindowShade/releases/latest) 會列出 ZIP、DMG 和單獨的 Intel ZIP,各帶一份 SHA-256。 - **已通過 Apple 公證。** 第一次開啟時系統會自己檢查,不用再手動放行。 - **從 1.0.16 及以前升級:** 這一版要手動下載一次,裝好後在“系統設定 → 隱私權與安全性”裡重新開啟輔助使用(開過螢幕錄製的,也重新開啟)。之後就能在選單裡更新。 - **用 Homebrew:** `brew install --cask surfine/tap/windowshade`。 @@ -123,7 +123,7 @@ WindowShade 只改過一項系統設定:程式塢的「最小化效果」。 ## 開發中 -目前下載版是 **1.0.21**。上面寫的都在裡面;這一版另有 Intel 實驗包,並把瀏海的轉場彈簧和空展開寬度對齊 macOS 27.3 的系統島。Intel 包沒有在真 Intel Mac 上試過。[釋出說明](docs/releases/v1.0.21.md) +目前下載版是 **1.0.23**。上面寫的都在裡面。這一版在真實的 2017 MacBook 上把 Intel 實驗版的效能收尾:看一眼進了 Apple 卡頓預算,收起、展開與視窗瀏覽快了 2–4 倍但仍超預算,所以 Intel 版仍是實驗版;同一批修正也讓 Apple Silicon 的展開快了一倍。另外修好視窗瀏覽在「永遠顯示捲動軸」時裁掉文件最後一行的問題。[釋出說明](docs/releases/v1.0.23.md) 接下來的方向是 **WindowShade 2**:讓 Mac 的視窗聽你指揮,也能被手邊的裝置遙控。瀏海的新樣子和新手勢已在 1.0.19 裡;指揮模式、遙控和程式設計工作階段仍在預覽開關後面——設定裡看不到,也不會執行: diff --git a/docs/DEVELOPMENT.md b/docs/DEVELOPMENT.md index fbed4cca..de5787de 100644 --- a/docs/DEVELOPMENT.md +++ b/docs/DEVELOPMENT.md @@ -484,7 +484,10 @@ cd prototype ### Intel 实验版(1.0.21 起) - **形态**:另一个 zip(`WindowShade-v<版本>-intel.zip`),不做 universal;arm64 的 zip、清单和它的条目(含 `hardwareRequirements: arm64`)都不动。 - Intel 版没有在真实的 Intel Mac 上测过,只做过 Rosetta 冒烟;README 三份照实写了这一点,并请用户出问题就提 issue。 + 从 1.0.23 起,Intel 版在真实的 MacBook10,1(2017 MacBook,Core m3-7Y32,macOS 26.7.3 OCLP)上实测并改过:看一眼进了 Apple 卡顿预算, + 收起、展开与窗口浏览仍超预算,数字、路径与剩余差距在 [performance.md](performance.md) 第九节和 [perf-ledger.md](perf-ledger.md)。 + 它仍属实验版,README 三份照实写这一点,并请用户出问题就提 issue。要重新量:直接 + `scripts/intel-floor.sh user@host`(编 x86_64 包、传过去、跑两遍 hitch 和静置能耗,按需记帐)。 - **更新不串**:Sparkle 的 `hardwareRequirements` 只认 `arm64`,所以 Intel 版另用 `appcast-intel.xml`。`build.sh` 按 `$ARCH` 写 `SUFeedURL` (x86_64 → `https://windowshade.aaronlau.me/appcast-intel.xml`,其余 → `appcast.xml`),官网连不上时的回退清单也按架构编译期分开(`UpdateLinks.fallbackFeed`)。 发布关第 7、8 步按架构各核一遍。 diff --git a/docs/perf-ledger.md b/docs/perf-ledger.md index b0c82ead..513cb543 100644 --- a/docs/perf-ledger.md +++ b/docs/perf-ledger.md @@ -10,6 +10,7 @@ - Intel 真机用 `scripts/intel-floor.sh user@host`(编 x86_64 包、传过去、跑两遍 hitch 和静置能耗,各记一行)。 - 2026-11-23 起的 MacBook10,1 行:那台机器开着「减少动态效果」(`com.apple.universalaccess reduceMotion = 1`),收起不播 Metal 卷帘、没有 present-* 两类;探针单窗口 fixture 第 1 轮之后都走最小化(focus handoff 判 stay-minimize)。和 11-22 那两行不是同一条路径,不能直接比。同一次的静置能耗:CPU 中位 0.07%、phys_footprint 29–31 MB。 - 2026-11-23 的 M5 browser-open 比 11-23 早先那两行高一倍(455–460 vs 196–226 ms/s):同一台机器,原因未查证,可能是当时桌面上开着的 App 与窗口不同(新尺下 refreshPanel 每次打开 17 次)。比较时只和同一天、同一桌面状态的基线比。 +- **1.0.23(build 20261129.01)没有在 MacBook10,1 或 M5 上重跑。** 下表 2026-11-23 的最后两行(`53c3d5d49`)是同一批 Intel 修正最后一次真机量测,构建号仍是 20261116.01;合入 main 时还带进了 main 上的窗口浏览滚动条修正,所以不能把任何一行当成本版的数字。要记 1.0.23 的帐,用 `scripts/intel-floor.sh user@host`(MacBook)或 `scripts/perf-report.sh --host`(本机)重新跑。 | 日期 | 版本 (build) 提交 | 机器 | 刷新率 | 对照预算 | 各类 ratio/worst | | --- | --- | --- | --- | --- | --- | diff --git a/docs/performance.md b/docs/performance.md index f83206f6..8745efc4 100644 --- a/docs/performance.md +++ b/docs/performance.md @@ -616,3 +616,5 @@ Apple Silicon 上全绿(含自检);唯一的架构阻塞点(卡顿采样 M5 这段时间被别的任务占着(load 5),绝对数不准,改做同一时段 A/B(3fd9b1c8 对 HEAD,交替各两遍):fold、unfold HEAD 更低,browser-open 持平,browser-close 互有高低,没看到退步。 browser-open 剩下的主要是每次新建面板+第一次排版(`update` 里的 layoutSubtreeIfNeeded,每次约 30 ms)——同一轮显示前怎样都要付,只有预热常驻面板(拿静置内存换)或简化视图树(画面会变)能消掉。`refreshHelperMap` 对每个 App 问 isTerminated(同步 XPC,每次约 13 ms),挪到后台会让紧接着那段用旧的对照表,没做。 既有问题(改动前的 HEAD 一样):`--notch` 的「标题变了刘海短暂展开」在 M5 上失败(MacBook 上过);`run-notch-minimal-tests`/`run-notch-token-tests` 的弹簧令牌断言失败。 + +**2026-11-29:1.0.23 首发。** 这一节的 20 个提交按序 cherry-pick 进 main 的 `integrate/1.0.23-intel`,没有手工解冲突(窗口浏览那两处自动合并后逐行核过 main 的「始终显示滚动条」修正仍在)。到首发时 MacBook10,1 不在线(SSH 192.168.5.21 超时),**1.0.23 这个 build 没有真机数字**;发布说明和卡顿账里引用的是上表 `53c3d5d49` 那次量测,构建号 20261116.01,且不含 main 带进来的滚动条修正。要看 1.0.23 自己的一行,等机器回来跑 `scripts/intel-floor.sh user@host`。 diff --git a/docs/releases/README.md b/docs/releases/README.md index e2e00150..d457517c 100644 --- a/docs/releases/README.md +++ b/docs/releases/README.md @@ -5,7 +5,7 @@ ## 候选(未发布) -(暂无) +- [v1.0.23.md](v1.0.23.md):Intel 实验版真机收尾(看一眼进预算,收起/展开/窗口浏览仍超,数字与差距写在说明里);窗口浏览“始终显示滚动条”时不再裁掉最后一行。build `20261129.01`。 ## 已发布 diff --git a/docs/releases/v1.0.23.md b/docs/releases/v1.0.23.md new file mode 100644 index 00000000..b7e3d95b --- /dev/null +++ b/docs/releases/v1.0.23.md @@ -0,0 +1,105 @@ +# WindowShade 1.0.23(build 20261129.01) + +2026-11-29 构建,build 沿用日期制 `20261129.01`。这一版是 Intel 实验版第一次在真实机器上量完再改的收尾版,同时把同一批主线程修正带回 Apple Silicon。 + +## 中文 + +### 一句话摘要(appcast 用) + +Intel 实验版第一次在真实的 2017 MacBook 上完整量过并收了一批卡顿:收起从 506–519 降到 131–133 ms/s,展开从 594–604 降到 119–170,窗口浏览关闭从 13–20 降到 7.1–7.4,看一眼从 4–10 降到 1.9 并进入 Apple 卡顿预算;窗口浏览打开从 412–414 降到 352–356。收起、展开、窗口浏览开关四类仍超预算,所以 Intel 版继续标实验版,数字与差距都写在下面的表里。同一批修正让 Apple Silicon 的展开从 35–45 降到 20.6–24.0 ms/s,其余没有退步。另外修好窗口浏览在“始终显示滚动条”时把文档最后一行裁掉的问题。 + +### Intel 摘要(appcast 用) + +Intel 实验版在 2017 MacBook(MacBook10,1,Core m3-7Y32)上实测并修正:收起 506–519 → 131–133 ms/s,展开 594–604 → 119–170,窗口浏览关闭 13–20 → 7.1–7.4,看一眼 4–10 → 1.9(这一类进了 Apple 卡顿预算);窗口浏览打开 412–414 → 352–356,仍超预算。收起、展开、窗口浏览开关四类的最坏一次仍高于 100 ms 的门槛,差距与原因是硬件与系统 IPC 的结构性成本,见 release notes。本版构建没有在真机上重跑,表里的数字是同一批修正最后一次真机量测。 + +### 这一版改了什么 + +Intel 与主线程: + +- **窗口浏览打开:** 每个 App 的探查结果合并成一次 `refreshPanel`(每次打开 17 → 3 次),右键菜单改成右键当下才生成。MacBook 上 412–414 → 350–356 ms/s。 +- **收起:** “被别人揭开”的 AX 通知注册移到后台串行队列;藏没藏住的验证改成后台读 AX、回主线程判定。MacBook 上 506–519 → 131–133 ms/s(p95 227–264 → 74–77)。 +- **展开:** 带到前台的 raise/focus 改从串行 AX 队列发出;展开验证的 50 ms 轮询在后台读 AX/CG;展开后 80/250/550/1100 ms 的几何校正与刘海标题监看的通知注册也移出主线程。MacBook 上 594–604 → 119–170 ms/s(p95 175–181 → 33–34),每次展开的卡顿总时间 263 → 150–175 ms。 +- **看一眼:** 出现时的背景合成在后台截,截完回主线程接着打开。M5 上 40–59 → 2.7–4.0 ms/s;MacBook 走最小化路径,本来就不经过这一步。 +- **窗口浏览关闭:** 淡出结束后把 `close` 拆到下一轮 runloop。MacBook 13–20 → 7.1–7.4 ms/s,M5 37–59 → 0–11。 +- **窗口浏览页脚:** “打开屏幕录制设置”按钮第一次要露出时才建(`NSButton(title:)` 在 macOS 26 上每次约 34 ms),`Panel.init` 每次约 56 → 11 ms。 + +MacBook10,1 实测(两遍,`--hitch` 20 轮/类,60 Hz;减少动态效果开、画面效果关,也就是 Intel 用户的默认路径): + +| 交互 | 修正前 (ms/s / worst ms) | 修正后 (ms/s / worst ms) | Apple 预算 | +| --- | --- | --- | --- | +| fold | 507–514 / 300–382 | 131–133 / 165–219 | 仍超:ratio 与 worst | +| unfold | 598–605 / 292–302 | 119–170 / 51–283 | 仍超:ratio(worst 两遍不一致) | +| browser-open | 412–414 / 412–447 | 352–356 / 301–370 | 仍超:ratio 与 worst | +| browser-close | 21–26 / 45–47 | 7.1–7.4 / 35–36 | 仍超:ratio | +| glance-show | 7.7–11.5 / 33 | 1.9 / 33 | 进预算 | +| glance-hide | 6.8–7.5 / 24–25 | 0.5 / 17 | 进预算 | + +同一批修正对 Apple Silicon 也有收益:M5 上窗口浏览打开 455–460 → 178–193(同一桌面状态 319–320 → 187–191),展开 35–45 → 20.6–24.0。第二轮改动做了同时段 A/B(3fd9b1c8 对 HEAD,交替各两遍):fold、unfold 更低,browser-open 持平,browser-close 互有高低,没有看到退步。 + +剩下的差距是真机上的结构成本,不是漏掉一步: + +- 慢机的大头是主线程对一个正在最小化/恢复的目标 App 发同步 AX IPC;挪走一个等待会转到下一个同步调用,只能整条链一起挪,这一版已经把能量到的链挪完。 +- 窗口浏览打开剩余的是每次新建面板加第一次排版(`update` 里的 `layoutSubtreeIfNeeded`,每次约 30 ms),显示前无论如何都要付;再省只能预热常驻面板(拿静置内存换)或简化视图树(画面会变)。 +- `refreshHelperMap` 对每个 App 问 `isTerminated`(同步 XPC,每次约 13 ms),挪到后台会让紧接着那段用旧对照表,没有做。 +- 展开开头的 `windowID(of:)`(这台机器约 170 ms)换成已知窗号会改 token 守卫语义,挪到后台会让 activate 晚约 170 ms,两样都不是帕累托。 +- 本版构建(`20261129.01`)没有在 MacBook10,1 上重跑;上表是同一批修正最后一次真机量测(`20261116.01`,perf/intel-floor `53c3d5d49`)。要拿 1.0.23 的包重新记帐,仍然用 `scripts/intel-floor.sh`。 + +窗口浏览: + +- **“始终显示滚动条”时不再裁掉文档最后一行。** 文档宽度跟随滚动视图的内容宽度,而不是反过来让内容缩进滚动条里;开着系统“始终显示滚动条”时最后一行不再被切掉。 + +### 需要 macOS 15 或更新版本。 + +### 已知 + +- **Intel 实验版仍属实验版**:MacBook10,1 上六类交互只有看一眼进了 Apple 卡顿预算,收起、展开、窗口浏览打开与关闭仍超;原因与剩余差距见上表。 +- 本版没有在真 Intel Mac 上重新跑卡顿表;上表来自同一批修正的最后一次真机量测,构建号不同。 +- 键盘面板预热(拿静置内存换)和收起/展开的写盘移出主线程没有做,前者要人决定取舍,后者是崩溃恢复顺序的语义改动。 +- `tests/run-duo-tests.sh` 的弹簧断言在 main 上就失败(在门禁排除表里),这一版没有改变它;FoldVerifier 的新用例放在 `tests/run-fold-verifier-tests.sh`。 +- 既有问题:`--notch` 的“标题变了刘海短暂展开”在 M5 上失败(MacBook 上过);`run-notch-minimal-tests`/`run-notch-token-tests` 的弹簧令牌断言失败。 + +## English + +### Summary (for appcast) + +The Intel build has been measured and tuned on a real 2017 MacBook for the first time: roll-up drops from 506–519 to 131–133 ms/s, unfold from 594–604 to 119–170, window-browser close from 13–20 to 7.1–7.4, and Glance from 4–10 to 1.9, which lands inside Apple's hitch budget; window-browser open drops from 412–414 to 352–356. Roll-up, unfold and both browser directions are still over budget, so the Intel build stays experimental and the numbers and gaps are in the table below. The same changes take Apple Silicon unfold from 35–45 to 20.6–24.0 ms/s with no regression elsewhere. Also fixes the window browser cutting off the last line of a document when scroll bars are always shown. + +### What changed + +Intel and the main thread: + +- **Window browser open:** each app's probe results are merged into one `refreshPanel` (17 → 3 per open) and the context menu is built on right-click. 412–414 → 350–356 ms/s on the MacBook. +- **Roll-up:** the "revealed by someone else" AX notification registration moved to a background serial queue; the hidden-or-not verification reads AX in the background and decides on the main thread. 506–519 → 131–133 ms/s (p95 227–264 → 74–77). +- **Unfold:** the raise and focus that bring the window forward are sent from a serial AX queue; the 50 ms restore-verification poll reads AX/CG in the background; the geometry corrections at 80/250/550/1100 ms after unfold and the notch title watcher registration also left the main thread. 594–604 → 119–170 ms/s (p95 175–181 → 33–34); total hitch time per unfold 263 → 150–175 ms. +- **Glance:** the background composite is captured off the main thread and the panel opens on the main thread when it lands. 40–59 → 2.7–4.0 ms/s on the M5; the MacBook takes the minimize path and never reaches this step. +- **Window browser close:** `close` is deferred to the next runloop turn after the fade-out. 13–20 → 7.1–7.4 ms/s on the MacBook, 37–59 → 0–11 on the M5. +- **Window browser footer:** the "open Screen Recording settings" button is created the first time it is needed (`NSButton(title:)` costs about 34 ms on macOS 26); `Panel.init` drops from about 56 to 11 ms. + +MacBook10,1 measurement (two runs, `--hitch` 20 per kind, 60 Hz; Reduce Motion on, visual effects off — the default Intel path): + +| Interaction | Before (ms/s / worst ms) | After (ms/s / worst ms) | Apple budget | +| --- | --- | --- | --- | +| fold | 507–514 / 300–382 | 131–133 / 165–219 | over: ratio and worst | +| unfold | 598–605 / 292–302 | 119–170 / 51–283 | over: ratio (worst differs between runs) | +| browser-open | 412–414 / 412–447 | 352–356 / 301–370 | over: ratio and worst | +| browser-close | 21–26 / 45–47 | 7.1–7.4 / 35–36 | over: ratio | +| glance-show | 7.7–11.5 / 33 | 1.9 / 33 | within budget | +| glance-hide | 6.8–7.5 / 24–25 | 0.5 / 17 | within budget | + +The same changes help Apple Silicon: browser open 455–460 → 178–193 (same desktop state 319–320 → 187–191), unfold 35–45 → 20.6–24.0 on the M5. The second round was A/B-checked against 3fd9b1c8 in the same session (two alternating runs each): fold and unfold lower, browser-open flat, browser-close mixed, no regression seen. + +The remaining gap is structural cost on the real machine, not a skipped step: the dominant cost is synchronous AX IPC from the main thread to an app that is busy minimizing or restoring; moving one wait just transfers it to the next call, so the chain has to move together, and this release moves every chain that could be measured. The rest of browser-open is panel creation plus first layout (about 30 ms), paid before anything can be shown. This build was not re-measured on the MacBook; the table is the last real-hardware run of the same set of changes. + +Window browser: + +- **The last line of a document is no longer cut off when scroll bars are always shown.** The document width follows the scroll view's content width instead of the content shrinking under the scroll bar. + +### Requires macOS 15 or later. + +### Known + +- The Intel build is still experimental: only Glance is inside Apple's hitch budget on the MacBook10,1; roll-up, unfold and both browser directions are still over. +- This build was not re-measured on a real Intel Mac; the table comes from the last real-hardware run of the same changes, on a different build number. +- Keyboard-panel prewarming (trading idle memory) and moving the roll-up/unfold disk writes off the main thread are not done: the first needs a product call, the second changes crash-recovery ordering. +- `tests/run-duo-tests.sh`'s spring assertion already failed on main and is in the gate exclusion table; the new FoldVerifier cases live in `tests/run-fold-verifier-tests.sh`. +- Known issues carried over: the `--notch` "title change briefly expands the notch" probe fails on the M5 (passes on the MacBook); the spring-token assertions in `run-notch-minimal-tests` / `run-notch-token-tests` fail. diff --git a/prototype/Info.plist b/prototype/Info.plist index 9c192421..95868eb5 100644 --- a/prototype/Info.plist +++ b/prototype/Info.plist @@ -15,9 +15,9 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0.22.1 + 1.0.23 CFBundleVersion - 20261116.01 + 20261129.01 LSMinimumSystemVersion 15.0 LSUIElement diff --git a/site/scripts/content.mjs b/site/scripts/content.mjs index 2b396de0..eb6ba986 100644 --- a/site/scripts/content.mjs +++ b/site/scripts/content.mjs @@ -32,7 +32,7 @@ export const copy = { intro: '双击标题栏,窗口收成一条卷帘条,停在原处。
再双击,它原样回来。', try: '先看看怎么用', video: '看介绍视频', - facts: ['macOS 15 及以上', 'Apple Silicon;Intel 实验版', '免费,MIT 开源', '简体、繁體与英文界面', '1.0.22 版,ZIP 22.49 MB'], + facts: ['macOS 15 及以上', 'Apple Silicon;Intel 实验版', '免费,MIT 开源', '简体、繁體与英文界面', '1.0.23 版'], stageLabel: '网页示意:一张 Mac 桌面,上面有两扇窗口', stageMenu: ['文本编辑', '文件', '编辑', '格式', '显示', '窗口'], @@ -218,7 +218,7 @@ export const copy = { faqTitle: '下载之前,你可能会问', faqs: [ - ['我的 Mac 能用吗?', '要 macOS 15 以上。Apple Silicon 用主下载包。Intel 从 1.0.21 起有单独的实验包。它只在 Rosetta 下跑过基本测试,没在真 Intel Mac 上试过。刷脸解锁、声纹和合盖效果在 Intel 上关闭。还在 macOS 14 的,继续用 1.0.16。收起、看一眼和手势都不用特别的硬件;合盖效果需要带铰链传感器的 MacBook。'], + ['我的 Mac 能用吗?', '要 macOS 15 以上。Apple Silicon 用主下载包。Intel 从 1.0.21 起有单独的实验包。1.0.23 起在 2017 MacBook 上实测过:看一眼进了卡顿预算,收起、展开与窗口浏览仍超预算,属实验版。刷脸解锁、声纹和合盖效果在 Intel 上关闭。还在 macOS 14 的,继续用 1.0.16。收起、看一眼和手势都不用特别的硬件;合盖效果需要带铰链传感器的 MacBook。'], ['要什么权限?', '两项,一项必需、一项可选。辅助功能(必需):找到、移动、恢复窗口。屏幕录制(可选):开了,看一眼、窗口浏览和置顶预览里能看到窗口的实时画面;不开也能用,预览会改成图标和标题。“屏幕录制”只是系统给这个权限起的名字,画面不会离开你的电脑。用着用着辅助功能被关掉了,它会提醒你。'], ['看一眼和手势会动我的窗口吗?', '看一眼不会。手势只在你松手、而且小浮窗的进度条走满时才动窗口;往回拉就取消。'], ['窗口浏览会动我的窗口吗?', '不会,除非你按下卡片上的按钮。动手之前,它还会再确认一次“就是这一扇窗口”,确认不了就不做。'], @@ -252,7 +252,7 @@ export const copy = { intro: 'Double-click a title bar and the window rolls up into a thin bar, right where it was. Double-click again and it’s back.', try: 'See how it works', video: 'Watch the intro (in Chinese)', - facts: ['macOS 15 or later', 'Apple Silicon; Intel experimental', 'Free, MIT licensed', 'Simplified, Traditional and English', 'Version 1.0.22, ZIP 22.49 MB'], + facts: ['macOS 15 or later', 'Apple Silicon; Intel experimental', 'Free, MIT licensed', 'Simplified, Traditional and English', 'Version 1.0.23'], stageLabel: 'Web illustration: a Mac desktop with two windows', stageMenu: ['TextEdit', 'File', 'Edit', 'Format', 'View', 'Window'], @@ -438,7 +438,7 @@ export const copy = { faqTitle: 'Before you download', faqs: [ - ['Will it work on my Mac?', 'You need macOS 15 or later. Apple Silicon uses the main download. From 1.0.21, Intel has its own experimental package. It has only had a basic test under Rosetta, not on a real Intel Mac. Face unlock, voiceprint and the lid effect are off on Intel. If you’re still on macOS 14, stay on 1.0.16. Rolling up, Glance and the title-bar gestures don’t need any special hardware. The lid-following desktop effect needs a MacBook with a hinge sensor.'], + ['Will it work on my Mac?', 'You need macOS 15 or later. Apple Silicon uses the main download. From 1.0.21, Intel has its own experimental package. Since 1.0.23 it has been measured on a 2017 MacBook: Glance is inside the budget, while roll-up, unfold and the window browser are still over, so it stays experimental. Face unlock, voiceprint and the lid effect are off on Intel. If you’re still on macOS 14, stay on 1.0.16. Rolling up, Glance and the title-bar gestures don’t need any special hardware. The lid-following desktop effect needs a MacBook with a hinge sensor.'], ['What permissions does it need?', 'Two: one required, one optional. Accessibility (required): finding, moving and restoring windows. Screen Recording (optional): turn it on to see live window pictures in Glance, in window browsing and in pinned previews; leave it off and WindowShade still works, with previews showing icons and titles instead. “Screen Recording” is just the name the system gives that permission. Nothing leaves your Mac. If Accessibility gets turned off while the app is running, it tells you.'], ['Do glances and gestures move my windows?', 'A glance never does. A gesture moves a window only when you let go with the panel’s track full; pull back to cancel.'], ['Can I use the notch without a notch?', 'Yes. On an external display there’s an invisible notch in the middle of the menu bar: it stays out of sight until a window is tucked into it, and flicking toward it works the same.'], From 5d5bc891215bce9e0fc26ed17748e8edbe974722 Mon Sep 17 00:00:00 2001 From: Aaron <12213433+surfine@users.noreply.github.com> Date: Sun, 29 Nov 2026 02:06:49 +0800 Subject: [PATCH 22/27] =?UTF-8?q?assets:=20DMG=20=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E7=9A=84=20Finder=20=E6=8E=92=E7=89=88?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit scripts/make-dmg.sh --capture-template 生成:图标 128、字号 13、不自动排列, WindowShade.app 在 (170,190)、Applications 在 (490,190),背景指向 .background/background.tiff。 模板只存 Finder 版面,与版本无关。本机钥匙串没有 Developer ID 私钥,捕获前把已有的 已签名 .build/release 包(1.0.22.1)送公证并钉票据,再按脚本原文捕获。 --- assets/dmg/DS_Store | Bin 0 -> 10244 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 assets/dmg/DS_Store diff --git a/assets/dmg/DS_Store b/assets/dmg/DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..2d7b746236ed84fe3c15e627d33293bb0a4237c1 GIT binary patch literal 10244 zcmeHMU2GIp6h6~V>DHF+wgm+xW|Cq8N;}hbS=yC^?RJYLh*h@{2w>Tt*=6nQ%rZM| zK_DrKe^DM#dCSvOu3?D@Lj6tZE$; z1QrM^5Lh6vKwyEu0{;dJ;LK(Ub$T*L0}BKe2rRH-0gev}m}Nr9B~QAc1Bv?tfRs_} z5^#h8q#|TO$R$sr1|)f1A-%4Wcw$Iica$rlT|&quPkP-+5|0l_%q)o)isa6Y@fEi@ zNeNE|X<&iC0;?_Hz1;`1i`7cjsDHm}+BZ^5tK7Dxy}hHov;9c=n6;R8GR}N8nXwOX zZpN~VtdBFgp-@L?HnQQ= zsbNjqrfeVGab}xxDi#BdYTB7Iq0st%_2DOH=Zvyxz3eSs5&?kLHYxK8@)8Y}atlHe z`Frn|2u-^d2@7399d~tht?dp+dV2dJ>muvd-+j-9jT`Tqjr3(Rxw)dvE1a+l%T5~e z`hil;GSj7Jb*NRV-c!yL^>L$=sUC3j6OLEkTdQ}wKdI-Rt`*IktTc|{wt2+Xb@Ncs zF6E~Sg{tlxsKW;jS7G5jj$Ynl7OdGw?*gnlU2#g5S$#^ktB?mXww*DHdh+BEBa_vQ zX)|d#j#ZwGgx$Va`{TCG{oHZWl}xT=7W;SI@a)!~IO>7vp4MSTND)&zJy)fVW%9aL zUrU#VM&F%!h}uwcJY3Um&?yxPwN`%{*%GV$!gMcn(LUFM>>&pps=_}CO;HN| z*>{J`@2{YbB$Zfy=KjQko(Uo?{k|wF}nG-Fz(-qF#YI4DX&w3T*YeY05S89GOA z(}(maU8ZkonSPeqr9Nqs^niRw&dUYak}L9A`33n!+4VdwTYl)<)Hsj)D)I<@m1I&A zLHrkK4UvN{b?Fv-uCDG9hWHiU681Uybz;AxxmRbzi0&8o z)*k>b-|I62*)4G6H-WW?a*hoAdguA;f|2VzE^7`-TevN30jH4y-Ui+Yo&s0Er@ITJOf=Si-|cM!zy0;5{EtofH`mIn>dJh=$t(HeTnX~W zv%M^BfnVvk z4vbF5CI`k+lM^E&lcU;Xa>UnB7kd8GSJRhu_4oEgD9@h>kL!m#h4X*0Uw**2zF%6q zJwN*WZsnKF*jEjDeR263=j-jv|B>SL)E{^LTy#GB`ZDTkV?6fd=Swx)XsOBMcvRax zFf^)Z1JQA9XdpQ}f@E~Z#7Js9HXPkP=G*2h&jW6@4VUr!D&+fMj*x68Ccb}iguLl` z$cvCs{xCt!5%RDoZ&A=*;5J~xZx4K0;2z+Q1m>uCUSN)j7X?;;uL`UI-{ggY>LcM^ z*ViAo@WJPE+4bH9J@e>_6up-G%T~|<`4*I z9KozY2JUS++z$9QXW@QO-D6leaX!Lt(si`|49c)ROyNJd=?!8GjMvzkK4|Lg4iO}Q z1^zo0@Pi2-?UM)|9Bl&%ED%`W|78J5PNh>x=qzp#tF-4EjsiXkX5w~Bo^-n)aW6rT zd_r@EZ)IB;qfBGT1e_3Z$&)An{p0@(xUHXG{L66g{`b7K>UMiYl#>#?|FM~2jsL*= F|99nA?GgY0 literal 0 HcmV?d00001 From 21f9a4c52fd7215cf45d0bde2ce635d56421a0e2 Mon Sep 17 00:00:00 2001 From: Aaron <12213433+surfine@users.noreply.github.com> Date: Sun, 29 Nov 2026 02:49:15 +0800 Subject: [PATCH 23/27] =?UTF-8?q?docs(copy):=20=E6=95=B4=E9=A1=BF=E4=B8=89?= =?UTF-8?q?=E8=AF=AD=20README=20=E4=B8=8E=E5=AE=98=E7=BD=91=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=96=87=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 27 +++++++++++++++++---------- README_CN.md | 29 ++++++++++++++++++----------- README_TW.md | 35 +++++++++++++++++++++-------------- site/scripts/content.mjs | 22 +++++++++++----------- site/scripts/zh-hant.json | 12 ++++++------ 5 files changed, 73 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index 1fcc702d..c07c3ced 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Unlike minimizing, the window never leaves the desktop. Drag the bar somewhere e Get the latest DMG from [Releases](https://github.com/surfine/WindowShade/releases/latest), open it, drag `WindowShade.app` onto Applications, then open it and follow the permission prompts. (The ZIP is the same app and is what in-app updates use.) It lives in the menu bar and stays out of your Dock. - **Needs macOS 15 or later.** Apple Silicon is the main build. -- **Intel Macs (experimental, from 1.0.21).** Releases also has a separate ZIP whose name ends in `-intel.zip`. From 1.0.23 it has been measured and tuned on a real 2017 MacBook (MacBook10,1): Glance meets Apple’s hitch budget, and rolling up, unfolding and opening or closing the window browser are 2–4× cheaper than in 1.0.22. Those four are still over budget, so it stays experimental. Face unlock, voiceprint and the lid-close desktop effect are off and hidden on Intel; pinned previews, Picture in Picture and everything else work the same. The Intel build updates from its own feed, so it is never offered the Apple Silicon ZIP, and Apple Silicon Macs are never offered the Intel one. If something goes wrong, please [open an issue](https://github.com/surfine/WindowShade/issues/new). +- **Intel Macs (experimental, from 1.0.21).** Releases also has a separate `-intel.zip` download. From 1.0.23, it has been measured and tuned on a real 2017 MacBook (MacBook10,1): Glance meets Apple’s smoothness target (hitch budget). Rolling up, unfolding, and opening or closing the window browser are 2–4× faster than in 1.0.22, though those four still exceed the budget, so the Intel build stays experimental. Face unlock, voiceprint and the lid-close desktop effect are off and hidden on Intel; pinned previews, Picture in Picture and everything else work the same. The Intel build uses its own update feed and never mixes with Apple Silicon builds. If something goes wrong, please [open an issue](https://github.com/surfine/WindowShade/issues/new). - **Download sizes:** the [latest release](https://github.com/surfine/WindowShade/releases/latest) lists the ZIP, the DMG and the separate Intel ZIP, each with a SHA-256 file. - **Notarized by Apple.** macOS checks it on first launch, so there’s nothing to override. - **Updating from 1.0.16 or earlier:** download this one by hand, then reopen Accessibility (and Screen Recording, if you had turned it on) in System Settings → Privacy & Security. From here on, updates install from the menu. @@ -59,13 +59,18 @@ Get the latest DMG from [Releases](https://github.com/surfine/WindowShade/releas **Roll up.** Double-click a title bar or press `⌃⌘C` and the window rolls up into a thin bar; double-click the bar to unroll it. The bar can keep the window’s own look, or use one consistent title bar. While a bar is in front, `⌘W`, `⌘M`, `⌘H`, `⌘Q` and `⌘N` go to the window and app behind it; `⌘Q` puts the window back down first, so any “save changes?” question is where you can see it. -**Title-bar gestures.** Put the pointer on a title bar and swipe with two fingers: push up to roll up, pull down to fill the screen between the menu bar and the Dock, push up again to put it back. Nothing happens until you let go, so pulling back halfway undoes it, and a panel styled like the system volume indicator says what letting go will do. Swipe sideways for half the screen; keep swiping the same way for two thirds, then one third, and once more moves the window to the display on that side. Turn down or up after a sideways swipe to take that corner. Spreading two fingers also fills the screen, and pinching undoes the last placement. Drag a title bar, throw it and let go, and the window glides the way you threw it — up rolls up, down fills, the sides walk the same steps, and a throw aimed at a corner takes it. With an ordinary mouse, three notches of the wheel on a title bar count as one swipe; Magic Mouse support is still being checked on real hardware. Details are in the [gesture notes](docs/gestures.md). +**Title-bar gestures.** Put the pointer on a title bar and swipe with two fingers: +- Push up to roll up, pull down to fill the screen between the menu bar and the Dock, and push up again to restore. Nothing happens until you let go, so pulling back halfway cancels it; an indicator styled like the system volume HUD shows what letting go will do. +- Swipe sideways for half the screen; keep swiping the same way for two thirds, then one third, and once more to move to the adjacent display. Turn down or up after a sideways swipe to take that corner. Spread two fingers to fill the screen, and pinch to undo the last placement. +- Drag a title bar, flick it and let go to send the window that way: up rolls up, down fills, sideways walks the same steps, and a flick toward a corner takes it. With an ordinary mouse, three wheel notches on a title bar count as one swipe; Magic Mouse support is still being checked on real hardware. Details are in the [gesture notes](docs/gestures.md). **Glance.** Rest the pointer on the bar and a card drops down beneath it, showing the window's content at its own size; move away and it rolls back up. Click the card to unroll the window for real; on a Force Touch trackpad, pressing firmly on the bar also glances, and letting go puts it away. The bar stays put and the card hangs just below it, so it reads as a preview, not the window itself. A glance never switches the app you’re in and never moves a window. A window that was minimized when it rolled up can’t be shown live, so you see how it looked then, and the corner says so. Details are in the [glance notes](docs/glance.md). **Carry and pin.** Press `⌃⌘G` to carry the current window to every desktop: it stays where it is, and its bar appears in the top-right corner of your other desktops. Rest on the bar for a live picture — if the window is hidden or minimized, a labelled snapshot appears instead — and click it to go there; press `⌃⌘G` again to put it down. Press `⌃⌘P` to pin a window, so it stays uncovered while you switch to anything else; the menu bar lists every pinned window and can unpin them all at once. -**Window browsing.** Rest the pointer on an app’s icon in the Dock and every window that app has open is listed, each with a picture and a title. The panel is for looking: a window changes only when you press a button on its card; Space gives a large preview without bringing the window forward; placement shows where the window will go and moves it only when you agree, and you can undo afterwards. You can also open it from Choose window… in the menu bar, or with a hot key you set — the Dock entry is on by default and can be switched off in Settings. The panel is temporary: it does not replace the Dock or take over Command-Tab. Details are in the [window browsing notes](docs/window-browser.md). +**Window browsing.** Rest the pointer on an app’s icon in the Dock to list every window that app has open, each with a picture and a title. The panel is for looking: a window changes only when you press a button on its card, and Space gives a large preview without bringing the window forward. Placement previews where the window will go and moves it only when you agree, and you can undo afterwards. + +You can also open it from Choose window… in the menu bar, or with a hot key you set (the Dock entry is on by default and can be switched off in Settings). The panel is temporary: it does not replace the Dock or take over Command-Tab. Details are in the [window browsing notes](docs/window-browser.md). **Launchpad.** Record a shortcut (for example `⌃⌘L`) to open the Home grid: every app, with the App Library on the last page. Drag an icon to a screen edge for Slide Over, with a split handle. It opens even when the notch is off. Details are in the [Launchpad notes](docs/launchpad.md). @@ -104,7 +109,9 @@ Double-click a title bar to roll up; double-click the bar to unroll. ## Your windows stay on your Mac -WindowShade asks for two permissions: one required, one optional. **Accessibility** (required; called Device Control and Data Access in System Settings from macOS 27): finding, moving and restoring windows. **Screen Recording** (optional): turn it on to see live window pictures in Glance, in window browsing and in pinned previews; leave it off and WindowShade still works, with previews showing icons and titles instead. “Screen Recording” is just the name the system gives that permission — everything is processed on your Mac and nothing is uploaded. If the app ever quits unexpectedly, your windows go back to how they were. WindowShade collects no usage data and does no analytics or reporting; checking for updates goes online. Everything it reads is listed under Privacy in Settings and on the [privacy page](https://windowshade.aaronlau.me/privacy/). +WindowShade asks for two permissions: one required, one optional. **Accessibility** (required; called Device Control and Data Access in System Settings from macOS 27) lets it find, move and restore windows. **Screen Recording** (optional) lets you see live window pictures in Glance, window browsing and pinned previews; leave it off and WindowShade still works, showing icons and titles instead. “Screen Recording” is just the system name for that permission; everything stays on your Mac and nothing is uploaded. + +If the app ever quits unexpectedly, your windows go back to how they were. WindowShade collects no usage data and does no analytics or reporting; checking for updates is the only time it goes online. Everything it reads is listed under Privacy in Settings and on the [privacy page](https://windowshade.aaronlau.me/privacy/). Regular windows all roll up. Stickies rolls up in its own system way; apps like Adobe’s that draw their own title bars are handled separately. Full screen, Split View, Stage Manager and multiple displays still have a few gaps — try it once with the apps you use. If something goes wrong, please [report it](https://github.com/surfine/WindowShade/issues) with your macOS version, the app, and the steps. @@ -123,14 +130,14 @@ WindowShade changes one system setting: the Dock’s minimize effect. When it ne ## In development -The current download is **1.0.23**. Everything described above is in it. This version finishes the Intel performance pass on a real 2017 MacBook: Glance now meets Apple's hitch budget, and roll-up, unfold and the window browser are 2–4× cheaper but still over budget, which is why the Intel build stays experimental. The same fixes also make Apple Silicon unfold about twice as cheap. It also fixes the window browser clipping the last line of a document when scroll bars are always shown. [Release notes](docs/releases/v1.0.23.md) +The current download is **1.0.23**, and everything described above is in it. This version finishes the Intel performance pass on a real 2017 MacBook: Glance now meets Apple’s smoothness target (hitch budget), and roll-up, unfold and the window browser are 2–4× faster but still over budget, so the Intel build stays experimental. The same fixes also make Apple Silicon unfold about twice as fast. It also fixes the window browser clipping the last line of a document when scroll bars are always shown. [Release notes](docs/releases/v1.0.23.md) -What comes next is **WindowShade 2**: your Mac’s windows taking direction, and answering to the devices at hand. The notch's new look and gestures ship in 1.0.19; the conductor, remote and coding sessions remain behind a preview switch — not shown in Settings and not running: +What comes next is **WindowShade 2**: your Mac’s windows taking direction, and answering to the devices at hand. The notch’s new look and gestures ship in 1.0.19; the conductor, remote and coding sessions remain behind a preview switch, not shown in Settings and not running: -- **Conductor mode and coding sessions** — the state and approvals of several coding sessions in one place. -- **Remote control** — drive this Mac from an iPhone or similar device, including mute control. -- **CarPlay reception** — put the iPhone’s picture on the whole screen. -- **Mouse and trackpad** — finer settings such as side buttons. +- **Conductor mode and coding sessions**: the state and approvals of several coding sessions in one place. +- **Remote control**: drive this Mac from an iPhone or similar device, including mute control. +- **CarPlay reception**: put the iPhone’s picture on the whole screen. +- **Mouse and trackpad**: finer settings such as side buttons. A few more are still experimental or device-limited: face scanning, presence locking, remote control and CarPlay. None of this claims macOS face unlock or complete CarPlay reception. diff --git a/README_CN.md b/README_CN.md index 79f0ddba..e8e7ebf8 100644 --- a/README_CN.md +++ b/README_CN.md @@ -48,7 +48,7 @@ 到 [Releases](https://github.com/surfine/WindowShade/releases/latest) 下载最新的 DMG,打开后把 `WindowShade.app` 拖到“应用程序”,再打开它,按提示给权限。(ZIP 是同一个 App,应用内更新用的就是它。)它住在菜单栏里,不占 Dock 位置。 - **要 macOS 15 以上。** 主力是 Apple Silicon 版。 -- **Intel Mac(实验,1.0.21 起)。** Releases 里另有一个文件名以 `-intel.zip` 结尾的 ZIP。从 1.0.23 起,它在真实的 2017 MacBook(MacBook10,1)上量过也改过:看一眼进了 Apple 卡顿预算,收起、展开与窗口浏览的开关比 1.0.22 快 2–4 倍;这四类仍超预算,所以还是实验版。刷脸解锁、声纹和合盖桌面效果在 Intel 上是关的,设置里也不显示;置顶预览、画中画和其余功能照常。Intel 版从自己的更新清单取更新,不会收到 Apple Silicon 的包,Apple Silicon 的 Mac 也不会收到 Intel 的包。遇到问题,请[提一个 issue](https://github.com/surfine/WindowShade/issues/new)。 +- **Intel Mac(实验,1.0.21 起)。** Releases 里另有 `-intel.zip` 安装包。从 1.0.23 起,它在 2017 款 MacBook(MacBook10,1)上做过实测和调优:“看一眼”已达到 Apple 的流畅标准(卡顿预算);收起、展开与窗口浏览的开关比 1.0.22 快 2–4 倍,但这四项仍未达标,所以继续标为实验版。刷脸解锁、声纹和合盖桌面效果在 Intel 上关闭且隐藏;置顶预览、画中画和其余功能照常。Intel 版从自己的更新清单取更新,不会与 Apple Silicon 版混用。遇到问题,请[提一个 issue](https://github.com/surfine/WindowShade/issues/new)。 - **下载包大小:** [最新 Releases](https://github.com/surfine/WindowShade/releases/latest) 会列出 ZIP、DMG 和单独的 Intel ZIP,各带一份 SHA-256。 - **已通过 Apple 公证。** 第一次打开时系统会自己检查,不用再手动放行。 - **从 1.0.16 及以前升级:** 这一版要手动下载一次,装好后在“系统设置 → 隐私与安全性”里重新打开辅助功能(开过屏幕录制的,也重新打开)。之后就能在菜单里更新。 @@ -59,17 +59,22 @@ **收起窗口。** 双击标题栏或按 `⌃⌘C`,窗口收成一条卷帘条;双击卷帘条展开。收起后的样子可以选“跟原来一样”,也可以选“统一标题栏”。卷帘条在最前面时按 `⌘W`、`⌘M`、`⌘H`、`⌘Q`、`⌘N`,作用在它背后的窗口和 App 上;按 `⌘Q` 会先把窗口放下来,要问“是否保存”时你看得见。 -**在标题栏上滑一下。** 把指针放在标题栏上,用两根手指滑:往上推,它收成一条卷帘条;往下拉,它铺满菜单栏和 Dock 之间的屏幕;再往上推回到原来的大小。松手才算数,滑到一半往回拉,就当没发生过;滑动时旁边有一块和系统音量提示同样样式的小浮窗,写着松手会做什么。左右滑占半屏;朝同一边再滑,变成三分之二、三分之一;那边还有一块屏幕的话,再滑就移过去。左右滑到位后接着往下或往上拐,窗口占那个角。两指张开也是铺满,捏合撤销上次排布。拖着标题栏快速甩出去再松手,窗口带着这股劲滑到甩的那一边:往上收起,往下铺满,左右走同一架梯子,明显朝着角落甩就占那一角。普通鼠标在标题栏上滚三格算一次;Magic Mouse 的支持还在真机上验证。细节见 [标题栏手势说明](docs/gestures.md)。 +**在标题栏上滑一下。** 把指针放在标题栏上,用两根手指滑动: +- 往上推收起,往下拉铺满菜单栏和 Dock 之间的屏幕,再往上推回到原大小。松手才生效,滑到一半往回拉就取消;滑动时旁边会浮出小窗(样式同系统音量提示),显示松手后的动作。 +- 左右滑占半屏;朝同一边再滑依次变成三分之二、三分之一,再滑则移到相邻屏幕。左右滑到位后再往下或往上拐,窗口占那一角。两指张开铺满,捏合撤销上次排布。 +- 拖住标题栏快速甩出再松手,窗口顺着方向滑过去:往上收起,往下铺满,左右同上,朝角落甩就占那一角。普通鼠标在标题栏上滚三格算一次滑动;Magic Mouse 的支持还在真机上验证。细节见 [标题栏手势说明](docs/gestures.md)。 **看一眼。** 指针在卷帘条上停一下,卷帘条下面就挂出一张卡片,按原来的大小显示窗口里的内容;移开,它自己收回去。单击卡片才真正展开。卷帘条留在原处,卡片和它隔着一道缝,一看就知道这是预览,不是窗口本身。它不会切换当前的 App,也不会动任何窗口。收起时被最小化的窗口拿不到实时画面,这时看到的是收起时的画面,角落会写明。细节见 [看一眼说明](docs/glance.md)。 **带到每张桌面、置顶。** 按 `⌃⌘G` 把当前窗口带到每张桌面:窗口留在原处,别的桌面右上角出现它的卷帘条;停在上面看一眼(窗口被隐藏或最小化时改显示带提示的截图),单击画面就回到它,再按一次放下。按 `⌃⌘P` 把那扇窗口置顶,你切到别的窗口,它也不会被盖住;菜单栏里能看到所有置顶的窗口,也能一次全部取消。 -**窗口浏览。** 把指针停在 Dock 里的应用图标上,这个应用开着的窗口会一起列出来,每扇都带画面和标题。面板只用来看:按下卡片上的按钮,才会动那扇窗口;选中一扇按空格打开大图预览,窗口不会被切到前面;左右、四角、居中、填满或移到别的屏幕,都先画出窗口要去的位置,你同意了才移动,移好了还能撤销。也可以从菜单栏的“选择窗口…”打开,或者按你自己设的快捷键——Dock 入口默认打开,可以在设置里关掉。面板是临时的:不替换系统 Dock,也不接管 Command-Tab。细节见 [窗口浏览说明](docs/window-browser.md)。 +**窗口浏览。** 把指针停在 Dock 里的应用图标上,这个应用开着的窗口会一起列出来,每扇都带画面和标题。面板只用来看,按下卡片上的按钮才会动那扇窗口;选中一扇按空格打开大图预览,窗口不会被切到前面。左右、四角、居中、填满或移到别的屏幕,都先画出窗口要去的位置,你同意了才移动,移好了还能撤销。 + +也可以从菜单栏的“选择窗口…”打开,或按你自己设的快捷键(Dock 入口默认打开,可以在设置里关掉)。面板是临时的,不替换系统 Dock,也不接管 Command-Tab。细节见 [窗口浏览说明](docs/window-browser.md)。 **启动台。** 录一个快捷键(例如 `⌃⌘L`)打开主屏幕,列出所有 App,末页是 App 资料库;把图标拖到屏幕边就侧拉,带分屏把手。刘海关着时也能打开。细节见 [启动台说明](docs/launchpad.md)。 -**更多排布与动作。** 魔法平铺、卷轴、画中画(窗口缩成一张实时画面,浮在屏幕角落)、`⌥`+Tab 按窗口切换,以及点 Dock 图标让开后隐藏(默认开;在欢迎窗口里答了从 Windows 或 iPad 来的默认关,设置里有开关)。设置 → 快捷键里能一键换上 Rectangle 那一套。 +**更多排布与动作。** 魔法平铺、卷轴、画中画(窗口缩成一张实时画面,浮在屏幕角落)、`⌥`+Tab 按窗口切换,以及点 Dock 图标让开这个 App(默认开;欢迎窗口选“之前常用 Windows 或 iPad”的默认关,设置里有开关)。设置 → 快捷键里能一键换上 Rectangle 那一套。 **刘海(默认开,可以在设置里关掉)。** 刘海里有实时活动、文件架、配件电量提醒、音量亮度提示和“让开这个 App”,这几项也各自在设置里开关。关掉自动检查更新这类要小心的操作,刘海会展开系统的指纹提示,用 Touch ID 确认;它不解锁 macOS。[说明](docs/touch-id-island.md) @@ -104,7 +109,9 @@ ## 你的窗口,只留在你的 Mac 上 -WindowShade 要两项权限,一项必需、一项可选。**辅助功能**(必需;macOS 27 起在系统设置里叫“设备控制和数据访问”):找到、移动、恢复窗口。**屏幕录制**(可选):开了,看一眼、窗口浏览和置顶预览里能看到窗口的实时画面;不开也能用,预览会改成图标和标题。“屏幕录制”只是系统给这个权限起的名字,画面只在你的电脑上处理,不会传到别处。应用万一意外退出,窗口也会自动恢复原样。WindowShade 不收集使用数据,也不做任何统计或上报;检查更新时会联网。它读到的每一样都列在设置里的“隐私”一栏和[官网隐私页](https://windowshade.aaronlau.me/privacy/)。 +WindowShade 要两项权限,一项必需、一项可选。**辅助功能**(必需;macOS 27 起在系统设置里叫“设备控制和数据访问”)用来找到、移动和恢复窗口。**屏幕录制**(可选)开启后,“看一眼”、窗口浏览和置顶预览能显示窗口的实时画面;不开也能用,预览会改成图标和标题。“屏幕录制”只是系统给这个权限起的名字,画面只在你的电脑上处理,不会传到别处。 + +应用万一意外退出,窗口会自动恢复原样。WindowShade 不收集使用数据,也不做任何统计或上报;只有检查更新时会联网。它读到的每一样都列在设置里的“隐私”一栏和[官网隐私页](https://windowshade.aaronlau.me/privacy/)。 普通窗口都能收起。便笺用系统自己的收起方式;Adobe 这类自己画标题栏的应用会单独处理。全屏、分屏、台前调度和多显示器还有少数情况没覆盖,建议先在你常用的应用里试一次。碰到问题欢迎[反馈](https://github.com/surfine/WindowShade/issues),写上 macOS 版本、应用名和操作步骤。 @@ -123,14 +130,14 @@ WindowShade 只改过一项系统设置:程序坞的「最小化效果」。 ## 开发中 -当前下载版是 **1.0.23**。上面写的都在里面。这一版在真实的 2017 MacBook 上把 Intel 实验版的性能收尾:看一眼进了 Apple 卡顿预算,收起、展开与窗口浏览快了 2–4 倍但仍超预算,所以 Intel 版仍是实验版;同一批修正也让 Apple Silicon 的展开快了一倍。另外修好窗口浏览在“始终显示滚动条”时裁掉文档最后一行的问题。[发布说明](docs/releases/v1.0.23.md) +当前下载版是 **1.0.23**,上面写的都在里面。这一版在 2017 款 MacBook 上收尾了 Intel 实验版的性能调优:“看一眼”已达到 Apple 的流畅标准(卡顿预算),收起、展开与窗口浏览快了 2–4 倍但仍未达标,所以 Intel 版继续标为实验版;同一批修正也让 Apple Silicon 的展开快了一倍。另外修好窗口浏览在“始终显示滚动条”时裁掉文档最后一行的问题。[发布说明](docs/releases/v1.0.23.md) -接下来的方向是 **WindowShade 2**:让 Mac 的窗口听你指挥,也能被手边的设备遥控。刘海的新样子和新手势已在 1.0.19 里;指挥模式、遥控和编程会话仍在预览开关后面——设置里看不到,也不会运行: +接下来的方向是 **WindowShade 2**:让 Mac 的窗口听你指挥,也能被手边的设备遥控。刘海的新样子和新手势已在 1.0.19 里;指挥模式、遥控和编程会话仍在预览开关后面,设置里看不到,也不会运行: -- **指挥模式、编程会话** —— 把多个编程会话的状态和审批集中到一处。 -- **遥控器** —— 用 iPhone 等设备控制这台 Mac,含静音操作。 -- **CarPlay 接收** —— 把 iPhone 的画面放到整块屏幕。 -- **鼠标与触控板** —— 侧键等更细的设置。 +- **指挥模式、编程会话**:把多个编程会话的状态和审批集中到一处。 +- **遥控器**:用 iPhone 等设备控制这台 Mac,含静音操作。 +- **CarPlay 接收**:把 iPhone 的画面放到整块屏幕。 +- **鼠标与触控板**:侧键等更细的设置。 另有几项仍在实验、有设备限制:刷脸、离开就锁、遥控和 CarPlay。现在不能据此声称支持系统刷脸解锁或完整 CarPlay 接收。 diff --git a/README_TW.md b/README_TW.md index 07cfd3e4..d21ac449 100644 --- a/README_TW.md +++ b/README_TW.md @@ -48,7 +48,7 @@ 到 [Releases](https://github.com/surfine/WindowShade/releases/latest) 下載最新的 DMG,開啟後把 `WindowShade.app` 拖進“應用程式”,再開啟它,按提示給權限。(ZIP 是同一個 App,應用程式內更新用的就是它。)它住在選單列裡,不佔 Dock 位置。 - **要 macOS 15 以上。** 主力是 Apple Silicon 版。 -- **Intel Mac(實驗,1.0.21 起)。** Releases 裡另有一個檔名以 `-intel.zip` 結尾的 ZIP。從 1.0.23 起,它在真實的 2017 MacBook(MacBook10,1)上量過也改過:看一眼進了 Apple 卡頓預算,收起、展開與視窗瀏覽的開關比 1.0.22 快 2–4 倍;這四類仍超預算,所以還是實驗版。刷臉解鎖、聲紋和合蓋桌面效果在 Intel 上是關的,設定裡也不顯示;置頂預覽、畫中畫和其餘功能照常。Intel 版從自己的更新清單取更新,不會收到 Apple Silicon 的包,Apple Silicon 的 Mac 也不會收到 Intel 的包。遇到問題,請[提一個 issue](https://github.com/surfine/WindowShade/issues/new)。 +- **Intel Mac(實驗,1.0.21 起)。** Releases 裡另有 `-intel.zip` 安裝包。從 1.0.23 起,它在 2017 年款 MacBook(MacBook10,1)上做過實測與調校:「看一眼」已達到 Apple 的流暢標準(卡頓預算);收起、展開與視窗瀏覽的開關比 1.0.22 快 2–4 倍,但這四項仍未達標,所以繼續標為實驗版。刷臉解鎖、聲紋和合蓋桌面效果在 Intel 上關閉且不顯示;置頂預覽、子母畫面和其餘功能照常。Intel 版從自己的更新清單取更新,不會與 Apple Silicon 版混用。遇到問題,請[提一個 issue](https://github.com/surfine/WindowShade/issues/new)。 - **下載包大小:** [最新 Releases](https://github.com/surfine/WindowShade/releases/latest) 會列出 ZIP、DMG 和單獨的 Intel ZIP,各帶一份 SHA-256。 - **已通過 Apple 公證。** 第一次開啟時系統會自己檢查,不用再手動放行。 - **從 1.0.16 及以前升級:** 這一版要手動下載一次,裝好後在“系統設定 → 隱私權與安全性”裡重新開啟輔助使用(開過螢幕錄製的,也重新開啟)。之後就能在選單裡更新。 @@ -59,17 +59,22 @@ **收起視窗。** 按兩下標題列或按 `⌃⌘C`,視窗收成一條捲簾條;按兩下捲簾條展開。收起後的樣子可以選“跟原來一樣”,也可以選“統一標題列”。捲簾條在最前面時按 `⌘W`、`⌘M`、`⌘H`、`⌘Q`、`⌘N`,作用在它背後的視窗和 App 上;按 `⌘Q` 會先把視窗放下來,要問“是否儲存”時你看得見。 -**在標題列上滑一下。** 把指標放在標題列上,用兩根手指滑:往上推,它收成一條捲簾條;往下拉,它鋪滿選單列和 Dock 之間的螢幕;再往上推回到原來的大小。鬆手才算數,滑到一半往回拉,就當沒發生過;滑動時旁邊有一塊和系統音量提示同樣樣式的小浮窗,寫著鬆手會做什麼。左右滑佔半螢幕;朝同一邊再滑,變成三分之二、三分之一;那邊還有一塊螢幕的話,再滑就移過去。左右滑到位後接著往下或往上拐,視窗占那個角。兩指張開也是鋪滿,捏合撤銷上次排布。拖著標題列快速甩出去再鬆手,視窗帶著這股勁滑到甩的那一邊:往上收起,往下鋪滿,左右走同一架梯子,明顯朝著角落甩就佔那一角。普通滑鼠在標題列上滾三格算一次;Magic Mouse 的支援還在真機上驗證。細節見 [標題列手勢說明](docs/gestures.md)。 +**在標題列上滑一下。** 把指標放在標題列上,用兩根手指滑動: +- 往上推收起,往下拉鋪滿選單列和 Dock 之間的螢幕,再往上推回到原大小。鬆手才生效,滑到一半往回拉就取消;滑動時旁邊會浮出小視窗(樣式同系統音量提示),顯示鬆手後的動作。 +- 左右滑佔半螢幕;朝同一邊再滑依序變成三分之二、三分之一,再滑則移到相鄰螢幕。左右滑到位後再往下或往上拐,視窗佔那一角。兩指張開鋪滿,捏合還原上次排布。 +- 拖移標題列快速甩出再鬆手,視窗順著方向滑過去:往上收起,往下鋪滿,左右同上,朝角落甩就佔那一角。普通滑鼠在標題列上捲動三格算一次滑動;巧控滑鼠的支援還在真機上驗證。細節見 [標題列手勢說明](docs/gestures.md)。 **看一眼。** 指標在捲簾條上停一下,捲簾條下面就掛出一張卡片,按原來的大小顯示視窗裡的內容;移開,它自己收回去。按一下卡片才真正展開。捲簾條留在原處,卡片和它隔著一道縫,一看就知道這是預覽,不是視窗本身。它不會切換當前的 App,也不會動任何視窗。收起時被最小化的視窗拿不到即時畫面,這時看到的是收起時的畫面,角落會寫明。細節見 [看一眼說明](docs/glance.md)。 **帶到每張桌面、置頂。** 按 `⌃⌘G` 把當前視窗帶到每張桌面:視窗留在原處,別的桌面右上角出現它的捲簾條;停在上面看一眼(視窗被隱藏或最小化時改顯示帶提示的截圖),按一下畫面就回到它,再按一次放下。按 `⌃⌘P` 把那扇視窗置頂,你切到別的視窗,它也不會被蓋住;選單列裡能看到所有置頂的視窗,也能一次全部取消。 -**視窗瀏覽。** 把指標停在 Dock 裡的應用圖示上,這個應用開著的視窗會一起列出來,每扇都帶畫面和標題。面板只用來看:按下卡片上的按鈕,才會動那扇視窗;選中一扇按空格開啟大圖預覽,視窗不會被切到前面;左右、四角、置中、填滿或移到別的螢幕,都先畫出視窗要去的位置,你同意了才移動,移好了還能撤銷。也可以從選單列的“選擇視窗…”開啟,或者按你自己設的快速鍵——Dock 入口預設開啟,可以在設定裡關掉。面板是臨時的:不取代系統 Dock,也不接管 Command-Tab。細節見 [視窗瀏覽說明](docs/window-browser.md)。 +**視窗瀏覽。** 把指標停在 Dock 裡的應用圖示上,這個應用開著的視窗會一起列出來,每扇都帶畫面和標題。面板只用來看,按下卡片上的按鈕才會動那扇視窗;選中一扇按空白鍵開啟大圖預覽,視窗不會被切到前面。左右、四角、置中、填滿或移到別的螢幕,都先畫出視窗要去的位置,你同意了才移動,移好了還能還原。 + +也可以從選單列的「選擇視窗…」開啟,或按你自己設的快速鍵(Dock 入口預設開啟,可以在設定裡關掉)。面板是臨時的,不取代系統 Dock,也不接管 Command-Tab。細節見 [視窗瀏覽說明](docs/window-browser.md)。 **啟動台。** 錄一個快速鍵(例如 `⌃⌘L`)開啟主螢幕,列出所有 App,末頁是 App 資料庫;把圖示拖到螢幕邊就側拉,帶分割畫面把手。瀏海關著時也能開啟。細節見 [啟動台說明](docs/launchpad.md)。 -**更多排布與動作。** 魔法並排、卷軸、子母畫面(視窗縮成一張即時畫面,浮在螢幕角落)、`⌥`+Tab 按視窗切換,以及點 Dock 圖示讓開後隱藏(預設開;在歡迎視窗裡答了從 Windows 或 iPad 來的預設關,設定裡有開關)。設定 → 快速鍵裡能一鍵換上 Rectangle 那一套。 +**更多排布與動作。** 魔法並排、卷軸、子母畫面(視窗縮成一張即時畫面,浮在螢幕角落)、`⌥`+Tab 按視窗切換,以及點 Dock 圖示讓開這個 App(預設開;歡迎視窗選「之前常用 Windows 或 iPad」的預設關,設定裡有開關)。設定 → 快速鍵裡能一鍵換上 Rectangle 那一套。 **瀏海(預設開,可以在設定裡關掉)。** 瀏海裡有即時活動、檔案架、配件電量提醒、音量亮度提示和“讓開這個 App”,這幾項也各自在設定裡開關。關掉自動檢查更新這類要小心的操作,瀏海會展開系統的指紋提示,用 Touch ID 確認;它不解鎖 macOS。[說明](docs/touch-id-island.md) @@ -104,13 +109,15 @@ ## 你的視窗,只留在你的 Mac 上 -WindowShade 要兩項權限,一項必需、一項可選。**輔助使用**(必需;macOS 27 起在系統設定裡叫「裝置控制與資料存取」):找到、移動、回復視窗。**螢幕錄製**(可選):開了,看一眼、視窗瀏覽和置頂預覽裡能看到視窗的即時畫面;不開也能用,預覽會改成圖示和標題。“螢幕錄製”只是系統給這個權限起的名字,畫面只在你的電腦上處理,不會傳到別處。應用萬一意外退出,視窗也會自動恢復原樣。WindowShade 不收集使用資料,也不做任何統計或上報;檢查更新時會連網。它讀到的每一樣都列在設定裡的「隱私權」一欄和[官網隱私權頁](https://windowshade.aaronlau.me/privacy/)。 +WindowShade 要兩項權限,一項必需、一項可選。**輔助使用**(必需;macOS 27 起在系統設定裡叫「裝置控制與資料存取」)用來找到、移動和回復視窗。**螢幕錄製**(可選)開啟後,「看一眼」、視窗瀏覽和置頂預覽能顯示視窗的即時畫面;不開也能用,預覽會改成圖示和標題。「螢幕錄製」只是系統給這個權限起的名字,畫面只在你的電腦上處理,不會傳到別處。 + +應用萬一意外退出,視窗會自動回復原樣。WindowShade 不收集使用資料,也不做任何統計或上報;只有檢查更新時會連網。它讀到的每一樣都列在設定裡的「隱私權」一欄和[官網隱私權頁](https://windowshade.aaronlau.me/privacy/)。 -普通視窗都能收起。便箋用系統自己的收起方式;Adobe 這類自己畫標題列的應用會單獨處理。全螢幕、分割畫面、台前排程和多顯示器還有少數情況沒覆蓋,建議先在你常用的應用裡試一次。碰到問題歡迎[回饋](https://github.com/surfine/WindowShade/issues),寫上 macOS 版本、應用名和操作步驟。 +普通視窗都能收起。便箋用系統自己的收起方式;Adobe 這類自己畫標題列的應用會單獨處理。全螢幕、分割顯示、幕前調度和多顯示器還有少數情況沒覆蓋,建議先在你常用的應用裡試一次。碰到問題歡迎[回饋](https://github.com/surfine/WindowShade/issues),寫上 macOS 版本、應用名和操作步驟。 ### 怎麼徹底刪掉 -WindowShade 只改過一項系統設定:程式塢的「最小化效果」。用到時改成「縮放」,改之前記下原值;正常退出時還原,意外退出後下次啟動先還原。刪掉之前先在選單裡退出 WindowShade,這一項就已經回到原樣。其餘要刪的: +WindowShade 只改過一項系統設定:Dock 的「最小化效果」。用到時改成「縮放」,改之前記下原值;正常退出時還原,意外退出後下次啟動先還原。刪掉之前先在選單裡退出 WindowShade,這一項就已經回到原樣。其餘要刪的: 1. 把 `WindowShade.app` 拖到垃圾桶;如果開過「登入時自動啟動」,到「系統設定 → 一般 → 登入項目」裡把它移除。 2. 刪掉它在你帳戶裡建立的檔案: @@ -123,14 +130,14 @@ WindowShade 只改過一項系統設定:程式塢的「最小化效果」。 ## 開發中 -目前下載版是 **1.0.23**。上面寫的都在裡面。這一版在真實的 2017 MacBook 上把 Intel 實驗版的效能收尾:看一眼進了 Apple 卡頓預算,收起、展開與視窗瀏覽快了 2–4 倍但仍超預算,所以 Intel 版仍是實驗版;同一批修正也讓 Apple Silicon 的展開快了一倍。另外修好視窗瀏覽在「永遠顯示捲動軸」時裁掉文件最後一行的問題。[釋出說明](docs/releases/v1.0.23.md) +目前下載版是 **1.0.23**,上面寫的都在裡面。這一版在 2017 年款 MacBook 上收尾了 Intel 實驗版的效能調校:「看一眼」已達到 Apple 的流暢標準(卡頓預算),收起、展開與視窗瀏覽快了 2–4 倍但仍未達標,所以 Intel 版繼續標為實驗版;同一批修正也讓 Apple Silicon 的展開快了一倍。另外修好視窗瀏覽在「永遠顯示捲動軸」時裁掉文件最後一行的問題。[釋出說明](docs/releases/v1.0.23.md) -接下來的方向是 **WindowShade 2**:讓 Mac 的視窗聽你指揮,也能被手邊的裝置遙控。瀏海的新樣子和新手勢已在 1.0.19 裡;指揮模式、遙控和程式設計工作階段仍在預覽開關後面——設定裡看不到,也不會執行: +接下來的方向是 **WindowShade 2**:讓 Mac 的視窗聽你指揮,也能被手邊的裝置遙控。瀏海的新樣子和新手勢已在 1.0.19 裡;指揮模式、遙控和程式設計工作階段仍在預覽開關後面,設定裡看不到,也不會執行: -- **指揮模式、程式設計工作階段** —— 把多個程式設計工作階段的狀態和審批集中到一處。 -- **遙控器** —— 用 iPhone 等裝置控制這台 Mac,含靜音操作。 -- **CarPlay 接收** —— 把 iPhone 的畫面放到整塊螢幕。 -- **滑鼠與觸控板** —— 側鍵等更細的設定。 +- **指揮模式、程式設計工作階段**:把多個程式設計工作階段的狀態和審批集中到一處。 +- **遙控器**:用 iPhone 等裝置控制這台 Mac,含靜音操作。 +- **CarPlay 接收**:把 iPhone 的畫面放到整塊螢幕。 +- **滑鼠與觸控式軌跡板**:側鍵等更細的設定。 另有幾項仍在實驗、有裝置限制:刷臉、離開就鎖、遙控和 CarPlay。現在不能據此聲稱支援系統刷臉解鎖或完整 CarPlay 接收。 @@ -146,7 +153,7 @@ cd WindowShade/prototype open WindowShade.app ``` -通過 `WINDOWSHADE_CODESIGN_IDENTITY` 或未跟蹤的 `prototype/local-codesign.env` 設定簽名。簽名、隔離構建與釋出步驟見 [DEVELOPMENT.md](docs/DEVELOPMENT.md);介面和官網文案按 [文案規則](docs/copy-guide.md) 寫。 +透過 `WINDOWSHADE_CODESIGN_IDENTITY` 或未追蹤的 `prototype/local-codesign.env` 設定簽名。簽名、隔離構建與釋出步驟見 [DEVELOPMENT.md](docs/DEVELOPMENT.md);介面和官網文案按 [文案規則](docs/copy-guide.md) 寫。 | 倉庫入口 | 內容 | | --- | --- | diff --git a/site/scripts/content.mjs b/site/scripts/content.mjs index eb6ba986..cb70e438 100644 --- a/site/scripts/content.mjs +++ b/site/scripts/content.mjs @@ -70,7 +70,7 @@ export const copy = { todayKicker: '今天的 WindowShade', todayTitle: '老动作之外,
WindowShade 还帮你看住每扇窗口。', - todayBody: '收起,窗口留在原处。看一眼,不用展开就看到它。置顶,它一直在最前面。侧拉,它靠在屏幕边随叫随到。收进刘海,桌面一下子空了,刘海替你看着它。窗口浏览,从 Dock 把它找出来。', + todayBody: '收起,窗口留在原处;不用展开,停在上面就能看一眼。要一直看就置顶,或者侧拉到屏幕边随叫随到。收进刘海后桌面一下子空了,有需要还能从 Dock 的窗口浏览里找出来。', glanceKicker: '看一眼', glanceTitle: '不用去了再回来,
停一下就能看一眼。', @@ -114,7 +114,7 @@ export const copy = { notchKicker: '收进刘海', notchTitle: '刘海,
也能装窗口。', - notchIntro: '收进刘海默认关闭,在设置里打开。朝刘海甩一下标题栏,窗口缩小、飞进刘海,桌面一下子空了。刘海两边露出它的图标和个数;指针停上去,刘海往下展开成一排,点一下,它回到原处。', + notchIntro: '收进刘海默认关闭,在设置里打开。朝刘海甩一下标题栏,窗口缩小、飞进刘海,桌面一下子空了。刘海两边会露出它的图标和个数;指针停上去,刘海向下展开一排窗口,点一下就回到原处。', notchPoints: [ ['一个入口,找回所有收着的窗口', '收进刘海的、卷帘条、侧拉的、带到每张桌面的窗口,都排在这一排里。点哪一格,哪一扇就回到原处。'], ['有变化,刘海告诉你', '收着的窗口标题变了,比如编译完成、下载好了,刘海短暂展开说一句就收回,格子上留一个点。一直在变的窗口只标点,不打扰你。'], @@ -136,7 +136,7 @@ export const copy = { notchCaption: '网页示意,不会碰你电脑上的窗口。在 Mac 上是朝刘海甩一下标题栏,这里用按钮代替。', slideKicker: '侧拉', slideTitle: '侧拉一扇窗口,
靠在屏幕边随叫随到。', - slideIntro: '拖住窗口标题栏,移到屏幕侧边中段的箭头上。出现“松手侧拉”后松手,窗口就靠在边上、浮在前面。朝它靠的那一边甩一下,它收到屏幕边外,只留一个小把手;轻点把手,或在上面两指往里划,它就回来。拖住标题栏拉到屏幕中间,停下再松手,就回到普通窗口。', + slideIntro: '拖住窗口标题栏,移到屏幕侧边中段的箭头上。出现“松手侧拉”后松手,窗口就靠在边上、浮在前面。朝它靠的那一边甩一下,它收到屏幕边外,只留一个小把手;点一下把手,或在上面两指往里划,它就回来。拖住标题栏拉到屏幕中间,停下再松手,就回到普通窗口。', slidePoints: [ ['还是那扇窗口', '收起、拉出都是真窗口带着速度滑,不截图、不最小化,也不会把整个应用藏起来。'], ['每张桌面都拉得出来', '换到别的桌面,把手跟着你;拉出来的是它此刻的画面,点一下就回到它那里。'], @@ -208,7 +208,7 @@ export const copy = { ['⌃ ⌘ ←→↑↓', '左半屏、右半屏、变小一级、变大一级'], ], shortcutNotes: [ - '1.0.22 起新装的带上面这几组,从 1.0.15 及以前升级上来的也保留。1.0.16 到 1.0.21 之间装上的一项都没有,可以在“设置 → 快捷键”里自己录,也可以一键换上 Rectangle 那一套。', + '1.0.22 起新装的带上面这几组,从 1.0.15 及以前升级上来的也保留。1.0.16 到 1.0.21 之间装上的一项都没有。需要的话可以在“设置 → 快捷键”里自己录,也能一键换上 Rectangle 那一套。', '另有 7 个动作,在“快捷指令”、聚焦搜索和 Siri 里都能用。比如收起或展开当前窗口、全部展开、置顶或取消置顶当前窗口。', ], @@ -218,8 +218,8 @@ export const copy = { faqTitle: '下载之前,你可能会问', faqs: [ - ['我的 Mac 能用吗?', '要 macOS 15 以上。Apple Silicon 用主下载包。Intel 从 1.0.21 起有单独的实验包。1.0.23 起在 2017 MacBook 上实测过:看一眼进了卡顿预算,收起、展开与窗口浏览仍超预算,属实验版。刷脸解锁、声纹和合盖效果在 Intel 上关闭。还在 macOS 14 的,继续用 1.0.16。收起、看一眼和手势都不用特别的硬件;合盖效果需要带铰链传感器的 MacBook。'], - ['要什么权限?', '两项,一项必需、一项可选。辅助功能(必需):找到、移动、恢复窗口。屏幕录制(可选):开了,看一眼、窗口浏览和置顶预览里能看到窗口的实时画面;不开也能用,预览会改成图标和标题。“屏幕录制”只是系统给这个权限起的名字,画面不会离开你的电脑。用着用着辅助功能被关掉了,它会提醒你。'], + ['我的 Mac 能用吗?', '要 macOS 15 以上。Apple Silicon 用主下载包;Intel 从 1.0.21 起有单独的实验包。1.0.23 起在 2017 款 MacBook 上实测过:“看一眼”已达到流畅标准(卡顿预算),收起、展开与窗口浏览仍未达标,属实验版。刷脸解锁、声纹和合盖效果在 Intel 上关闭。还在 macOS 14 的,继续用 1.0.16。收起、看一眼和手势都不用特别的硬件;合盖效果需要带铰链传感器的 MacBook。'], + ['要什么权限?', '两项,一项必需、一项可选。辅助功能(必需)用来找到、移动和恢复窗口。屏幕录制(可选)开启后,“看一眼”、窗口浏览和置顶预览能显示窗口的实时画面;不开也能用,预览会改成图标和标题。“屏幕录制”只是系统给这个权限起的名字,画面不会离开你的电脑。用着用着辅助功能被关掉了,它会提醒你。'], ['看一眼和手势会动我的窗口吗?', '看一眼不会。手势只在你松手、而且小浮窗的进度条走满时才动窗口;往回拉就取消。'], ['窗口浏览会动我的窗口吗?', '不会,除非你按下卡片上的按钮。动手之前,它还会再确认一次“就是这一扇窗口”,确认不了就不做。'], ['没有刘海的 Mac 也能收进刘海吗?', '能。外接显示器上,菜单栏正中有一个看不见的刘海。它平时不露面,收着窗口时才显出来;朝它甩一下,同样收得进去。'], @@ -290,7 +290,7 @@ export const copy = { todayKicker: 'WindowShade today', todayTitle: 'Beyond the old gesture,
WindowShade keeps track of every window.', - todayBody: 'Roll up, and a window stays where it was. Glance, and you see it without unrolling. Pin, and it stays in front. Slide Over, and it waits at the screen edge. Tuck it into the notch, and the notch keeps an eye on it. Browse, and you find it from the Dock.', + todayBody: 'Roll a window up to keep its place, or rest on the bar to glance without unrolling. Pin it to keep it in front, or use Slide Over to park it at the screen edge. You can also tuck windows into the notch to clear your desk, and find any window straight from the Dock.', glanceKicker: 'Glance', glanceTitle: 'No round trip.
Just rest and glance.', @@ -334,7 +334,7 @@ export const copy = { notchKicker: 'Tuck into the notch', notchTitle: 'The notch
can hold windows.', - notchIntro: 'Tucking into the notch is off until you turn it on in Settings. Flick a title bar toward the notch and the window shrinks and flies into it, clearing your desk. Its icon and a count show beside the notch; rest the pointer there and the notch opens into a row. Click one and it goes back where it was.', + notchIntro: 'Tucking into the notch is off until you turn it on in Settings. Flick a title bar toward the notch and the window shrinks into it, clearing your desk. Its icon and count show beside the notch; rest the pointer there to see the row, and click a window to put it back.', notchPoints: [ ['One place for every put-away window', 'Windows tucked into the notch, rolled-up bars, Slide Over and windows on every desktop all sit in that row. Click a card and that window goes back where it was.'], ['The notch tells you when something changes', 'When a tucked window’s title changes, say a build finishes or a download completes, the notch opens briefly to say so, then leaves a dot on its card. Windows that change all the time only get the dot.'], @@ -428,7 +428,7 @@ export const copy = { ['⌃ ⌘ ←→↑↓', 'Left half, right half, one size down, one size up'], ], shortcutNotes: [ - 'New setups from 1.0.22 on come with the ones above, and so do setups upgraded from 1.0.15 or earlier. Setups first installed with 1.0.16 to 1.0.21 have none; record your own in Settings → Shortcuts, or bring Rectangle’s key set over in one click.', + 'New setups from 1.0.22 on come with the ones above, and so do setups upgraded from 1.0.15 or earlier. Setups first installed with 1.0.16 to 1.0.21 have none. Record your own in Settings → Shortcuts, or bring Rectangle’s key set over in one click.', 'There are also 7 actions for Shortcuts, Spotlight and Siri, such as Roll Up or Unroll Front Window, Unroll All, and Pin or Unpin Front Window.', ], @@ -438,8 +438,8 @@ export const copy = { faqTitle: 'Before you download', faqs: [ - ['Will it work on my Mac?', 'You need macOS 15 or later. Apple Silicon uses the main download. From 1.0.21, Intel has its own experimental package. Since 1.0.23 it has been measured on a 2017 MacBook: Glance is inside the budget, while roll-up, unfold and the window browser are still over, so it stays experimental. Face unlock, voiceprint and the lid effect are off on Intel. If you’re still on macOS 14, stay on 1.0.16. Rolling up, Glance and the title-bar gestures don’t need any special hardware. The lid-following desktop effect needs a MacBook with a hinge sensor.'], - ['What permissions does it need?', 'Two: one required, one optional. Accessibility (required): finding, moving and restoring windows. Screen Recording (optional): turn it on to see live window pictures in Glance, in window browsing and in pinned previews; leave it off and WindowShade still works, with previews showing icons and titles instead. “Screen Recording” is just the name the system gives that permission. Nothing leaves your Mac. If Accessibility gets turned off while the app is running, it tells you.'], + ['Will it work on my Mac?', 'You need macOS 15 or later. Apple Silicon uses the main download. From 1.0.21, Intel has its own experimental package. Since 1.0.23 it has been measured on a 2017 MacBook: Glance meets Apple’s smoothness target (hitch budget), while roll-up, unfold and the window browser still exceed it, so it stays experimental. Face unlock, voiceprint and the lid effect are off on Intel. If you’re still on macOS 14, stay on 1.0.16. Rolling up, Glance and the title-bar gestures don’t need any special hardware. The lid-following desktop effect needs a MacBook with a hinge sensor.'], + ['What permissions does it need?', 'Two: one required, one optional. Accessibility (required) lets WindowShade find, move and restore windows. Screen Recording (optional) lets you see live window pictures in Glance, window browsing and pinned previews; leave it off and WindowShade still works, showing icons and titles instead. “Screen Recording” is just the system name for that permission; nothing leaves your Mac. If Accessibility gets turned off while the app is running, it tells you.'], ['Do glances and gestures move my windows?', 'A glance never does. A gesture moves a window only when you let go with the panel’s track full; pull back to cancel.'], ['Can I use the notch without a notch?', 'Yes. On an external display there’s an invisible notch in the middle of the menu bar: it stays out of sight until a window is tucked into it, and flicking toward it works the same.'], ['How is Slide Over different from pinning?', 'Pinning just keeps a window in front, where it is. Slide Over docks it at the screen edge: pull it out when you need it and tuck it away when you don’t, from any desktop.'], diff --git a/site/scripts/zh-hant.json b/site/scripts/zh-hant.json index 1e8257cd..d2956c54 100644 --- a/site/scripts/zh-hant.json +++ b/site/scripts/zh-hant.json @@ -7,7 +7,7 @@ "${t('选择旧系统','Choose a historical system')}": "${t('選擇舊系統','Choose a historical system')}", "${t('选择窗口安排','Choose an arrangement')}": "${t('選擇視窗安排','Choose an arrangement')}", "1.0.17 起,同一版里还有魔法平铺、卷轴、画中画、带分屏把手的侧拉、⌥Tab 按窗口切换、点 Dock 图标让开这个 App。": "1.0.17 起,同一版裡還有魔法並排、卷軸、子母畫面、帶分割顯示把手的側拉、⌥Tab 按視窗切換、點 Dock 圖示讓開這個 App。", - "1.0.22 起新装的带上面这几组,从 1.0.15 及以前升级上来的也保留。1.0.16 到 1.0.21 之间装上的一项都没有,可以在“设置 → 快捷键”里自己录,也可以一键换上 Rectangle 那一套。": "1.0.22 起新裝的帶上面這幾組,從 1.0.15 及以前升級上來的也保留。1.0.16 到 1.0.21 之間裝上的一項都沒有,可以在“設定 → 快速鍵”裡自己錄,也可以一鍵換上 Rectangle 那一套。", + "1.0.22 起新装的带上面这几组,从 1.0.15 及以前升级上来的也保留。1.0.16 到 1.0.21 之间装上的一项都没有。需要的话可以在“设置 → 快捷键”里自己录,也能一键换上 Rectangle 那一套。": "1.0.22 起新裝的帶上面這幾組,從 1.0.15 及以前升級上來的也保留。1.0.16 到 1.0.21 之間裝上的一項都沒有。需要的話可以在“設定 → 快速鍵”裡自己錄,也能一鍵換上 Rectangle 那一套。", "1994 年 1 月的 Mini’app’les 用户社群刊物,在一串免费和共享软件里列出了 WindowShade 1.2。署名是 Interactive Technologies 和 Rob Johnston,版权从 1989 到 1992。": "1994 年 1 月的 Mini’app’les 使用者社群刊物,在一串免費和共享軟體裡列出了 WindowShade 1.2。署名是 Interactive Technologies 和 Rob Johnston,版權從 1989 到 1992。", "1994 年手册摘录": "1994 年手冊摘錄", "1994 年通讯": "1994 年通訊", @@ -74,7 +74,7 @@ "两指张开,再捏合": "兩指張開,再捏合", "两指滑动": "兩指滑動", "两指轻点两下": "兩指輕點兩下", - "两项,一项必需、一项可选。辅助功能(必需):找到、移动、恢复窗口。屏幕录制(可选):开了,看一眼、窗口浏览和置顶预览里能看到窗口的实时画面;不开也能用,预览会改成图标和标题。“屏幕录制”只是系统给这个权限起的名字,画面不会离开你的电脑。用着用着辅助功能被关掉了,它会提醒你。": "兩項,一項必需、一項可選。輔助使用(必需):找到、移動、回復視窗。螢幕錄製(可選):開了,看一眼、視窗瀏覽和置頂預覽裡能看到視窗的即時畫面;不開也能用,預覽會改成圖示和標題。“螢幕錄製”只是系統給這個權限起的名字,畫面不會離開你的電腦。用著用著輔助使用被關掉了,它會提醒你。", + "两项,一项必需、一项可选。辅助功能(必需)用来找到、移动和恢复窗口。屏幕录制(可选)开启后,“看一眼”、窗口浏览和置顶预览能显示窗口的实时画面;不开也能用,预览会改成图标和标题。“屏幕录制”只是系统给这个权限起的名字,画面不会离开你的电脑。用着用着辅助功能被关掉了,它会提醒你。": "兩項,一項必需、一項可選。輔助使用(必需)用來找到、移動和回復視窗。螢幕錄製(可選)開啟後,“看一眼”、視窗瀏覽和置頂預覽能顯示視窗的即時畫面;不開也能用,預覽會改成圖示和標題。“螢幕錄製”只是系統給這個權限起的名字,畫面不會離開你的電腦。用著用著輔助使用被關掉了,它會提醒你。", "为了什么": "為了什麼", "为什么是收起": "為什麼是收起", "主导航": "主導航", @@ -229,7 +229,7 @@ "把设置改成三下,再照老习惯双击试试。窗口没反应的那一下,你会发现手指比脑子先动了。": "把設定改成三下,再照老習慣按兩下試試。視窗沒反應的那一下,你會發現手指比腦子先動了。", "拉出侧拉的窗口": "拉出側拉的視窗", "拉出来": "拉出來", - "拖住窗口标题栏,移到屏幕侧边中段的箭头上。出现“松手侧拉”后松手,窗口就靠在边上、浮在前面。朝它靠的那一边甩一下,它收到屏幕边外,只留一个小把手;轻点把手,或在上面两指往里划,它就回来。拖住标题栏拉到屏幕中间,停下再松手,就回到普通窗口。": "拖住視窗標題列,移到螢幕側邊中段的箭頭上。出現“鬆手側拉”後鬆手,視窗就靠在邊上、浮在前面。朝它靠的那一邊甩一下,它收到螢幕邊外,只留一個小把手;輕點把手,或在上面兩指往裡劃,它就回來。拖住標題列拉到螢幕中間,停下再鬆手,就回到普通視窗。", + "拖住窗口标题栏,移到屏幕侧边中段的箭头上。出现“松手侧拉”后松手,窗口就靠在边上、浮在前面。朝它靠的那一边甩一下,它收到屏幕边外,只留一个小把手;点一下把手,或在上面两指往里划,它就回来。拖住标题栏拉到屏幕中间,停下再松手,就回到普通窗口。": "拖住視窗標題列,移到螢幕側邊中段的箭頭上。出現“鬆手側拉”後鬆手,視窗就靠在邊上、浮在前面。朝它靠的那一邊甩一下,它收到螢幕邊外,只留一個小把手;點一下把手,或在上面兩指往裡劃,它就回來。拖住標題列拉到螢幕中間,停下再鬆手,就回到普通視窗。", "拖到哪,就在哪展开": "拖到哪,就在哪展開", "拖到屏幕边可侧拉": "拖到螢幕邊可側拉", "拖动标题栏就能移动窗口;聚焦后按方向键也可以。": "拖移標題列就能移動視窗;聚焦後按方向鍵也可以。", @@ -270,10 +270,10 @@ "收起窗口,卷帘条留在原处": "收起視窗,捲簾條留在原處", "收起窗口,留下位置。一个从九十年代走来的小动作。": "收起視窗,留下位置。一個從九十年代走來的小動作。", "收起,
有了自己的按钮。": "收起,
有了自己的按鈕。", - "收起,窗口留在原处。看一眼,不用展开就看到它。置顶,它一直在最前面。侧拉,它靠在屏幕边随叫随到。收进刘海,桌面一下子空了,刘海替你看着它。窗口浏览,从 Dock 把它找出来。": "收起,視窗留在原處。看一眼,不用展開就看到它。置頂,它一直在最前面。側拉,它靠在螢幕邊隨叫隨到。收進瀏海,桌面一下子空了,瀏海替你看著它。視窗瀏覽,從 Dock 把它找出來。", + "收起,窗口留在原处;不用展开,停在上面就能看一眼。要一直看就置顶,或者侧拉到屏幕边随叫随到。收进刘海后桌面一下子空了,有需要还能从 Dock 的窗口浏览里找出来。": "收起,視窗留在原處;不用展開,停在上面就能看一眼。要一直看就置頂,或者側拉到螢幕邊隨叫隨到。收進瀏海後桌面一下子空了,有需要還能從 Dock 的視窗瀏覽裡找出來。", "收进刘海": "收進瀏海", "收进刘海的、卷帘条、侧拉的、带到每张桌面的窗口,都排在这一排里。点哪一格,哪一扇就回到原处。": "收進瀏海的、捲簾條、側拉的、帶到每張桌面的視窗,都排在這一排裡。點哪一格,哪一扇就回到原處。", - "收进刘海默认关闭,在设置里打开。朝刘海甩一下标题栏,窗口缩小、飞进刘海,桌面一下子空了。刘海两边露出它的图标和个数;指针停上去,刘海往下展开成一排,点一下,它回到原处。": "收進瀏海預設關閉,在設定裡開啟。朝瀏海甩一下標題列,視窗縮小、飛進瀏海,桌面一下子空了。瀏海兩邊露出它的圖示和個數;指標停上去,瀏海往下展開成一排,點一下,它回到原處。", + "收进刘海默认关闭,在设置里打开。朝刘海甩一下标题栏,窗口缩小、飞进刘海,桌面一下子空了。刘海两边会露出它的图标和个数;指针停上去,刘海向下展开一排窗口,点一下就回到原处。": "收進瀏海預設關閉,在設定裡開啟。朝瀏海甩一下標題列,視窗縮小、飛進瀏海,桌面一下子空了。瀏海兩邊會露出它的圖示和個數;指標停上去,瀏海向下展開一排視窗,點一下就回到原處。", "改一次当年的控制面板": "改一次當年的控制面板", "改完设置,按那个次数点标题栏。用触屏或键盘的话,点“按当前设置演示一次”。": "改完設定,按那個次數點標題列。用觸螢幕或鍵盤的話,點“按當前設定示範一次”。", "改成 3 次点击,再双击试试。": "改成 3 次點選,再按兩下試試。", @@ -390,7 +390,7 @@ "翻开窗口往事": "翻開視窗往事", "老动作之外,
WindowShade 还帮你看住每扇窗口。": "老動作之外,
WindowShade 還幫你看住每扇視窗。", "能。外接显示器上,菜单栏正中有一个看不见的刘海。它平时不露面,收着窗口时才显出来;朝它甩一下,同样收得进去。": "能。外接顯示器上,選單列正中有一個看不見的瀏海。它平時不露面,收著視窗時才顯出來;朝它甩一下,同樣收得進去。", - "要 macOS 15 以上。Apple Silicon 用主下载包。Intel 从 1.0.21 起有单独的实验包。它只在 Rosetta 下跑过基本测试,没在真 Intel Mac 上试过。刷脸解锁、声纹和合盖效果在 Intel 上关闭。还在 macOS 14 的,继续用 1.0.16。收起、看一眼和手势都不用特别的硬件;合盖效果需要带铰链传感器的 MacBook。": "要 macOS 15 以上。Apple Silicon 用主下載包。Intel 從 1.0.21 起有單獨的實驗包。它只在 Rosetta 下跑過基本測試,沒在真 Intel Mac 上試過。刷臉解鎖、聲紋和合蓋效果在 Intel 上關閉。還在 macOS 14 的,繼續用 1.0.16。收起、看一眼和手勢都不用特別的硬體;合蓋效果需要帶鉸鏈感測器的 MacBook。", + "要 macOS 15 以上。Apple Silicon 用主下载包;Intel 从 1.0.21 起有单独的实验包。1.0.23 起在 2017 款 MacBook 上实测过:“看一眼”已达到流畅标准(卡顿预算),收起、展开与窗口浏览仍未达标,属实验版。刷脸解锁、声纹和合盖效果在 Intel 上关闭。还在 macOS 14 的,继续用 1.0.16。收起、看一眼和手势都不用特别的硬件;合盖效果需要带铰链传感器的 MacBook。": "要 macOS 15 以上。Apple Silicon 用主下載包;Intel 從 1.0.21 起有單獨的實驗包。1.0.23 起在 2017 款 MacBook 上實測過:“看一眼”已達到流暢標準(卡頓預算),收起、展開與視窗瀏覽仍未達標,屬實驗版。刷臉解鎖、聲紋和合蓋效果在 Intel 上關閉。還在 macOS 14 的,繼續用 1.0.16。收起、看一眼和手勢都不用特別的硬體;合蓋效果需要帶鉸鏈感測器的 MacBook。", "要一直看的,
就让它一直在前面。": "要一直看的,
就讓它一直在前面。", "要什么权限?": "要什麼權限?", "计算器": "計算器", From 8bb721a0387d555abba91224665181b26713860c Mon Sep 17 00:00:00 2001 From: Aaron <12213433+surfine@users.noreply.github.com> Date: Sun, 29 Nov 2026 02:50:57 +0800 Subject: [PATCH 24/27] =?UTF-8?q?docs(1.0.23):=20=E9=80=9F=E5=BA=A6?= =?UTF-8?q?=E8=AF=B4=E6=B3=95=E4=B8=8E=E5=AE=9E=E6=B5=8B=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 「2–4 倍」把窗口浏览打开也算进去了,但它只是 412–414 → 352–356(约 15%)。 三份 README 与 CHANGELOG 改成:收起/展开 3.5–5 倍、窗口浏览关闭约 3 倍、打开约 15%; M5 展开写成「约 40 → 20–24 ms/s」,不再说「快一倍」。 --- CHANGELOG.md | 2 +- README.md | 4 ++-- README_CN.md | 4 ++-- README_TW.md | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71a8d7b8..2d646e40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ One line per release. Full notes, downloads and checksums are on [GitHub Release | Version | Date | Highlights | | --- | --- | --- | -| [1.0.23](docs/releases/v1.0.23.md) | 2026-11-29 | Intel build measured on a real 2017 MacBook: Glance inside Apple's hitch budget, roll-up / unfold / window browser 2–4× cheaper but still over; the same fixes help Apple Silicon; the window browser no longer clips the last line with always-on scroll bars. / Intel 实验版首次在真机量测:看一眼进预算,收起/展开/窗口浏览快 2–4 倍但仍超;同一批修正也带回 Apple Silicon;窗口浏览不再裁掉最后一行。 | +| [1.0.23](docs/releases/v1.0.23.md) | 2026-11-29 | Intel build measured on a real 2017 MacBook: Glance inside Apple's hitch budget, roll-up and unfold 3.5–5× cheaper, window-browser close ~3× and open ~15%, all four still over; the same fixes help Apple Silicon; the window browser no longer clips the last line with always-on scroll bars. / Intel 实验版首次在真机量测:看一眼进预算,收起/展开快 3.5–5 倍、窗口浏览关闭约 3 倍、打开约省 15%,四类仍超;同一批修正也带回 Apple Silicon;窗口浏览不再裁掉最后一行。 | | [1.0.22](docs/releases/v1.0.22.md) | 2026-11-16 | Notch edges settled, three Stage Manager edge cases, one title-bar target rule, Bluetooth permission, four dead switches gone, shortcuts for new setups. / 刘海边界收拾干净,台前调度三处边界;标题栏目标统一、蓝牙授权、四个假开关下架、新装带回快捷键。 | | [1.0.21](docs/releases/v1.0.21.md) | 2026-11-09 | First experimental Intel build; the notch's springs and expanded shape match the macOS 27.3 system island. Beta channel only. / 首个 Intel 实验版;刘海的弹簧与展开几何对齐 macOS 27.3 系统灵动岛。只走测试频道。 | | [1.0.20](docs/releases/v1.0.20.md) | 2026-11-02 | A Features page with eight real switches, seeded from what you already use; window fixes for macOS 26 double-click, fold flash and corner parking. / 功能页与 8 个真开关,升级保持原样;修好 macOS 26 双击缩放、收起闪屏与角落停车。 | diff --git a/README.md b/README.md index c07c3ced..f37a5691 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Unlike minimizing, the window never leaves the desktop. Drag the bar somewhere e Get the latest DMG from [Releases](https://github.com/surfine/WindowShade/releases/latest), open it, drag `WindowShade.app` onto Applications, then open it and follow the permission prompts. (The ZIP is the same app and is what in-app updates use.) It lives in the menu bar and stays out of your Dock. - **Needs macOS 15 or later.** Apple Silicon is the main build. -- **Intel Macs (experimental, from 1.0.21).** Releases also has a separate `-intel.zip` download. From 1.0.23, it has been measured and tuned on a real 2017 MacBook (MacBook10,1): Glance meets Apple’s smoothness target (hitch budget). Rolling up, unfolding, and opening or closing the window browser are 2–4× faster than in 1.0.22, though those four still exceed the budget, so the Intel build stays experimental. Face unlock, voiceprint and the lid-close desktop effect are off and hidden on Intel; pinned previews, Picture in Picture and everything else work the same. The Intel build uses its own update feed and never mixes with Apple Silicon builds. If something goes wrong, please [open an issue](https://github.com/surfine/WindowShade/issues/new). +- **Intel Macs (experimental, from 1.0.21).** Releases also has a separate `-intel.zip` download. From 1.0.23, it has been measured and tuned on a real 2017 MacBook (MacBook10,1): Glance meets Apple’s smoothness target (hitch budget). Roll-up and unfold are 3.5–5× faster than in 1.0.22, window-browser close about 3× and browser open about 15% cheaper; those four still exceed the budget, so the Intel build stays experimental. Face unlock, voiceprint and the lid-close desktop effect are off and hidden on Intel; pinned previews, Picture in Picture and everything else work the same. The Intel build uses its own update feed and never mixes with Apple Silicon builds. If something goes wrong, please [open an issue](https://github.com/surfine/WindowShade/issues/new). - **Download sizes:** the [latest release](https://github.com/surfine/WindowShade/releases/latest) lists the ZIP, the DMG and the separate Intel ZIP, each with a SHA-256 file. - **Notarized by Apple.** macOS checks it on first launch, so there’s nothing to override. - **Updating from 1.0.16 or earlier:** download this one by hand, then reopen Accessibility (and Screen Recording, if you had turned it on) in System Settings → Privacy & Security. From here on, updates install from the menu. @@ -130,7 +130,7 @@ WindowShade changes one system setting: the Dock’s minimize effect. When it ne ## In development -The current download is **1.0.23**, and everything described above is in it. This version finishes the Intel performance pass on a real 2017 MacBook: Glance now meets Apple’s smoothness target (hitch budget), and roll-up, unfold and the window browser are 2–4× faster but still over budget, so the Intel build stays experimental. The same fixes also make Apple Silicon unfold about twice as fast. It also fixes the window browser clipping the last line of a document when scroll bars are always shown. [Release notes](docs/releases/v1.0.23.md) +The current download is **1.0.23**, and everything described above is in it. This version finishes the Intel performance pass on a real 2017 MacBook: Glance now meets Apple’s smoothness target (hitch budget), and roll-up and unfold are 3.5–5× faster, window-browser close about 3× and open about 15% cheaper, but still over budget, so the Intel build stays experimental. The same fixes cut Apple Silicon unfold from about 40 to 20–24 ms/s. It also fixes the window browser clipping the last line of a document when scroll bars are always shown. [Release notes](docs/releases/v1.0.23.md) What comes next is **WindowShade 2**: your Mac’s windows taking direction, and answering to the devices at hand. The notch’s new look and gestures ship in 1.0.19; the conductor, remote and coding sessions remain behind a preview switch, not shown in Settings and not running: diff --git a/README_CN.md b/README_CN.md index e8e7ebf8..020ee619 100644 --- a/README_CN.md +++ b/README_CN.md @@ -48,7 +48,7 @@ 到 [Releases](https://github.com/surfine/WindowShade/releases/latest) 下载最新的 DMG,打开后把 `WindowShade.app` 拖到“应用程序”,再打开它,按提示给权限。(ZIP 是同一个 App,应用内更新用的就是它。)它住在菜单栏里,不占 Dock 位置。 - **要 macOS 15 以上。** 主力是 Apple Silicon 版。 -- **Intel Mac(实验,1.0.21 起)。** Releases 里另有 `-intel.zip` 安装包。从 1.0.23 起,它在 2017 款 MacBook(MacBook10,1)上做过实测和调优:“看一眼”已达到 Apple 的流畅标准(卡顿预算);收起、展开与窗口浏览的开关比 1.0.22 快 2–4 倍,但这四项仍未达标,所以继续标为实验版。刷脸解锁、声纹和合盖桌面效果在 Intel 上关闭且隐藏;置顶预览、画中画和其余功能照常。Intel 版从自己的更新清单取更新,不会与 Apple Silicon 版混用。遇到问题,请[提一个 issue](https://github.com/surfine/WindowShade/issues/new)。 +- **Intel Mac(实验,1.0.21 起)。** Releases 里另有 `-intel.zip` 安装包。从 1.0.23 起,它在 2017 款 MacBook(MacBook10,1)上做过实测和调优:“看一眼”已达到 Apple 的流畅标准(卡顿预算);收起与展开比 1.0.22 快 3.5–5 倍,窗口浏览关闭快约 3 倍、打开省约 15%;这四项仍未达标,所以继续标为实验版。刷脸解锁、声纹和合盖桌面效果在 Intel 上关闭且隐藏;置顶预览、画中画和其余功能照常。Intel 版从自己的更新清单取更新,不会与 Apple Silicon 版混用。遇到问题,请[提一个 issue](https://github.com/surfine/WindowShade/issues/new)。 - **下载包大小:** [最新 Releases](https://github.com/surfine/WindowShade/releases/latest) 会列出 ZIP、DMG 和单独的 Intel ZIP,各带一份 SHA-256。 - **已通过 Apple 公证。** 第一次打开时系统会自己检查,不用再手动放行。 - **从 1.0.16 及以前升级:** 这一版要手动下载一次,装好后在“系统设置 → 隐私与安全性”里重新打开辅助功能(开过屏幕录制的,也重新打开)。之后就能在菜单里更新。 @@ -130,7 +130,7 @@ WindowShade 只改过一项系统设置:程序坞的「最小化效果」。 ## 开发中 -当前下载版是 **1.0.23**,上面写的都在里面。这一版在 2017 款 MacBook 上收尾了 Intel 实验版的性能调优:“看一眼”已达到 Apple 的流畅标准(卡顿预算),收起、展开与窗口浏览快了 2–4 倍但仍未达标,所以 Intel 版继续标为实验版;同一批修正也让 Apple Silicon 的展开快了一倍。另外修好窗口浏览在“始终显示滚动条”时裁掉文档最后一行的问题。[发布说明](docs/releases/v1.0.23.md) +当前下载版是 **1.0.23**,上面写的都在里面。这一版在 2017 款 MacBook 上收尾了 Intel 实验版的性能调优:“看一眼”已达到 Apple 的流畅标准(卡顿预算),收起与展开快了 3.5–5 倍,窗口浏览关闭快约 3 倍、打开省约 15%,但仍未达标,所以 Intel 版继续标为实验版;同一批修正也让 Apple Silicon 的展开从约 40 降到 20–24 ms/s。另外修好窗口浏览在“始终显示滚动条”时裁掉文档最后一行的问题。[发布说明](docs/releases/v1.0.23.md) 接下来的方向是 **WindowShade 2**:让 Mac 的窗口听你指挥,也能被手边的设备遥控。刘海的新样子和新手势已在 1.0.19 里;指挥模式、遥控和编程会话仍在预览开关后面,设置里看不到,也不会运行: diff --git a/README_TW.md b/README_TW.md index d21ac449..927dd5aa 100644 --- a/README_TW.md +++ b/README_TW.md @@ -48,7 +48,7 @@ 到 [Releases](https://github.com/surfine/WindowShade/releases/latest) 下載最新的 DMG,開啟後把 `WindowShade.app` 拖進“應用程式”,再開啟它,按提示給權限。(ZIP 是同一個 App,應用程式內更新用的就是它。)它住在選單列裡,不佔 Dock 位置。 - **要 macOS 15 以上。** 主力是 Apple Silicon 版。 -- **Intel Mac(實驗,1.0.21 起)。** Releases 裡另有 `-intel.zip` 安裝包。從 1.0.23 起,它在 2017 年款 MacBook(MacBook10,1)上做過實測與調校:「看一眼」已達到 Apple 的流暢標準(卡頓預算);收起、展開與視窗瀏覽的開關比 1.0.22 快 2–4 倍,但這四項仍未達標,所以繼續標為實驗版。刷臉解鎖、聲紋和合蓋桌面效果在 Intel 上關閉且不顯示;置頂預覽、子母畫面和其餘功能照常。Intel 版從自己的更新清單取更新,不會與 Apple Silicon 版混用。遇到問題,請[提一個 issue](https://github.com/surfine/WindowShade/issues/new)。 +- **Intel Mac(實驗,1.0.21 起)。** Releases 裡另有 `-intel.zip` 安裝包。從 1.0.23 起,它在 2017 年款 MacBook(MacBook10,1)上做過實測與調校:「看一眼」已達到 Apple 的流暢標準(卡頓預算);收起與展開比 1.0.22 快 3.5–5 倍,視窗瀏覽關閉快約 3 倍、開啟省約 15%;這四項仍未達標,所以繼續標為實驗版。刷臉解鎖、聲紋和合蓋桌面效果在 Intel 上關閉且不顯示;置頂預覽、子母畫面和其餘功能照常。Intel 版從自己的更新清單取更新,不會與 Apple Silicon 版混用。遇到問題,請[提一個 issue](https://github.com/surfine/WindowShade/issues/new)。 - **下載包大小:** [最新 Releases](https://github.com/surfine/WindowShade/releases/latest) 會列出 ZIP、DMG 和單獨的 Intel ZIP,各帶一份 SHA-256。 - **已通過 Apple 公證。** 第一次開啟時系統會自己檢查,不用再手動放行。 - **從 1.0.16 及以前升級:** 這一版要手動下載一次,裝好後在“系統設定 → 隱私權與安全性”裡重新開啟輔助使用(開過螢幕錄製的,也重新開啟)。之後就能在選單裡更新。 @@ -130,7 +130,7 @@ WindowShade 只改過一項系統設定:Dock 的「最小化效果」。用到 ## 開發中 -目前下載版是 **1.0.23**,上面寫的都在裡面。這一版在 2017 年款 MacBook 上收尾了 Intel 實驗版的效能調校:「看一眼」已達到 Apple 的流暢標準(卡頓預算),收起、展開與視窗瀏覽快了 2–4 倍但仍未達標,所以 Intel 版繼續標為實驗版;同一批修正也讓 Apple Silicon 的展開快了一倍。另外修好視窗瀏覽在「永遠顯示捲動軸」時裁掉文件最後一行的問題。[釋出說明](docs/releases/v1.0.23.md) +目前下載版是 **1.0.23**,上面寫的都在裡面。這一版在 2017 年款 MacBook 上收尾了 Intel 實驗版的效能調校:「看一眼」已達到 Apple 的流暢標準(卡頓預算),收起與展開快了 3.5–5 倍,視窗瀏覽關閉快約 3 倍、開啟省約 15%,但仍未達標,所以 Intel 版繼續標為實驗版;同一批修正也讓 Apple Silicon 的展開從約 40 降到 20–24 ms/s。另外修好視窗瀏覽在「永遠顯示捲動軸」時裁掉文件最後一行的問題。[釋出說明](docs/releases/v1.0.23.md) 接下來的方向是 **WindowShade 2**:讓 Mac 的視窗聽你指揮,也能被手邊的裝置遙控。瀏海的新樣子和新手勢已在 1.0.19 裡;指揮模式、遙控和程式設計工作階段仍在預覽開關後面,設定裡看不到,也不會執行: From adc573333cf7d7ccc308a1a9584ef04ba768e7c6 Mon Sep 17 00:00:00 2001 From: Aaron <12213433+surfine@users.noreply.github.com> Date: Sun, 29 Nov 2026 03:23:53 +0800 Subject: [PATCH 25/27] =?UTF-8?q?docs(copy):=20=E5=AF=B9=E9=BD=90=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=AE=9E=E9=99=85=E9=BB=98=E8=AE=A4=E5=80=BC=E4=B8=8E?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- README_CN.md | 4 ++-- README_TW.md | 4 ++-- site/scripts/content.mjs | 8 ++++---- site/scripts/zh-hant.json | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index f37a5691..370f1439 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ WindowShade changes one system setting: the Dock’s minimize effect. When it ne ## In development -The current download is **1.0.23**, and everything described above is in it. This version finishes the Intel performance pass on a real 2017 MacBook: Glance now meets Apple’s smoothness target (hitch budget), and roll-up and unfold are 3.5–5× faster, window-browser close about 3× and open about 15% cheaper, but still over budget, so the Intel build stays experimental. The same fixes cut Apple Silicon unfold from about 40 to 20–24 ms/s. It also fixes the window browser clipping the last line of a document when scroll bars are always shown. [Release notes](docs/releases/v1.0.23.md) +The current codebase is **1.0.23** (latest shipped download is **1.0.22**), and everything described above is in it. This version finishes the Intel performance pass on a real 2017 MacBook: Glance now meets Apple’s smoothness target (hitch budget), and roll-up and unfold are 3.5–5× faster, window-browser close about 3× and open about 15% cheaper, but still over budget, so the Intel build stays experimental. The same fixes cut Apple Silicon unfold from about 40 to 20–24 ms/s. It also fixes the window browser clipping the last line of a document when scroll bars are always shown. [Release notes](docs/releases/v1.0.23.md) What comes next is **WindowShade 2**: your Mac’s windows taking direction, and answering to the devices at hand. The notch’s new look and gestures ship in 1.0.19; the conductor, remote and coding sessions remain behind a preview switch, not shown in Settings and not running: diff --git a/README_CN.md b/README_CN.md index 020ee619..ee32738b 100644 --- a/README_CN.md +++ b/README_CN.md @@ -64,7 +64,7 @@ - 左右滑占半屏;朝同一边再滑依次变成三分之二、三分之一,再滑则移到相邻屏幕。左右滑到位后再往下或往上拐,窗口占那一角。两指张开铺满,捏合撤销上次排布。 - 拖住标题栏快速甩出再松手,窗口顺着方向滑过去:往上收起,往下铺满,左右同上,朝角落甩就占那一角。普通鼠标在标题栏上滚三格算一次滑动;Magic Mouse 的支持还在真机上验证。细节见 [标题栏手势说明](docs/gestures.md)。 -**看一眼。** 指针在卷帘条上停一下,卷帘条下面就挂出一张卡片,按原来的大小显示窗口里的内容;移开,它自己收回去。单击卡片才真正展开。卷帘条留在原处,卡片和它隔着一道缝,一看就知道这是预览,不是窗口本身。它不会切换当前的 App,也不会动任何窗口。收起时被最小化的窗口拿不到实时画面,这时看到的是收起时的画面,角落会写明。细节见 [看一眼说明](docs/glance.md)。 +**看一眼。** 指针在卷帘条上停一下,卷帘条下面就挂出一张卡片,按原来的大小显示窗口里的内容;移开,它自己收回去。单击卡片才真正展开;在支持力度触控的触控板上用力按住卷帘条也能看一眼,松手收回。卷帘条留在原处,卡片和它隔着一道缝,一看就知道这是预览,不是窗口本身。它不会切换当前的 App,也不会动任何窗口。收起时被最小化的窗口拿不到实时画面,这时看到的是收起时的画面,角落会写明。细节见 [看一眼说明](docs/glance.md)。 **带到每张桌面、置顶。** 按 `⌃⌘G` 把当前窗口带到每张桌面:窗口留在原处,别的桌面右上角出现它的卷帘条;停在上面看一眼(窗口被隐藏或最小化时改显示带提示的截图),单击画面就回到它,再按一次放下。按 `⌃⌘P` 把那扇窗口置顶,你切到别的窗口,它也不会被盖住;菜单栏里能看到所有置顶的窗口,也能一次全部取消。 @@ -130,7 +130,7 @@ WindowShade 只改过一项系统设置:程序坞的「最小化效果」。 ## 开发中 -当前下载版是 **1.0.23**,上面写的都在里面。这一版在 2017 款 MacBook 上收尾了 Intel 实验版的性能调优:“看一眼”已达到 Apple 的流畅标准(卡顿预算),收起与展开快了 3.5–5 倍,窗口浏览关闭快约 3 倍、打开省约 15%,但仍未达标,所以 Intel 版继续标为实验版;同一批修正也让 Apple Silicon 的展开从约 40 降到 20–24 ms/s。另外修好窗口浏览在“始终显示滚动条”时裁掉文档最后一行的问题。[发布说明](docs/releases/v1.0.23.md) +当前代码版本是 **1.0.23**(最新已发布下载版为 **1.0.22**),上面写的都在里面。这一版在 2017 款 MacBook 上收尾了 Intel 实验版的性能调优:“看一眼”已达到 Apple 的流畅标准(卡顿预算),收起与展开快了 3.5–5 倍,窗口浏览关闭快约 3 倍、打开省约 15%,但仍未达标,所以 Intel 版继续标为实验版;同一批修正也让 Apple Silicon 的展开从约 40 降到 20–24 ms/s。另外修好窗口浏览在“始终显示滚动条”时裁掉文档最后一行的问题。[发布说明](docs/releases/v1.0.23.md) 接下来的方向是 **WindowShade 2**:让 Mac 的窗口听你指挥,也能被手边的设备遥控。刘海的新样子和新手势已在 1.0.19 里;指挥模式、遥控和编程会话仍在预览开关后面,设置里看不到,也不会运行: diff --git a/README_TW.md b/README_TW.md index 927dd5aa..377dda50 100644 --- a/README_TW.md +++ b/README_TW.md @@ -64,7 +64,7 @@ - 左右滑佔半螢幕;朝同一邊再滑依序變成三分之二、三分之一,再滑則移到相鄰螢幕。左右滑到位後再往下或往上拐,視窗佔那一角。兩指張開鋪滿,捏合還原上次排布。 - 拖移標題列快速甩出再鬆手,視窗順著方向滑過去:往上收起,往下鋪滿,左右同上,朝角落甩就佔那一角。普通滑鼠在標題列上捲動三格算一次滑動;巧控滑鼠的支援還在真機上驗證。細節見 [標題列手勢說明](docs/gestures.md)。 -**看一眼。** 指標在捲簾條上停一下,捲簾條下面就掛出一張卡片,按原來的大小顯示視窗裡的內容;移開,它自己收回去。按一下卡片才真正展開。捲簾條留在原處,卡片和它隔著一道縫,一看就知道這是預覽,不是視窗本身。它不會切換當前的 App,也不會動任何視窗。收起時被最小化的視窗拿不到即時畫面,這時看到的是收起時的畫面,角落會寫明。細節見 [看一眼說明](docs/glance.md)。 +**看一眼。** 指標在捲簾條上停一下,捲簾條下面就掛出一張卡片,按原來的大小顯示視窗裡的內容;移開,它自己收回去。按一下卡片才真正展開;在支援力度觸控的觸控式軌跡板上用力按住捲簾條也能看一眼,鬆手收回。捲簾條留在原處,卡片和它隔著一道縫,一看就知道這是預覽,不是視窗本身。它不會切換當前的 App,也不會動任何視窗。收起時被最小化的視窗拿不到即時畫面,這時看到的是收起時的畫面,角落會寫明。細節見 [看一眼說明](docs/glance.md)。 **帶到每張桌面、置頂。** 按 `⌃⌘G` 把當前視窗帶到每張桌面:視窗留在原處,別的桌面右上角出現它的捲簾條;停在上面看一眼(視窗被隱藏或最小化時改顯示帶提示的截圖),按一下畫面就回到它,再按一次放下。按 `⌃⌘P` 把那扇視窗置頂,你切到別的視窗,它也不會被蓋住;選單列裡能看到所有置頂的視窗,也能一次全部取消。 @@ -130,7 +130,7 @@ WindowShade 只改過一項系統設定:Dock 的「最小化效果」。用到 ## 開發中 -目前下載版是 **1.0.23**,上面寫的都在裡面。這一版在 2017 年款 MacBook 上收尾了 Intel 實驗版的效能調校:「看一眼」已達到 Apple 的流暢標準(卡頓預算),收起與展開快了 3.5–5 倍,視窗瀏覽關閉快約 3 倍、開啟省約 15%,但仍未達標,所以 Intel 版繼續標為實驗版;同一批修正也讓 Apple Silicon 的展開從約 40 降到 20–24 ms/s。另外修好視窗瀏覽在「永遠顯示捲動軸」時裁掉文件最後一行的問題。[釋出說明](docs/releases/v1.0.23.md) +目前程式碼版本是 **1.0.23**(最新已釋出下載版為 **1.0.22**),上面寫的都在裡面。這一版在 2017 年款 MacBook 上收尾了 Intel 實驗版的效能調校:「看一眼」已達到 Apple 的流暢標準(卡頓預算),收起與展開快了 3.5–5 倍,視窗瀏覽關閉快約 3 倍、開啟省約 15%,但仍未達標,所以 Intel 版繼續標為實驗版;同一批修正也讓 Apple Silicon 的展開從約 40 降到 20–24 ms/s。另外修好視窗瀏覽在「永遠顯示捲動軸」時裁掉文件最後一行的問題。[釋出說明](docs/releases/v1.0.23.md) 接下來的方向是 **WindowShade 2**:讓 Mac 的視窗聽你指揮,也能被手邊的裝置遙控。瀏海的新樣子和新手勢已在 1.0.19 裡;指揮模式、遙控和程式設計工作階段仍在預覽開關後面,設定裡看不到,也不會執行: diff --git a/site/scripts/content.mjs b/site/scripts/content.mjs index cb70e438..31e68aa6 100644 --- a/site/scripts/content.mjs +++ b/site/scripts/content.mjs @@ -171,7 +171,7 @@ export const copy = { browseKicker: '窗口浏览', browseTitle: '找窗口,
从它的应用找起。', browseIntro: '把指针停在 Dock 里的应用图标上,窗口浏览会列出这个应用开着的窗口,每扇都带画面和标题。认准了再动手,只会动你选的那一扇。', - browseHow: '也可以从菜单栏的“选择窗口…”打开,或者按你自己设的快捷键。面板顶部是搜索框。Dock 入口默认关闭,在“设置 → 窗口浏览”里打开。', + browseHow: '也可以从菜单栏的“选择窗口…”打开,或按你自己设的快捷键。面板顶部是搜索框。Dock 入口默认打开,可以在“设置 → 窗口浏览”里关掉。', browsePoints: [ ['先看清,再动手', '面板只用来看。按下卡片上的按钮,才会动那扇窗口。'], ['按空格,看大图', '选中一扇窗口按空格,打开大图预览。窗口不会被切到前面,也不会移动。'], @@ -226,7 +226,7 @@ export const copy = { ['侧拉和置顶有什么不一样?', '置顶只是让窗口一直在最前面,位置不变。侧拉让窗口靠在屏幕边:要用时拉出来,不用时收到边外,换到别的桌面也拉得出来。'], ['我装了 Swish,会打架吗?', '不会。Swish 在运行时,标题栏上的手势交给它;卷帘条上的下拉照常。'], ['快捷键按了没反应?', '多半是开着“安全输入”:比如在输入密码的时候,系统不把按键交给别的应用。别的窗口管理工具占用了同一个组合,也会这样。遇到这两种情况,刘海或菜单栏会说一句是哪一种。'], - ['刘海会换掉系统的音量和亮度提示吗?', '默认不会。在设置里打开“音量和亮度”,按这些键时刘海里才显示。之后想看回系统自己的提示,再打开“改回用系统的提示”。这时 WindowShade 只旁听、不拦按键:系统的提示照常出现,刘海里也跟着显示。'], + ['刘海会换掉系统的音量和亮度提示吗?', '允许辅助功能后,“音量和亮度”默认打开,按这些键时在刘海里显示。想看回系统自己的提示,可以在设置里打开“改回用系统的提示”(WindowShade 只旁听不拦键,系统的提示照常出现,刘海里也跟着显示),或者直接关掉“音量和亮度”。'], ['出了问题,怎么告诉你们?', '在“设置 → 高级 → 关于”里点“报告问题”。也可以先“导出诊断信息”:它只存在你的电脑上,不会上传,发不发给我们由你决定。同一处还能导出、导入设置,导入前会先留一份备份。'], ['所有窗口都能收起来吗?', '普通窗口都可以。便笺用系统自己的收起方式;Adobe 这类自己画标题栏的应用会单独处理。全屏、分屏、台前调度和多显示器还有少数情况没覆盖,建议先在你常用的应用里试一次。'], ['怎么装?', '下载 DMG 打开,把 WindowShade.app 拖进“应用程序”;也可以下 ZIP 解压。Intel 实验版只有 ZIP,没有 DMG。安装包已通过 Apple 公证。从 1.0.16 及以前升级,装好后重新打开辅助功能(开过屏幕录制的,也重新打开)。'], @@ -391,7 +391,7 @@ export const copy = { browseKicker: 'Window browsing', browseTitle: 'Looking for a window?
Start with its app.', browseIntro: 'Rest the pointer on an app’s icon in the Dock and window browsing lists every window that app has open, each with a picture and a title. Pick the right one first; only that window is touched.', - browseHow: 'You can also open it from Choose window… in the menu bar, or with a shortcut you set. The search field is at the top of the panel. The Dock entry is off by default; turn it on in Settings → Window browsing.', + browseHow: 'You can also open it from Choose window… in the menu bar, or with a shortcut you set. The search field is at the top of the panel. The Dock entry is on by default; you can turn it off in Settings → Window browsing.', browsePoints: [ ['Look first, then act', 'The panel is for looking. A window changes only when you press a button on its card.'], ['Space for a closer look', 'Select a window and press Space for a large preview. The window isn’t brought forward or moved.'], @@ -446,7 +446,7 @@ export const copy = { ['I use Swish. Will they clash?', 'No. While Swish is running, title-bar gestures are left to it; pulling down on a rolled-up bar still works.'], ['Does window browsing move my windows?', 'No, not unless you press a button on a card. Before it acts, it checks once more that the window is still the one you picked. If it can’t be sure, it does nothing.'], ['A shortcut does nothing. Why?', 'Most likely Secure Input is on: while you type a password, for example, macOS keeps keystrokes from other apps. Another window manager holding the same combination does the same. In either case, the notch or the menu bar says which one it is.'], - ['Does the notch replace the volume and brightness display?', 'Not by default. Turn on Volume & brightness in Settings and the notch shows them when you press those keys. If you’d rather keep the system’s own display, also turn on Use the System’s Volume and Brightness Pop-ups. WindowShade then only listens: the keys go through, the system shows its own display and the notch follows along.'], + ['Does the notch replace the volume and brightness display?', 'With Accessibility allowed, Volume & brightness is on by default and shows in the notch when you press those keys. If you’d rather keep the system’s own display, turn on Use the System’s Volume and Brightness Pop-ups (WindowShade only listens: the system shows its own display and the notch follows along), or turn off Volume & brightness.'], ['Something’s wrong. How do I tell you?', 'In Settings → Advanced → About, click Report a Problem. You can also Export Diagnostics first: the file stays on your Mac, nothing is uploaded, and you decide whether to send it. The same place exports and imports settings; importing makes a backup first.'], ['Does it work with every window?', 'With regular windows, yes. Stickies rolls up in its own system way; apps like Adobe’s that draw their own title bars are handled separately. Full screen, Split View, Stage Manager and multiple displays still have a few gaps. Try it once with the apps you use.'], ['How do I install it?', 'Download the DMG, open it and drag WindowShade.app into Applications; a ZIP works too. The experimental Intel build is a ZIP only, with no DMG. The app is notarized by Apple. From 1.0.16 or earlier, after installing, reopen Accessibility (and Screen Recording, if you had turned it on).'], diff --git a/site/scripts/zh-hant.json b/site/scripts/zh-hant.json index d2956c54..99848fba 100644 --- a/site/scripts/zh-hant.json +++ b/site/scripts/zh-hant.json @@ -79,7 +79,7 @@ "为什么是收起": "為什麼是收起", "主导航": "主導航", "主屏幕": "主螢幕", - "也可以从菜单栏的“选择窗口…”打开,或者按你自己设的快捷键。面板顶部是搜索框。Dock 入口默认关闭,在“设置 → 窗口浏览”里打开。": "也可以從選單列的“選擇視窗…”開啟,或者按你自己設的快速鍵。面板頂部是搜尋框。Dock 入口預設關閉,在“設定 → 視窗瀏覽”裡開啟。", + "也可以从菜单栏的“选择窗口…”打开,或按你自己设的快捷键。面板顶部是搜索框。Dock 入口默认打开,可以在“设置 → 窗口浏览”里关掉。": "也可以從選單列的“選擇視窗…”開啟,或按你自己設的快速鍵。面板頂部是搜尋框。Dock 入口預設開啟,可以在“設定 → 視窗瀏覽”裡關掉。", "也可以直接双击便笺顶上那条标题栏。": "也可以直接按兩下便箋頂上那條標題列。", "产品说明": "產品說明", "什么时候读": "什麼時候讀", @@ -99,6 +99,7 @@ "便笺标题栏。双击收起或展开这张便笺。": "便箋標題列。按兩下收起或展開這張便箋。", "便笺至今还留着这一招": "便箋至今還留著這一招", "做法各不相同。按 Deskovery 自己的说明,它显示的是原窗口的一个副本,原窗口被挪出屏幕或最小化。看上去一样,背后是另一套办法。": "做法各不相同。按 Deskovery 自己的說明,它顯示的是原視窗的一個副本,原視窗被挪出螢幕或最小化。看上去一樣,背後是另一套辦法。", + "允许辅助功能后,“音量和亮度”默认打开,按这些键时在刘海里显示。想看回系统自己的提示,可以在设置里打开“改回用系统的提示”(WindowShade 只旁听不拦键,系统的提示照常出现,刘海里也跟着显示),或者直接关掉“音量和亮度”。": "允許輔助使用後,“音量和亮度”預設開啟,按這些鍵時在瀏海里顯示。想看回系統自己的提示,可以在設定裡開啟“改回用系統的提示”(WindowShade 只旁聽不攔鍵,系統的提示照常出現,瀏海里也跟著顯示),或者直接關掉“音量和亮度”。", "先别关掉": "先別關掉", "先别关掉它。": "先別關掉它。", "先有一个小工具,
后来才是系统功能。": "先有一個小工具,
後來才是系統功能。", @@ -432,6 +433,5 @@ "面板收起了。把指针停到 Dock 图标上,或者点一下。": "面板收起了。把指標停到 Dock 圖示上,或者點一下。", "音乐": "音樂", "音乐、耳机、隔空投送和路线这几项,与刘海共用最多三个入口。轻扫切换,长按展开。": "音樂、耳機、AirDrop和路線這幾項,與瀏海共用最多三個入口。輕掃切換,長按展開。", - "预览": "預覽", - "默认不会。在设置里打开“音量和亮度”,按这些键时刘海里才显示。之后想看回系统自己的提示,再打开“改回用系统的提示”。这时 WindowShade 只旁听、不拦按键:系统的提示照常出现,刘海里也跟着显示。": "預設不會。在設定裡開啟“音量和亮度”,按這些鍵時瀏海里才顯示。之後想看回系統自己的提示,再開啟“改回用系統的提示”。這時 WindowShade 只旁聽、不攔按鍵:系統的提示照常出現,瀏海里也跟著顯示。" + "预览": "預覽" } \ No newline at end of file From ac05473d35ddb2c29b1b102b5918be310d8759b1 Mon Sep 17 00:00:00 2001 From: Aaron <12213433+surfine@users.noreply.github.com> Date: Sun, 29 Nov 2026 03:27:05 +0800 Subject: [PATCH 26/27] =?UTF-8?q?docs(copy-guide):=20=E8=A1=A5=E8=AE=B0?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E9=BB=98=E8=AE=A4=E5=80=BC=E6=A0=B8=E5=AF=B9?= =?UTF-8?q?=E3=80=81=E5=AE=98=E7=BD=91=E5=90=8C=E6=AD=A5=E4=B8=8E=E7=B9=81?= =?UTF-8?q?=E4=BD=93=E6=A0=A1=E5=AF=B9=E7=BA=AA=E5=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/copy-guide.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/copy-guide.md b/docs/copy-guide.md index 5a67d60f..3442284a 100644 --- a/docs/copy-guide.md +++ b/docs/copy-guide.md @@ -240,3 +240,16 @@ - 这句话里有没有只有我们才懂的词? - 同一个东西,别处是不是叫了另一个名字? - 删掉一个词、删掉半句话,意思还在吗?在就删。 + +## 维护与同步纪律(2026-11-29 实作补记) + +1. **事实以代码与 appcast 为准,不照抄旧文案。** + - 功能默认开关以 `prototype/Core/ReleaseDefaults.swift` 和对应设置逻辑为准(例如 `WindowBrowserDockEnabled`、`Notch.levelKeys.enabled` 均默认开启),改代码默认值时同步检查 README 与 `site/scripts/content.mjs`。 + - 版本号分两层:`README*.md` 顶部的 `` 由 `scripts/readme-status.py` 对齐 `site/public/appcast.xml`(已上架可下载版);`prototype/Info.plist` 与 `docs/releases/` 可能已推进到下一版。“开发中”段落要写清“当前代码版本”和“最新已发布下载版”,避免和顶部状态栏打架。 +2. **官网改动后必跑的同步链。** + - 改完 `site/scripts/content.mjs` 的简体文案后,必须重跑 `python3 tools/localize/site-zh-hant.py` 重新生成 `site/scripts/zh-hant.json`,再跑 `npm --prefix site run build && npm --prefix site run check`。 + - 需要上线时运行 `npm --prefix site run deploy`。跨分支同步(如把文案改动 cherry-pick 到 `main`)时,保留目标分支自己的版本号与发布事实,不要把未合并分支的版本号带过去。 +3. **繁体(`README_TW.md`)常见漏网词。** + - 保持 Apple 台湾写法:`Dock`(不用“程式塢”)、`分割顯示`(不用“分割畫面”)、`幕前調度`(不用“台前排程”)、`還原`(不用“撤銷”)、`空白鍵`(不用“空格”)、`觸控式軌跡板`(Mac 本机,不用“觸控板”)、`透過`(表示经由,不用“通過”)。 +4. **长段与术语处理。** + - 超过四五句的密集说明(如标题栏手势、窗口浏览、权限说明)拆成条列或短段;工程词(如“卡顿预算 / hitch budget”)首次出现用白话说明;避免连续多句同骨架排比,也不用破折号(`——` / `—`)硬接补充说明。 From a6b5ccb457e106f786373f735cea2f3aea559d02 Mon Sep 17 00:00:00 2001 From: Aaron <12213433+surfine@users.noreply.github.com> Date: Sun, 29 Nov 2026 03:33:47 +0800 Subject: [PATCH 27/27] web(site): apply modern-web-guidance and no-slop audit fixes --- site/scripts/build.mjs | 2 +- site/scripts/history.mjs | 10 +++++----- site/style.css | 12 +++++++++--- site/theme.js | 36 +++++++++++++++++++++++++++++++----- 4 files changed, 46 insertions(+), 14 deletions(-) diff --git a/site/scripts/build.mjs b/site/scripts/build.mjs index 8c1bc4dd..77b69911 100644 --- a/site/scripts/build.mjs +++ b/site/scripts/build.mjs @@ -155,7 +155,7 @@ await writeFile(path.join(dist, 'privacy/index.html'), ` ${shareMeta({ origin, path: '/privacy/', title: '权限与隐私 · WindowShade', description: 'WindowShade 读到的每一样都列在这里。', image: '/media/og.jpg', imageAlt: copy.zh.shareAlt, en: false })} ${shareFallback}${siteHeader('zh-CN', 'privacy')}${privacyMain()}${siteFooter('zh-CN')}`); -await writeFile(path.join(dist, '404.html'), `WindowShade · 404

这一页,暂时不在这里。

This page has wandered off.

回到首页 / Home
`); +await writeFile(path.join(dist, '404.html'), `WindowShade · 404

这一页,暂时不在这里。

This page has wandered off.

回到首页 / Home
`); await writeFile(path.join(dist, twTablePath), twTableSource); await writeFile(path.join(dist, 'robots.txt'), `User-agent: *\nAllow: /\nSitemap: ${origin}/sitemap.xml\n`); await writeFile(path.join(dist, 'sitemap.xml'), `${origin}/${origin}/en/${origin}/tw/${origin}/history/${origin}/en/history/${origin}/tw/history/${origin}/privacy/`); diff --git a/site/scripts/history.mjs b/site/scripts/history.mjs index 2f47f707..40d109b4 100644 --- a/site/scripts/history.mjs +++ b/site/scripts/history.mjs @@ -53,13 +53,13 @@ export function historyPage(lang, origin) {
${heading(0,t('先看今天的桌面','START WITH TODAY’S DESKTOP'),'先别关掉它。','Don’t close it just yet.')}
${p('你正在写东西。参考资料挡住了草稿,但过会儿还要看。关掉太彻底,拖到一边又挤。','You’re writing. A reference window covers your draft, but you’ll need it again soon. Closing is too final; pushing it aside crowds everything else.')}${p('WindowShade 把窗口内容收上去,只留标题栏。后面的东西露出来了,窗口也还在原处。下面可以试试,再和最小化、总览比一比。','WindowShade rolls the contents up and leaves only the title bar. What was behind shows through, and the window stays where it was. Try it below, then compare minimizing and overview.')}
-
01 / ${t('同一张桌面,三种安排','ONE DESKTOP, THREE ARRANGEMENTS')}
DRAFT / 01

${t('还没写完的想法','An unfinished thought')}

${t('参考资料让开一下,接着写。','Move the reference aside and keep writing.')}

FIELD NOTE

${t('暂时不用。
很快回来。','Not now.
Back in a moment.')}

${t('它还在这张桌面上。','It’s still on this desk.')}

${t('选一种办法,把参考资料挪开。','Pick a way to move the reference aside.')}

${cap('三种安排都试一次。点标题栏或底部入口,把参考资料放回来。','Try each arrangement. Click the title bar or the entry at the bottom to bring the reference back.')}
${p('三种都能用。收起的窗口还在原处,只是桌面上多了一条卷帘条。最小化后桌面最干净,可要回来就得去 Dock 里找。总览能一次看到所有窗口,但整张桌面会暂时重排一遍。','All three work. A rolled-up window stays where it was, as a thin bar on the desk. Minimizing leaves the cleanest desk, but you have to find the window in the Dock to get it back. Overview shows every window at once by rearranging the whole desk for a moment.')}
+
01 / ${t('同一张桌面,三种安排','ONE DESKTOP, THREE ARRANGEMENTS')}
DRAFT / 01

${t('还没写完的想法','An unfinished thought')}

${t('参考资料让开一下,接着写。','Move the reference aside and keep writing.')}

FIELD NOTE

${t('暂时不用。
很快回来。','Not now.
Back in a moment.')}

${t('它还在这张桌面上。','It’s still on this desk.')}

${t('选一种办法,把参考资料挪开。','Pick a way to move the reference aside.')}

${cap('三种安排都试一次。点标题栏或底部入口,把参考资料放回来。','Try each arrangement. Click the title bar or the entry at the bottom to bring the reference back.')}
${p('三种都能用。收起的窗口还在原处,只是桌面上多了一条卷帘条。最小化后桌面最干净,可要回来就得去 Dock 里找。总览能一次看到所有窗口,但整张桌面会暂时重排一遍。','All three work. A rolled-up window stays where it was, as a thin bar on the desk. Minimizing leaves the cleanest desk, but you have to find the window in the Dock to get it back. Overview shows every window at once by rearranging the whole desk for a moment.')}
${heading(1,t('SYSTEM 7.5 之前','BEFORE SYSTEM 7.5'),'先有一个小工具,
后来才是系统功能。','First a utility.
Then a system feature.')}
${p('1994 年 1 月的 Mini’app’les 用户社群刊物,在一串免费和共享软件里列出了 WindowShade 1.2。署名是 Interactive Technologies 和 Rob Johnston,版权从 1989 到 1992。','The January 1994 Mini’app’les issue lists WindowShade 1.2 among freeware and shareware, credited to Interactive Technologies and Rob Johnston, with a 1989–92 copyright range.')}${p('它做的事和今天一样:双击标题栏,窗口只剩标题栏;再双击,内容回来。到了 System 7.5,Apple 把它放进了系统,升级手册还专门给它留了一页。','It did what it does today: double-click the title bar and only the bar is left; double-click again and the contents come back. With System 7.5, Apple built it into the system and gave it a page in the upgrade guide.')}${cite('early',t('1994 年通讯','The 1994 newsletter'))} ${cite('manual',t('System 7.5 手册','System 7.5 manual'))}
-
${heading(2,'1994 · SYSTEM 7.5','点两下还是三下,
你自己定。','Two clicks or three?
Your call.')}
${p('系统收下了这个动作,但没规定要点几下。控制面板里可以选关掉、点两下或点三下,可以要求同时按住某个键,还能决定收起时要不要响一声。','The system took the gesture on but left the count to you. The control panel let you turn it off or pick two or three clicks, require a modifier key, and choose whether it made a sound.')}${p('把设置改成三下,再照老习惯双击试试。窗口没反应的那一下,你会发现手指比脑子先动了。','Set it to three clicks, then double-click out of habit. When nothing happens, you’ll notice your fingers moved before you thought about it.')}${cite('manual',t('手册第 48 页','Manual, page 48'))}
02 / ${t('重绘控制面板','RECONSTRUCTED CONTROL PANEL')}1994
WindowShade
${t('隐藏或显示窗口的点击次数','Clicks to hide or show window')}
${t('同时使用修饰键','Also use modifier keys')}

${t('内容可以收起,
位置留在这里。','Contents can roll up.
The place stays here.')}

${t('当前:连续点击 2 次。','Current setting: click twice in succession.')}

${cap('改完设置,按那个次数点标题栏。用触屏或键盘的话,点“按当前设置演示一次”。','Change a setting, then click the title bar that many times. On touch or keyboard, use “Demonstrate the current setting”.')}
-
${heading(3,'1997 · MAC OS 8','收起,
有了自己的按钮。','Rolling up
gets a button.')}
${p('1997 年的 Mac OS 8 在标题栏右边加了一个收起按钮(collapse box)。不知道能双击的人,现在也看得到这个功能了;双击照样能用。','Mac OS 8, in 1997, added a collapse box at the right of the title bar. People who never knew about the double-click could now see the feature; the double-click still worked.')}${p('收起的窗口还能拖着走。把这条标题栏挪到别处再展开,窗口就在新位置打开。','A rolled-up window could still be dragged. Move the bar somewhere else, unroll it, and the window opens there.')}${cite('hig',t('Apple 的窗口规范,103–104 页','Apple’s window guidelines, pages 103–104'))}
03 / ${t('拖到哪,就在哪展开','IT OPENS WHERE YOU LEAVE IT')}PLATINUM
${t('拖我试试','Drag me')}

${t('收起来,拖到别处,再展开。','Roll me up, move me, unroll me.')}

${t('双击标题栏收起窗口,点右上角的方框也可以。','Double-click the title bar to roll the window up, or click the box at the top right.')}

${cap('拖动标题栏就能移动窗口;聚焦后按方向键也可以。','Drag the title bar to move the window, or focus it and use the arrow keys.')}
+
${heading(2,'1994 · SYSTEM 7.5','点两下还是三下,
你自己定。','Two clicks or three?
Your call.')}
${p('系统收下了这个动作,但没规定要点几下。控制面板里可以选关掉、点两下或点三下,可以要求同时按住某个键,还能决定收起时要不要响一声。','The system took the gesture on but left the count to you. The control panel let you turn it off or pick two or three clicks, require a modifier key, and choose whether it made a sound.')}${p('把设置改成三下,再照老习惯双击试试。窗口没反应的那一下,你会发现手指比脑子先动了。','Set it to three clicks, then double-click out of habit. When nothing happens, you’ll notice your fingers moved before you thought about it.')}${cite('manual',t('手册第 48 页','Manual, page 48'))}
02 / ${t('重绘控制面板','RECONSTRUCTED CONTROL PANEL')}1994
WindowShade
${t('隐藏或显示窗口的点击次数','Clicks to hide or show window')}
${t('同时使用修饰键','Also use modifier keys')}

${t('内容可以收起,
位置留在这里。','Contents can roll up.
The place stays here.')}

${t('当前:连续点击 2 次。','Current setting: click twice in succession.')}

${cap('改完设置,按那个次数点标题栏。用触屏或键盘的话,点“按当前设置演示一次”。','Change a setting, then click the title bar that many times. On touch or keyboard, use “Demonstrate the current setting”.')}
+
${heading(3,'1997 · MAC OS 8','收起,
有了自己的按钮。','Rolling up
gets a button.')}
${p('1997 年的 Mac OS 8 在标题栏右边加了一个收起按钮(collapse box)。不知道能双击的人,现在也看得到这个功能了;双击照样能用。','Mac OS 8, in 1997, added a collapse box at the right of the title bar. People who never knew about the double-click could now see the feature; the double-click still worked.')}${p('收起的窗口还能拖着走。把这条标题栏挪到别处再展开,窗口就在新位置打开。','A rolled-up window could still be dragged. Move the bar somewhere else, unroll it, and the window opens there.')}${cite('hig',t('Apple 的窗口规范,103–104 页','Apple’s window guidelines, pages 103–104'))}
03 / ${t('拖到哪,就在哪展开','IT OPENS WHERE YOU LEAVE IT')}PLATINUM
${t('拖我试试','Drag me')}

${t('收起来,拖到别处,再展开。','Roll me up, move me, unroll me.')}

${t('双击标题栏收起窗口,点右上角的方框也可以。','Double-click the title bar to roll the window up, or click the box at the top right.')}

${cap('拖动标题栏就能移动窗口;聚焦后按方向键也可以。','Drag the title bar to move the window, or focus it and use the arrow keys.')}
${heading(4,'2000 → 2001 → 2003','窗口有了
新去处。','Windows get
somewhere to go.')}
${p('2000 年,Apple 第一次展示 Aqua 界面和 Dock;2001 年 3 月 24 日,Mac OS X 正式上市。窗口最小化后会缩进 Dock,离开原来的位置。','Apple showed Aqua and the Dock in 2000, and Mac OS X went on sale on March 24, 2001. A minimized window now shrank into the Dock and left its place.')}${cite('aqua',t('Aqua 预告','Aqua announcement'))} ${cite('osx',t('2001 年上市资料','2001 release announcement'))}${p('后来又有了一眼看到所有窗口的办法:2003 年的 Panther 带来 Exposé,把叠在一起的窗口铺开让你挑;2011 年的 Lion 带来 Mission Control。','Later came ways to see every window at once: Exposé arrived with Panther in 2003 and spread overlapping windows out for you to pick from; Mission Control came with Lion in 2011.')}${cite('expose','Panther / Exposé')} ${cite('lion','Lion / Mission Control')}
2000

Aqua

${t('公开新界面','A new interface is unveiled')}

2001

Dock

${t('消费版 OS X 上市','Consumer OS X ships')}

2003

Exposé

${t('把窗口铺开来挑','Windows spread out to pick from')}

2011

Mission Control

${t('窗口和桌面一起看','Windows and desktops in one view')}

${p('这些都是用来找窗口的。只想让一扇窗口先让开的时候,收起还是最省事:别的窗口都不用动。','These are all for finding windows. When you only want one window out of the way for a moment, rolling it up is still the simplest: nothing else moves.')}
-
${heading(5,t('2000 年代 → 今天','THE 2000s → TODAY'),'系统不带它了,
用的人还在。','The system dropped it.
People kept using it.')}
${p('Mac OS X 不带收起功能,于是有人自己做。Unsanity 的 WindowShade X、后来的 WindowMizer 和 Deskovery 都是这么来的。它们彼此没有关系,想解决的是同一件事。','Mac OS X had no roll-up, so people built their own: Unsanity’s WindowShade X, later WindowMizer, and Deskovery. None of them were related; they solved the same problem.')}${p('做法各不相同。按 Deskovery 自己的说明,它显示的是原窗口的一个副本,原窗口被挪出屏幕或最小化。看上去一样,背后是另一套办法。','They didn’t all work the same way. Deskovery’s own documentation says it shows a copy of the window while moving the original off screen or minimizing it. It looks the same; underneath it’s something else.')}${cite('revival',t('开发者回顾','Developer retrospective'))} ${cite('deskovery',t('Deskovery 文档','Deskovery documentation'))}${p('Mac 自带的便笺一直留着这个功能。按 Apple 现在的说明,双击便笺的标题栏就能收起,第一行字会留在标题栏上,收起来也认得出是哪一张。','Stickies, which comes with every Mac, never lost it. Apple’s current guide still says to double-click a note’s title bar to collapse it, and the first line stays in the bar, so you can tell the notes apart.')}${cite('stickies',t('现行便笺手册','Current Stickies guide'))}

${t('明天还要接着做','Pick this up tomorrow')}

${t('确认周五的日程
给设计稿留批注
把旧文件归档','Confirm Friday’s schedule
Leave notes on the design draft
Archive the old files')}

${t('第一行留在标题栏。','The first line stays.')}

${t('也可以直接双击便笺顶上那条标题栏。','You can also double-click the thin bar at the top of the note.')}

-

${t('开一台真正的旧 Mac。','Boot a real old Mac.')}

${t('上面的界面都是重画的。这里跑的是真正的旧系统,由 Infinite Mac 提供。
选一台开机,照着右边的步骤,在当年的菜单里找到这个设置。','Everything above is redrawn. These are real old systems, run by Infinite Mac.
Pick one, boot it, and follow the steps to find the setting in the original menus.')}

System 7.5

${t('还没开机。','Not running yet.')}

INFINITE MAC

${t('旧系统来自:','Old systems from: ')}Infinite Mac / Mihai Parparita ↗

+
${heading(5,t('2000 年代 → 今天','THE 2000s → TODAY'),'系统不带它了,
用的人还在。','The system dropped it.
People kept using it.')}
${p('Mac OS X 不带收起功能,于是有人自己做。Unsanity 的 WindowShade X、后来的 WindowMizer 和 Deskovery 都是这么来的。它们彼此没有关系,想解决的是同一件事。','Mac OS X had no roll-up, so people built their own: Unsanity’s WindowShade X, later WindowMizer, and Deskovery. None of them were related; they solved the same problem.')}${p('做法各不相同。按 Deskovery 自己的说明,它显示的是原窗口的一个副本,原窗口被挪出屏幕或最小化。看上去一样,背后是另一套办法。','They didn’t all work the same way. Deskovery’s own documentation says it shows a copy of the window while moving the original off screen or minimizing it. It looks the same; underneath it’s something else.')}${cite('revival',t('开发者回顾','Developer retrospective'))} ${cite('deskovery',t('Deskovery 文档','Deskovery documentation'))}${p('Mac 自带的便笺一直留着这个功能。按 Apple 现在的说明,双击便笺的标题栏就能收起,第一行字会留在标题栏上,收起来也认得出是哪一张。','Stickies, which comes with every Mac, never lost it. Apple’s current guide still says to double-click a note’s title bar to collapse it, and the first line stays in the bar, so you can tell the notes apart.')}${cite('stickies',t('现行便笺手册','Current Stickies guide'))}

${t('明天还要接着做','Pick this up tomorrow')}

${t('确认周五的日程
给设计稿留批注
把旧文件归档','Confirm Friday’s schedule
Leave notes on the design draft
Archive the old files')}

${t('第一行留在标题栏。','The first line stays.')}

${t('也可以直接双击便笺顶上那条标题栏。','You can also double-click the thin bar at the top of the note.')}

+

${t('开一台真正的旧 Mac。','Boot a real old Mac.')}

${t('上面的界面都是重画的。这里跑的是真正的旧系统,由 Infinite Mac 提供。
选一台开机,照着右边的步骤,在当年的菜单里找到这个设置。','Everything above is redrawn. These are real old systems, run by Infinite Mac.
Pick one, boot it, and follow the steps to find the setting in the original menus.')}

System 7.5

${t('还没开机。','Not running yet.')}

INFINITE MAC

${t('旧系统来自:','Old systems from: ')}Infinite Mac / Mihai Parparita ↗

${heading(6,'2026 · WINDOWSHADE','三十年后,
又回到 Mac 上。','Thirty years on,
back on the Mac.')}
${p('今天的 WindowShade 是一个开源小工具,支持 macOS 15 及更新的系统,2026 年 6 月开始公开开发。名字和想法来自当年,代码是从头写的,也不是 Apple 的产品。','Today’s WindowShade is a small open-source app for macOS 15 and later, developed in public since June 2026. The name and the idea come from back then; the code is new, and it isn’t an Apple product.')}${p('双击标题栏,窗口收成一条卷帘条,留在原处;再双击,原样展开,和 1994 年一样。它还多做了几件事:把窗口置顶,边写边看参考;停在 Dock 图标上,看到那个应用的所有窗口;合上盖子时,桌面像留在原处。','Double-click the title bar and the window rolls up into a thin bar, right where it was; double-click again and it’s back, just as in 1994. It does a few more things too: pin a window so it stays in front while you work, rest on a Dock icon to see every window that app has, and close the lid while the desktop seems to stay put.')}${cite('project',t('源码与使用说明','Source and usage'))} ${t('初始公开提交,2026-06-30','Initial public commit, 2026-06-30')} ↗
${t('今天的 WindowShade:“参考资料”收成一条卷帘条,停在原处,后面的草稿露了出来','Today’s WindowShade: the Reference window rolled up into a thin bar in place, uncovering the draft behind it')}

${t('收起窗口,
留下位置。','Roll it up.
Keep its place.')}

${t('在你的 Mac 上试试,免费开源。','Try it on your Mac. It’s free and open source.')}

${t('看看它能做什么','See what it does')} →
${p('写这篇,是因为这个小功能被忘得太久了。三十年前它解决的事,今天还天天碰到:一扇窗口挡住了后面的东西,你只想让它先让开一下。','We wrote this because the feature was forgotten for too long. The problem it solved thirty years ago still comes up every day: a window is in the way, and you just want it out of the way for a minute.')}

${t('史料与致谢','Sources & acknowledgments')}

${t('文中的年份和说法,都能在下面找到出处。','Every date and claim above comes from one of these.')}

    ${sourceList}

${t('WindowShade 项目,2026-09-13。历史系统与品牌属于各自权利人。发现问题?','The WindowShade project, 2026-09-13. Historical systems and brands belong to their respective owners. Found an error?')} ${t('告诉我们','Tell us')} ↗

${siteFooter(lang)}`; } diff --git a/site/style.css b/site/style.css index aacfd217..5c115498 100644 --- a/site/style.css +++ b/site/style.css @@ -49,7 +49,8 @@ --wall:radial-gradient(120% 90% at 0% 0%,#233a6b 0%,transparent 58%),radial-gradient(90% 80% at 100% 0%,#4a2a55 0%,transparent 62%),radial-gradient(120% 90% at 70% 110%,#5a3a2a 0%,transparent 62%),#171a24; --menubar:rgba(20,22,28,.45) } -:root[data-theme=light]{color-scheme:light} +:root[data-theme=light],:root:has(> head > meta[name="color-scheme"][content="light"]){color-scheme:light} +:root:has(> head > meta[name="color-scheme"][content="dark"]){color-scheme:dark} /* Base */ *{box-sizing:border-box} @@ -446,8 +447,13 @@ details>p{font-size:var(--fs-body);line-height:1.85;color:var(--muted);padding-b /* Entrances: content settles in once, on first view. */ @media(prefers-reduced-motion:no-preference){ - .hero-copy>*{animation:arrive .8s var(--ease-out) both} - .hero-copy>:nth-child(2){animation-delay:.05s}.hero-copy>:nth-child(3){animation-delay:.1s}.hero-copy>:nth-child(4){animation-delay:.15s}.hero-copy>:nth-child(5){animation-delay:.2s} + .hero-copy>*{--stagger:.05s;animation:arrive .8s var(--ease-out) both} + @supports (animation-delay:calc(sibling-index() * .05s)){ + .hero-copy>*{animation-delay:calc((sibling-index() - 1) * var(--stagger))} + } + @supports not (animation-delay:calc(sibling-index() * .05s)){ + .hero-copy>:nth-child(2){animation-delay:.05s}.hero-copy>:nth-child(3){animation-delay:.1s}.hero-copy>:nth-child(4){animation-delay:.15s}.hero-copy>:nth-child(5){animation-delay:.2s} + } .hero-demo{animation:arrive 1s .12s var(--ease-out) both} @keyframes arrive{from{opacity:0;transform:translateY(12px)}} } diff --git a/site/theme.js b/site/theme.js index f6a4f9c9..5a8569ac 100644 --- a/site/theme.js +++ b/site/theme.js @@ -2,20 +2,46 @@ // header hairline that appears once content scrolls under it. Kept apart from app.js so pages // without the product demos (privacy, 404, the history essay) do not load them. (() => { + const STORAGE_KEY = 'windowshade-theme'; const root = document.documentElement; + const meta = document.querySelector('meta[name="color-scheme"]'); // Follow the system unless the reader picked one. const darkPreference = matchMedia('(prefers-color-scheme: dark)'); - let manualTheme = null; - try { manualTheme = localStorage.getItem('windowshade-theme'); } catch {} - if (manualTheme === 'light' || manualTheme === 'dark') root.dataset.theme = manualTheme; + const readStored = () => { + try { + const value = localStorage.getItem(STORAGE_KEY); + return value === 'light' || value === 'dark' ? value : null; + } catch { return null; } + }; + const applyScheme = (scheme) => { + if (scheme === 'light' || scheme === 'dark') { + root.dataset.theme = scheme; + if (meta) meta.content = scheme; + } else { + delete root.dataset.theme; + if (meta) meta.content = 'light dark'; + } + }; + applyScheme(readStored()); const button = document.querySelector('.theme'); const isDark = () => (root.dataset.theme ? root.dataset.theme === 'dark' : darkPreference.matches); const syncTheme = () => button?.setAttribute('aria-pressed', String(isDark())); syncTheme(); darkPreference.addEventListener('change', syncTheme); + addEventListener('storage', (event) => { + if (event.key !== STORAGE_KEY && event.key !== null) return; + applyScheme(readStored()); + syncTheme(); + }); button?.addEventListener('click', () => { - root.dataset.theme = isDark() ? 'light' : 'dark'; - try { localStorage.setItem('windowshade-theme', root.dataset.theme); } catch {} + const target = isDark() ? 'light' : 'dark'; + const system = darkPreference.matches ? 'dark' : 'light'; + const next = target === system ? null : target; + try { + if (next) localStorage.setItem(STORAGE_KEY, next); + else localStorage.removeItem(STORAGE_KEY); + } catch {} + applyScheme(next); syncTheme(); });