---
catalog_id: "R-062"
kind: "repo"
domain: "frontend"
domain_label: "前端动效 / Frontend & Motion"
date: "2026-11-27"
title: "motiondivision/motion"
verdict: "WAAPI卸载配FLiP投影，离线逐帧踩双时钟陷阱"
summary: "面向 JS 与 React 的混合双线程动效引擎，结合 WAAPI 合成器卸载与线性采样弹簧、8 阶段批处理帧循环、FLiP 布局投影树逆缩放补偿及 AnimatePresence 退场编排，同时剖析其在离线确定性逐帧渲染中的双时钟与增量步长陷阱。"
summary_en: "Hybrid JS/React animation engine using WAAPI offloading, 8-phase frameloop, and FLiP layout projection, with dual-clock traps in offline render."
canonical_url: "https://oumuatown.com/repos/motiondivision__motion/"
markdown_url: "https://oumuatown.com/repos/motiondivision__motion.md"
og_image_zh: "https://oumuatown.com/og/zh/R-062.png"
og_image_en: "https://oumuatown.com/og/en/R-062.png"
cite_count: 83
repo: "motiondivision/motion"
github_url: "https://github.com/motiondivision/motion"
commit: "6390e6d"
tags:
  - "web-animation"
  - "react"
  - "waapi"
  - "spring-physics"
  - "flip-layout"
  - "frameloop"
github_repos:
  - "https://github.com/motiondivision/motion/tree/6390e6d"
  - "https://github.com/greensock/gsap/tree/5e6c35f"
  - "https://github.com/heygen-com/hyperframes/tree/61cea64"
  - "https://github.com/199-biotechnologies/motion-dev-animations-skill/tree/3feedfb"
---

# R-062 · motiondivision/motion

> **结论 / Verdict**: WAAPI卸载配FLiP投影，离线逐帧踩双时钟陷阱
> **EN Summary**: Hybrid JS/React animation engine using WAAPI offloading, 8-phase frameloop, and FLiP layout projection, with dual-clock traps in offline render.

## Provenance & Evidence

- Primary Repository: https://github.com/motiondivision/motion (@6390e6d)
- Referenced Repository: https://github.com/greensock/gsap/tree/5e6c35f
- Referenced Repository: https://github.com/heygen-com/hyperframes/tree/61cea64
- Referenced Repository: https://github.com/199-biotechnologies/motion-dev-animations-skill/tree/3feedfb
- Verified Source Citations (#Lxx): 83
- Web Reader: https://oumuatown.com/repos/motiondivision__motion/

# motiondivision/motion

> 仓库地址：https://github.com/motiondivision/motion · 审计版本：`motiondivision/motion@6390e6d`（`v14.14.0`） · 审计日期：2026-11-27
> 来源文章：[关联文章](../articles/2026-11-27-0xnicc0-12-hand-drawn-motion-repos.md)

## 定位与解决的真问题

- **核心定位与目标用户**：Motion Division 维护的开源 Web 与 React 动画引擎（MIT 协议，`LICENSE.md#L1-L21`；由原 Framer Motion 演进而来），同时提供轻量级原生 DOM/WAAPI 入口（`motion`）与声明式 React 组件/手势/布局引擎（`framer-motion` / `motion/react`）。
- **相比常规做法解决的关键痛点**：
  1. **主线程卡顿下的 120fps 合成器卸载**：常规纯 JS 帧循环在主线程繁忙时会丢帧，而原生 WAAPI 写法繁琐且难以串联物理弹簧与动态打断；Motion 在满足条件时自动把 `transform`/`opacity`/`clipPath`/`filter` 卸载至浏览器合成器线程（`WAAPI` + CSS `linear` 采样），并在主线程接管颜色线性混合、自定义 `onUpdate` 与中断速度继承。
  2. **DOM 布局突变与子元素变形失真**：普通 CSS 无法对 `flex`/`grid` 重排、父子结构变更或尺寸增减做顺滑补间；Motion 的 `ProjectionNode` 树在 React Commit 前后自动抓拍布局盒，利用 `scaleX`/`scaleY` 投射并沿树自顶向下传递 `treeScale` 逆向缩放补偿与 `borderRadius`/`boxShadow` 矫正，彻底消除容器变形时内部文字与圆角被拉扁的问题。
  3. **React 卸载即消失与退场占位冲突**：通过 `AnimatePresence` 延迟实际卸载直至子树全部退出动画调用 `safeToRemove`，并借助 `popLayout` 模式在绘制前把退场节点脱流定位，让兄弟节点立刻触发正确的 FLIP 补间。

## 技术栈与核心目录结构

- **语言 / 运行时 / 关键依赖**：TypeScript 5.4、React 18/19（`peerDependencies` 可选）、Rollup + Turbo Monorepo（零第三方运行时依赖，内部拆分为分层 workspace 包）。
- **关键目录树与职责划分**（`motiondivision/motion@6390e6d`，`v14.14.0`）：
  - `packages/motion-utils`：纯数学与工具层（缓动函数、插值、错误校验、`MotionGlobalConfig` 全局开关 `src/global-config.ts`）。
  - `packages/motion-dom`：与框架无关的核心运行时引擎（v14 将原 `framer-motion` 中的核心动画、渲染调度与投影树全部下沉至此）：
    - `src/frameloop/`：8 阶段读写隔离帧调度器（`batcher.ts`、`render-step.ts`、`order.ts`、`sync-time.ts`）。
    - `src/animation/`：混合双端执行层——`MultiValueAnimation.ts`（`ValueTrack` + 共享时钟）、`JSAnimation.ts`（单值 JS 动画）、`NativeAnimation.ts`（WAAPI 封装）、`waapi/transforms/TransformAnimation.ts`（元素级多通道 transform 合成组）、`keyframes/KeyframesResolver.ts` & `DOMKeyframesResolver.ts`（异步批测量解析）及 `generators/`（`spring.ts`、`inertia.ts` 解析解）。
    - `src/projection/`：`ProjectionNode` 树（`node/create-projection-node.ts`）、`NodeStack` 共享元素栈（`shared/stack.ts`）、树形变换传播（`geometry/delta-apply.ts`、`delta-calc.ts`）与圆角/阴影逆缩放矫正（`styles/transform.ts`、`scale-border-radius.ts`、`scale-box-shadow.ts`）。
    - `src/render/`：`VisualElement.ts` 与 DOM/HTML/SVG 渲染节点抽象（继承自 `src/node/MotionNode.ts`）。
  - `packages/framer-motion`：React 绑定层，承载 `<motion.*>`、`AnimatePresence`（`src/components/AnimatePresence/`）、`LayoutGroup`、`useAnimate`、手势特性及服务端 SSR 优化呈现（`optimized-appear/`）。
  - `packages/motion`：统一对外分发包（`src/index.ts` 重导出 `framer-motion/dom`，`src/react.ts` 重导出 `framer-motion`，并提供 `./mini`、./react-m` 等按需摇树子入口）。

## 核心实现源码级剖析（附文件路径与行号）

1. **8 阶段读写隔离 `frameloop` 与双缓冲任务队列**（`packages/motion-dom/src/frameloop/order.ts#L3-L12`, `packages/motion-dom/src/frameloop/batcher.ts#L6-L96`, `packages/motion-dom/src/frameloop/render-step.ts#L3-L120`, `packages/motion-dom/src/frameloop/sync-time.ts#L18-L34`）：
   - **严格 8 阶段管线**：`stepsOrder`（`order.ts#L3-L12`）固定按 `setup -> read -> resolveKeyframes -> preUpdate -> update -> preRender -> render -> postRender` 展开执行。所有 `getBoundingClientRect` / `getComputedStyle` 集中于 `read` 与 `resolveKeyframes`，物理/补间计算置于 `update`，样式写回统归 `render`，从调度层根除反复重排。
   - **双缓冲队列避免 GC**：`createRenderStep`（`render-step.ts#L8-L116`）内部维护 `thisFrame` 与 `nextFrame` 两个复用的 `Set<Process>` 及 `toKeepAlive` 集合；每步执行时直接交换引用并清空 `thisFrame`，持续帧任务（`keepAlive = true`）自动回填 `nextFrame` 并置位 `runNextFrame`，全程零数组重分配。
   - **时间增量封顶（`maxElapsed = 40` ms）与事件循环同步时钟**：`batcher.ts#L6, #L46-L60` 在非 `MotionGlobalConfig.useManualTiming` 模式下读取 `performance.now` 计算 `state.delta`：首帧用默认 `1000 / 60`，此后钳位在 `[1, 40]` ms（`Math.max(Math.min(timestamp - state.timestamp, maxElapsed), 1)`）以防止切标签页回来后动画瞬移；`sync-time.ts#L18-L34` 则用微任务级缓存把同一帧或同一事件循环内的多次 `time.now` 锚定到同一个 `frameData.timestamp`。

2. **混合 WAAPI + JS 双轨调度与 `DOMKeyframesResolver` 延迟测量**（`packages/motion-dom/src/animation/MultiValueAnimation.ts#L38-L785`, `packages/motion-dom/src/animation/animate/multi-value.ts#L254-L475`, `packages/motion-dom/src/animation/waapi/supports/waapi.ts#L28-L89`, `packages/motion-dom/src/animation/waapi/transforms/TransformAnimation.ts#L459-L1284`, `packages/motion-dom/src/animation/keyframes/KeyframesResolver.ts#L19-L295`）：
   - **架构演进与统一多轨模型**：在 v14 中，早期独立的 `AsyncMotionValueAnimation` 已被重构为 `MultiValueAnimation`（管理共享时钟与批量轨道 `ValueTrack`）及其单值子类 `JSAnimation`（`JSAnimation.ts#L18-L135`）和 `NativeAnimation`（`NativeAnimation.ts#L30-L285`）。每次 `animate` 调用由 `startValueAnimation`（`multi-value.ts#L366-L475`）为各属性创建 `ValueTrack`，并交给 `KeyframeResolver` / `DOMKeyframesResolver` 解析起始关键帧。
   - **异步批处理关键帧解析（消除 1-frame 测量卡顿）**：当起点为通配符 `[null, target]` 或需要跨单位（如 `auto` / `%` -> `px`）及 `var(--token)` 求值时，`DOMKeyframesResolver`（`DOMKeyframesResolver.ts#L48-L230`）进入异步队列（`isAsync = true`），把多个组件的样式读取聚拢到 `frame.read`，把临时移除变换→设终态→测量→还原的写读周期聚拢到 `frame.resolveKeyframes`（`KeyframesResolver.ts#L24-L113`, `#L200-L215`），直到下一帧才完成 `track.init` 并启动动画。
   - **WAAPI 分流规则与 `TransformGroup` 合成器合并**：
     - 非变换类可加速属性（`opacity`、`clipPath`、`filter`，见 `accelerated-values.ts#L8-L13`——**注意颜色被刻意排除在 `acceleratedValues` 之外**，因浏览器 WAAPI 在 sRGB 空间混色而 JS 采样器在 linear 空间混色，打断时会产生色阶跳变；仅当含 `oklch`/`oklab` 等浏览器独占色系时才由 `hasBrowserOnlyColors` 强制走 WAAPI，`waapi.ts#L80-L83`）若满足 `supportsWaapi`（需 `!MotionGlobalConfig.useManualTiming`）、无 `onUpdate`、无 `repeatDelay`、非 `mirror`、非 `inertia` 且非零阻尼（`waapi.ts#L28-L89`），直接走 `MultiValueAnimation.pool` 调 `element.animate`（`effects/style/output.ts#L25-L29`）。
     - 独立变换属性（`x`/`y`/`scale`/`rotate` 等）共用单个 CSS `transform`，故通过 `joinGroup` 汇入元素级 `TransformGroup`（`TransformAnimation.ts#L252-L287`, `#L452-L1284`）：若同元素各轨道时间参数一致，则合成单条包含完整函数序的 `transform` 关键帧，并用 `generateLinearEasing`（`linear.ts#L3-L16`）把弹簧采样为 CSS `linear(...)` 函数交给底层执行；若新动画以不同时序中途打断，则按 16ms 采样拼接或直接 `demote` 降级回主线程 `JSAnimation` Tick 驱动；一旦全部轨道进入 WAAPI，`MultiValueAnimation.isOffloaded` 置 `true` 并停止主线程 `driver`（`MultiValueAnimation.ts#L673`, `#L953`），释放主线程 CPU。
   - **关键底层细节（`createStyleAnimation`）**：`TransformGroup` 创建原生动画时**并不调用 `element.animate`**，而是通过 `createStyleAnimation` 直接 `new Animation(new KeyframeEffect(element, keyframes, options))`（`effects/style/output.ts#L38-L45`），以绕过 WebKit 中 `element.animate` 抢先播放导致后续修改 `startTime`/`playbackRate` 产生跳变的 Bug。

3. **解析解 `spring` 与 `inertia` 物理引擎**（`packages/motion-dom/src/animation/generators/spring.ts#L47-L531`, `packages/motion-dom/src/animation/generators/inertia.ts#L8-L115`, `packages/motion-dom/src/animation/generators/utils/calc-duration.ts#L7-L26`）：
   - **闭式阻尼谐振子解析解（无欧拉积分步长误差）**：`springGenerator`（`spring.ts#L272-L514`）不采用固定步长数值积分，而是根据 $\zeta = \text{damping} / (2\sqrt{\text{stiffness}\cdot\text{mass}})$ 直接分支计算精确解析解：欠阻尼（$\zeta < 1$，指数衰减包络乘正余弦并按 `t` 记忆化三角函数，支持无缝 `retarget` 复用、`#L362-L398`）、临界阻尼（$\zeta = 1$，`#L399-L412`）与过阻尼（$\zeta > 1$，快慢双指数衰减并在 `dampedAngularFreq >= 1` 触发 300 极限截断防拖尾、`#L413-L454`）。由于是时间 $t$ 的纯解析函数，同时提供解析导数 `velocity(t)` 供打断瞬间精准传递初速度，并以双阈值（`restSpeed` 默认 2 或细粒度 0.01、`restDelta` 默认 0.5 或 0.005，`#L32-L35`, `#L342-L350`, `#L481-L490`）判定静止。
   - **感知参数反演（`duration` + `bounce` / `visualDuration`）**：`findSpring`（`spring.ts#L112-L186`）借助 12 轮牛顿迭代（`approximateRoot`）把设计师直观的 `duration`/`bounce` 映射为物理 `stiffness`/`damping`（通过 `overdampedFreqScale` 对负 bounce 保持同收敛边界）；`applyToOptions` 则利用 `calcGeneratorDuration`（以 `50ms` 步进探测至多 `20_000ms`，`calc-duration.ts#L7-L26`）把无限域弹簧转化为有限时长 + CSS `linear` 供给 WAAPI。
   - **惯性抛投 `inertia`**：`inertia`（`inertia.ts#L8-L115`）以指数衰减 `-amplitude * Math.exp(-t / timeConstant)` 推算自由滑行位移；若越过 `min`/`max` 越界阈值，则在精确越界时间点 `timeReachedBoundary` 动态派生一个带有当前边界速度 `(-calcDelta(t) / timeConstant) * 1000` 的高刚度 `createSpring` 接管回弹（`#L65-L83`, `#L107-L112`）。

4. **FLIP `ProjectionNode` 树形逆缩放补偿与 `AnimatePresence`**（`packages/motion-dom/src/projection/node/create-projection-node.ts#L928-L3037`, `packages/motion-dom/src/projection/geometry/delta-apply.ts#L81-L152`, `packages/motion-dom/src/projection/styles/transform.ts#L5-L82`, `packages/motion-dom/src/projection/shared/stack.ts#L4-L92`, `packages/framer-motion/src/components/AnimatePresence/`）：
   - **Commit 前后两阶段树形测量**：React 提交 DOM 变更前，父/子节点触发 `willUpdate`（`create-projection-node.ts#L928-L1002`）强制降级加速变换（`demoteTransforms`）、临时剥离旋转/倾斜（`resetSkewAndRotation`，`#L2575-L2617`）并记录去除了祖先变换的干净页面盒 `snapshot` 及当前速度；提交后 `didUpdate` 通过微任务 `microtask.read`（`#L1094-L1099`, `#L1007-L1090`）重置变换、测新 `layout`、计算 `layoutDelta`/`visualDelta` 并触发 `setAnimationOrigin` 与单帧对齐的 `startAnimation`（`#L2251-L2414`）。
   - **层级 `treeScale` 逆向抗畸变**：在每帧 `frame.preRender` 的 `updateProjection` 中（`#L1162-L1198`），沿节点深度从上到下执行 `resolveTargetDelta -> calcProjection`，通过 `applyTreeDeltas`（`delta-apply.ts#L81-L152`）把路径上所有祖先正在播放的 `projectionDelta.scale` 累乘进当前节点的 `treeScale`。随后 `buildProjectionTransform`（`styles/transform.ts#L18-L80`）把位移除以 `treeScale`（`xTranslate / treeScale.x`），若有旋转则先插入 `scale(1 / treeScale.x, 1 / treeScale.y)` 抵消祖先畸变再施以自身角度与 `delta.scale * treeScale`；同理，`correctBorderRadius`（`scale-border-radius.ts#L17-L42`）将像素圆角按当前目标盒尺寸换算为百分比 `x% y%` 避免逐帧重绘，`correctBoxShadow`（`scale-box-shadow.ts#L17-L59`）逆除缩放以保持阴影真实厚度。同时以 `layerBudget = 400` 管控 `will-change: transform` 合成层数量（`create-projection-node.ts#L126`, `#L1174-L1192`）。
   - **共享元素 `layoutId`（`NodeStack`）**：同一 `layoutId` 挂载至同一个 `NodeStack`（`stack.ts#L4-L92`），新挂载节点在 render 阶段即提前 snapshot 旧 `lead` 防并发 Render 中途污染（`create-projection-node.ts#L369-L373`），`promote` 把旧 `lead` 的 `snapshot` 与速度接力给新 `lead` 并执行交叉淡入淡出或隐藏旧节点（`#L2659-L2768`）。
   - **`AnimatePresence` 与 `PopChild` 脱流**：`AnimatePresence`（`AnimatePresence/index.tsx#L46-L275`）对比前后子元素 `key` 集合，通过 `PresenceContext` 追踪所有后代注册节点（`PresenceChild.tsx#L60-L89`），直到所有退场节点触发 `onExitComplete` 才真正从 `renderedChildren` 剔除；在 `mode="popLayout"` 下，`PopChild`（`PopChild.tsx#L86-L266`）在 `getSnapshotBeforeUpdate` 记录脱流前精确几何位置与 `offsetParent` 坐标，并在 `useInsertionEffect` 注入高优先级 `<style>` 规则 `[data-motion-pop-id="..."]{position:absolute!important;...}` 与 `inert` 属性，随后在 `microtask.setup`/`microtask.read` 修正因外层容器塌缩造成的偏移（`#L228-L249`），使留存兄弟元素同一帧即可精准 FLIP。

5. **离线确定性逐帧步进（`window.renderAt(t)` / HyperFrames）与 GSAP 的本质对比**（`packages/motion-dom/src/frameloop/batcher.ts#L6-L57`, `packages/motion-dom/src/effects/style/output.ts#L25-L45`, `packages/motion-dom/src/animation/MultiValueAnimation.ts#L462-L677`, `packages/motion-dom/src/animation/keyframes/KeyframesResolver.ts#L200-L215`）：
   - **对比结论**：与 [greensock/GSAP](./greensock__GSAP.md) 把所有状态绑定到单一全局时间轴 `gsap.globalTimeline.totalTime(t)` 不同，Motion 的**混合架构为“交互流畅度”而设计，天然存在 4 个阻碍无头视频任意随机跳帧的机制冲突**：
     1. **双时钟与 `new Animation` 拦截盲区**：Motion 把符合条件的 `opacity`/`clipPath`/`filter` 交给 `element.animate`，而把 `transform` 组合动画直接交给 `new window.Animation(new window.KeyframeEffect(...))`（`output.ts#L38-L45`），脱离 JS `frameloop` 跑在浏览器原生 `document.timeline` 合成器线程上。如果仅用 [heygen-com/hyperframes](./heygen-com__hyperframes.md) 式的虚拟时钟垫片劫持 `performance.now` / `rAF` 甚至只 Hook `Element.prototype.animate`，**`TransformGroup` 创建的原生 `Animation` 仍会按真实墙钟自主播放或完全漏掉 Seek**——必须同时设置 `MotionGlobalConfig.useManualTiming = true`（彻底禁用 `supportsWaapi` 并改由手动时间驱动，`waapi.ts#L28-L30`、`batcher.ts#L47-L57`），或额外劫持 `window.Animation` 构造函数并遍历 `document.getAnimations` 强制 `pause` + 赋值 `currentTime`。
     2. **增量时间钳位（`maxElapsed = 40` ms）与全局无 Seek 入口**：在默认自主运行模式下，`batcher.ts#L6, #L54-L56` 强制将每帧 `delta` 钳位在 `<= 40ms`。即使外层垫片把 `performance.now` 直接从 `0` 跳到 `2000ms`，Motion 的 `JSAnimation` / `MultiValueAnimation` 只按实际调用的 `timestamp` 与 `startTime` 差值计算，或者依赖 `batcher` 的 `state.delta`——如果跳帧调用或由多进程并发 Worker 从中间帧 `t > 0` 启动，缺少统一类似 `gsap.globalTimeline.totalTime(t)` 的全局树级定位 API（`MultiValueAnimation` 的 `time` setter 仅挂在单次 `animate` 返回的局部控件句柄上，React `<motion.div>` 默认并不向外部全局注册表暴露统一的 seekable 时间轴；虽然 `JSAnimation.sample(t)` 存在，但同样只面向独立单值对象）。因此采集 Motion 页面通常只能开启 `useManualTiming` 并从 `0` 开始按固定 `dt = 1000 / fps`（确保 `< 40ms`）单调递增步进，无法零成本支持多浏览器切片并发随机 `seek`。
     3. **异步 1-Frame 关键帧解析与 `pendingAnimation` 延迟**：当 `<motion.div>` 初次挂载使用隐式初始值（如 `animate={{ x: 100 }}` 缺省 `initial`）或测量单位变换时，`DOMKeyframesResolver` 推迟至下一帧的 `frame.read -> frame.resolveKeyframes` 完成解析（`KeyframesResolver.ts#L203-L210`）；而布局动画 `ProjectionNode.startAnimation` 也刻意把首帧推迟到下一帧的 `frame.update`（`create-projection-node.ts#L2251`）。在无头抓帧中若未先空跑至少 1~2 次 rAF flush 就立即抓首帧，会导致目标元素呈现未动画或尚未测量完的闪烁态。
     4. **交互向工程选型界线**：做动态交互 Web/React 产品（高频手势拖拽打断、动态尺寸容器 FLIP、列表增删重排）选 **Motion**；做程序化短视频/科普视频离线渲染（`HyperFrames`、Playwright `renderAt(t)`、多 Worker 分片并行压片）优先选 **GSAP** 或纯函数驱动的 **Remotion**；若必须在已有 Motion 页面上录屏，必须在页面引导早期强制挂载 `MotionGlobalConfig.useManualTiming = true`（禁 WAAPI，全转 JS 轨道）并配合单调小步长 `dt <= 40ms` 与首帧预热 flush。

## 亮点设计 vs 局限/坑点

- **值得借鉴的设计**：
  - **分析解弹簧 + CSS `linear` 合成器降维**：把复杂二阶微分方程做闭式解析求解，再仅在必要时采样为浏览器原生 `linear` 字符串丢给合成器线程执行，兼顾物理真实感、零数值发散、打断瞬间精确传递解析速度以及低主线程占用。
  - **`TransformGroup` 自动合批与防抖降级（Churn Detection）**：同元素多路独立变换属性自动拼合进一条原生 `transform` 动画，而在检测到大频外部写入（100ms `churnWindow` 内重复打断，如用户连续拖拽）时自动退回主线程运行以省去重复构造 WAAPI 动画的 IPC/解析损耗（`TransformAnimation.ts#L155-L160`, `#L1158-L1161`）。
  - **带预算的合成层调度与树形反扭曲**：`layerBudget = 400` 防 GPU 显存爆炸，视口外元素不分配 `will-change`，`treeScale` + 百分比 `borderRadius` 让声明式 `layout` 动画做到“零人工算矩阵”。
- **局限、隐含假设与潜在坑点**：
  - **离线逐帧渲染的全局控制弱**：无内置统一全局时间轴对象，`TransformGroup` 通过 `new Animation` 而非 `element.animate` 起动画易穿透常规 WAAPI 劫持层，且 `DOMKeyframesResolver` 与布局动画天然带有 1 帧异步延迟。
  - **色域差异导致颜色属性故意跳过常规 WAAPI**：因为原生 WAAPI 用 sRGB 插值而 JS 采样器用 linear 空间插值（`accelerated-values.ts#L4-L7`），普通 Hex/RGB 颜色动画默认仍留主线程执行。
  - **`AnimatePresence` 严格依赖稳定 `key` 与单层阻塞**：`mode="wait"` 同时出现多个节点只取其一并警告；若子组件内部消费了 `usePresence` 却漏调 `safeToRemove`，父节点将永久滞留 DOM 中。

## 可复用的模块或设计模式

- **如何迁移到未来项目**：
  1. **通用 DOM 8 阶段 `frameloop` 调度器**：`packages/motion-dom/src/frameloop/`（`order.ts` + `render-step.ts` + `batcher.ts`）体积极小、零框架依赖，可直接移植到任何自研 Canvas/DOM 交互应用中隔离读写阶段并消除每帧 Set/Array GC 抖动。
  2. **闭式阻尼弹簧与牛顿感知参数求解器**：`packages/motion-dom/src/animation/generators/spring.ts` 无任何外部依赖，可直接抽离到物理 UI 控件、Canvas/SVG 程序化科普片或游戏 UI 动效模块中，用 `(duration, bounce)` 替代难调的 `(stiffness, damping)`。
  3. **多通道独立变换合并 + `createStyleAnimation` 避坑认知**：在构建任意 Chrome 录屏 / WAAPI 劫持基础设施（如更新 [heygen-com/hyperframes](./heygen-com__hyperframes.md) 适配器）时，必须同步拦截 `window.Animation` 构造函数（或扫描 `document.getAnimations`）并支持检测 `MotionGlobalConfig.useManualTiming`，以免漏抓 `TransformGroup` 的独立合成器轨道。
- **关联 Pattern**：[hand-drawn-pixel-stylization-and-animation-remake-loop](../patterns/hand-drawn-pixel-stylization-and-animation-remake-loop.md) · [deterministic-code-film-contract](../patterns/deterministic-code-film-contract.md) · [agentic-video-and-3d-toolchain-matrix](../patterns/agentic-video-and-3d-toolchain-matrix.md)

## Cross-Referenced Specimens

- [A-007 · 12 个手绘与像素动效开源仓库管线 + @seeconvm Fable 5.2 20 章全流程实战课程](https://oumuatown.com/articles/2026-11-27-0xnicc0-12-hand-drawn-motion-repos.md) — 手绘像素动效七仓补位与二十章代码成片排障资产库
- [R-046 · greensock/GSAP](https://oumuatown.com/repos/greensock__GSAP.md) — 双向链表场景树配时间轴随机定位，稳撑交互动效与逐帧录屏
- [R-178 · heygen-com/hyperframes](https://oumuatown.com/repos/heygen-com__hyperframes.md) — 虚拟时间垫片配 CDP 帧捕获，稳把网页动效渲染成视频
- [P-014 · 手绘像素风格化、参考动效逐帧逆向复刻与多运行时确定性寻帧闭环（Hand-Drawn/Pixel Stylization, Animation Remake & Deterministic Stepping Loop）](https://oumuatown.com/patterns/hand-drawn-pixel-stylization-and-animation-remake-loop.md) — 手绘像素四通道风格化、逆向逐帧复刻与多引擎离线寻帧闭环
- [P-004 · 确定性代码成片帧契约与无损流式渲染管线（Deterministic Code-Film Contract）](https://oumuatown.com/patterns/deterministic-code-film-contract.md) — 纯时间函数、单主时钟与无头流式直写消除代码成片漂移
- [P-001 · Agent 驱动视频剪辑、2D/3D 动画与跨宿主技能选型矩阵（Agentic Video, 3D & Skill Toolchain Matrix）](https://oumuatown.com/patterns/agentic-video-and-3d-toolchain-matrix.md) — 视频生成、三维自动化与跨宿主技能选型边界与避坑矩阵
- [P-034 · 代码艺术风格配方、参数化解说语法与全链路防 AI-Slop 门禁体系（Artistic Style Recipes, Explainer Grammars & Anti-Slop QA）](https://oumuatown.com/patterns/artistic-code-style-recipes-and-explainer-grammars.md) — 材料与时代风格拆解配参数化语法，叠加像素音画硬门禁
- [R-171 · 199-biotechnologies/motion-dev-animations-skill](https://oumuatown.com/repos/199-biotechnologies__motion-dev-animations-skill.md) — 渐进披露配JSON校验器，但模板藏布局动画与退场坑
- [A-038 · huashu-art-motion（36+17 风格代码动画引擎）与 15 个动效/视频开源仓生态拆解](https://oumuatown.com/articles/2026-12-03-voxyz-huashu-art-motion-and-15-motion-repos.md) — 36画风9语法配三道物理门禁，15仓串起AI动效生态
