修复 AGC 运行预览尺寸抖动 #252
Reference in New Issue
Block a user
Delete Branch "fix/preview-iframe-resize-loop"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
问题
AGC 项目运行页的本地预览会根据 iframe 上报内容尺寸调整 iframe viewport;部分使用
100vh、百分比或响应式布局的游戏会把宿主调整后的 viewport 再反映为新的内容尺寸,形成反馈环并在两个缩放档位之间持续抖动。附件工程和录屏已确认可触发该问题,普通浏览器直接打开不受影响。
落地方案
验证计划
gameagent-2873e5ac在 AGC WebView 中稳定显示;npm run check:encoding、git diff --check。Fixes #250
审查 head b5e7cfeea2fd3d367cad9ec6b6310e303fd216ad:未发现明确问题。已检查 base
5de9554426到当前 head 的完整 diff,并结合调用方、现有测试与配置审查;相关 Vitest 12/12、TypeScript tsc --noEmit、git diff --check 均通过。审查 head b5e7cfeea2fd3d367cad9ec6b6310e303fd216ad:未发现明确问题。
审查 head b5e7cfeea2fd3d367cad9ec6b6310e303fd216ad:未发现明确问题。
New commits pushed, approval review dismissed automatically according to repository settings
审查 head 4d3dde539413ae1ddb95e144061e50d4e96557b0:发现 1 个阻塞问题(行内位置:apps/ai-game-creator-shell/src/features/project-workspace/LocalGamePreviewFrame.tsx new-side 第117行附近)。这里的保护条件会让延迟 native 报告重新进入 fit 更新路径。复现:current={contentHeight:1000, viewport:1200x700},appliedViewport=1200x1000,previousReportedViewport=1200x1000;随后收到 viewport=1200x700 但 contentHeight=1100 的延迟 native 报告。该报告同时满足 reportsNativeViewport,因此不会被第117-123行的“viewport变化”保护拦截,函数返回新的内容尺寸并把 iframe fit 从1000改为1100;之后 applied/native 回报交错时会再次改变缩放,目标的 resize-loop 仍可能发生。建议把报告序列/当前 resize epoch 与 native/applied viewport 绑定,在已确认 applied viewport 后拒绝旧 epoch 的 native 报告,或明确区分真实内容变化和延迟 viewport 回报,并补充该 contentHeight 变化的回归测试。