Skip to content

fix(lynx): prefer native animation frames - #2101

Merged
xuefei1313 merged 4 commits into
developfrom
agent/use-native-lynx-raf
Jul 24, 2026
Merged

fix(lynx): prefer native animation frames#2101
xuefei1313 merged 4 commits into
developfrom
agent/use-native-lynx-raf

Conversation

@xuefei1313

Copy link
Copy Markdown
Contributor

🤔 这个分支是...

  • 新功能
  • Bug fix
  • Ts 类型更新
  • 打包优化
  • 性能优化
  • 功能增强
  • 重构
  • 依赖版本更新
  • 代码优化
  • 测试 case 更新
  • 分支合并
  • 网站/文档更新
  • demo 更新
  • Workflow
  • 其他 (具体是什么,请补充?)

🔗 相关 issue 连接

N/A

🐞 Bugserver 用例 id

N/A

💡 问题的背景&解决方案

Lynx 环境此前直接复用了基于 setTimeoutrafBasedSto。这段逻辑来自通用小程序环境的历史兼容实现,没有使用 Lynx runtime 已提供的原生 requestAnimationFrame / cancelAnimationFrame,导致动画调度无法跟随宿主帧节奏。

本 PR 在 LynxEnvContribution.configure() 的低频配置阶段选择并缓存调度器:

  • 仅当 native request/cancel 两个 API 都存在时成对启用,并绑定 Lynx runtime 作为 this
  • 任一 API 缺失时,request/cancel 成对回退到现有 rafBasedSto,保持兼容;
  • 重复 configure 会重新评估能力,避免残留上一轮 scheduler;
  • 动画热路径只调用已缓存函数,不增加逐帧 capability 判断或对象分配。

新增单测覆盖原生 scheduler、runtime receiver、handle 透传、原子 fallback 与 native → fallback 的重复配置场景。

📝 Changelog

Language Changelog
🇺🇸 English Prefer the native Lynx animation-frame scheduler when both request and cancel APIs are available, with an atomic timeout-backed fallback.
🇨🇳 Chinese Lynx 环境在 request/cancel API 完整时默认使用原生动画帧调度,并在能力不完整时成对回退到 timeout 模拟实现。

☑️ 自测

  • 文档提供了,或者更新,或者不需要
  • Demo 提供了,或者更新,或者不需要
  • Ts 类型定义提供了,或者更新,或者不需要
  • Changelog 提供了,或者不需要

验证:

  • rush build -t @visactor/vrender
  • packages/vrender-kits: 30 suites / 98 tests passed
  • packages/vrender-kits: rushx compile
  • changed-file ESLint passed
  • packages/vrender: entry/shared-app 2 suites / 15 tests passed
  • packages/vrender: rushx compile
  • pre-push rush test --only tag:package passed for all 7 published packages
  • 独立代码评审:无 Critical / Important 问题

未执行:Lynx 真机/宿主 smoke(当前环境没有 Lynx 宿主)。


🚀 Summary

copilot:summary

🔍 Walkthrough

copilot:walkthrough

@xuefei1313
xuefei1313 marked this pull request as ready for review July 24, 2026 10:01
@xuefei1313
xuefei1313 merged commit dfae0a4 into develop Jul 24, 2026
6 of 8 checks passed
@xuefei1313
xuefei1313 deleted the agent/use-native-lynx-raf branch July 24, 2026 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant