Repository navigation
Conversation
The mascot TimelineViews only go static while the island is collapsed and every session is idle. Expanding the panel (hover, approval, completion) re-enables them, and a live TimelineView keeps SwiftUI's update machinery on a display link: every display cycle re-runs the whole panel's layout pass (wxtsky#299). The expanded panel is the largest tree, so hovering it costs ~6-11ms of main-thread layout per frame at 60Hz and drops frames. Add a Settings -> Mascots switch, on by default, that holds the mascots still while the panel is expanded instead: - MascotAnimationGate learns `isExpanded` / `animatesWhenExpanded`, and re-anchors the schedules (epoch bump) when animation resumes. - PanelWindowController.syncMascotAnimationGate() feeds the gate the panel visibility/surface and the setting on every relevant change. - Mascots page toggle + 7 locales + README settings-table note. - Three gate tests: on by default, off holds while expanded but the collapsed bar still animates, and resuming re-anchors the schedules.
Contributor
Author
|
@wxtsky cc |
wxtsky
added a commit
that referenced
this pull request
Oct 28, 2026
…lay frame With the island open on a ProMotion screen, CodeIsland laid the whole panel out 120 times a second, every session card, the header and the footer, for as long as a mascot moved (#381, #391). The mascots drew on TimelineView(.periodic) at 20 or 8 fps, but a TimelineView whose entries are less than about a quarter second apart updates on every display frame, whatever its schedule says, and each update re-ran the panel's layout from its root. The glow behind a waiting mascot (a repeatForever animation in 18 of the mascots, pulsing on with Reduce Motion on) and the shimmer on "Thinking…" and on a running tool's name did the same. Offscreen, where no display paces it, v1.0.40 lays the panel out 6,000-47,000 times a second; v1.0.35 did too. FrameClock replaces all of it: one timer, 20 ticks a second on a grid of the reference date, running only while something on screen moves. Every clock due at a tick sees the same instant, so a tick is one wakeup and one update of the island however many mascots and labels move; clocks ticking on their own woke the island several times a frame. Sleep scenes ask for 0.12 s and tick on every other frame of the rest. The glow runs on the clock too (MascotAlertGlow: the same once-a-second pulse, from full strength), and pulses through its opacity so a frame doesn't blur the circle again; four waiting mascots went from 709M to 87M instructions a second offscreen. It holds still with Reduce Motion or with the panel hidden, and so does the shimmer. Animation speed "Off" holds the mascots still instead of redrawing the same frame. The iOS companion keeps TimelineView. Co-Authored-By: Claude Opus 5.5 <[email protected]>
wxtsky
added a commit
that referenced
this pull request
Oct 28, 2026
… idle removal and more Unreleased notes for this round: the island's 20 fps clock (#381, #391), "Always allow" holding in its session and Codex rules Codex can use (#380), shortcuts and pinned displays with a second monitor (#384), pi and Oh My Pi ringing once a task (#386), the Claude Desktop answer and background compaction fixes (#389, #388), removing idle cards (#385), the Codex Desktop thread jump (#387), the DeepSeek whale (#390) and the Grok / DeepSeek Harness sections in Group by CLI. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Owner
|
感谢 @conghuhu!你的采样和诊断方向完全正确:吉祥物的
最终的修法(已进 main:c360cfd、c22e907、8146525)是让岛上所有会动的东西共用一个每秒 20 帧的时钟( 所以这个 PR 就不合了,先关掉。非常感谢你的采样数据,它直接指向了根因。新的 changelog 条目里也注明了 #391。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
v1.0.40 在鼠标 hover 展开灵动岛后会出现明显卡顿(外接 60Hz 屏幕 + 几个会话时尤其明显)。用
sample对 CodeIsland 主线程采样(1ms 间隔)得到三组对照:hover 期间热栈几乎全是
NSHostingView.layout → ViewGraphRootValueUpdater.render → AttributeGraph 布局 → RootGeometry/LayoutEngineBox.sizeThatFits,CodeIsland 自己的业务代码只占主线程采样的 ~0.1%——也就是说不是某个函数慢,而是整个面板的 SwiftUI layout 在被每帧重跑。根因
吉祥物
TimelineView目前只在「收起且所有会话 idle」时停用(#299):MascotAnimationGate.shouldAnimate=visible && awake && !isIdleSettled && !reduceMotion;PanelWindowController.isIslandSettled()对surface.isExpanded恒返回false。所以 hover 一展开,动画立刻恢复;而一个活跃的
TimelineView会把 SwiftUI 的更新机制挂在 display link 上,每个 display cycle 都会重跑整个面板的 layout pass(MascotAnimationGate.swift里 #299 的注释已经写明这个结论)。展开面板是最大的一棵树,60Hz 下每帧约 6–11ms 主线程,鼠标移动时再叠加 hover 动画,就掉帧/发涩。改动
新增 设置 → 角色(Mascots)→「展开面板时播放吉祥物动画」,默认开启(不改变现有行为):
MascotAnimationGate增加isExpanded/animatesWhenExpanded两个状态,恢复播放时 bump epoch 重新锚定 schedules;PanelWindowController.syncMascotAnimationGate()在面板显隐、展开/收起、设置变更时统一同步给 gate;MascotAnimationGateTests用例:默认开启、关闭后展开静止但收起仍动画、恢复时 epoch 重锚。验证
swift build -c release --build-system native --arch arm64通过;CODEISLAND_ISOLATED=1启动验证通过;swift test,仓库也没有 PR CI 测试 workflow)。备注
默认开启、只是给用户一个出口;如果后续想保留动画又彻底消除这部分开销,可以把吉祥物动画移出 SwiftUI layout 图(例如每个 mascot 独立
NSHostingView,或用CADisplayLink+ 自绘),这次先做最小、可回退的一步。