Skip to content

fix(desktop): defer JCEF creation until native view is shown - #19

Merged
generalio merged 1 commit into
mainfrom
generalio/fix/desktop-webview-first-frame
Aug 8, 2026
Merged

fix(desktop): defer JCEF creation until native view is shown#19
generalio merged 1 commit into
mainfrom
generalio/fix/desktop-webview-first-frame

Conversation

@generalio

Copy link
Copy Markdown
Owner

目的

修复 Compose Desktop 中 windowed JCEF 在 SwingPanel 尚未进入原生窗口层级时提前创建,导致 720yun VR 页面等首帧空白、需缩放窗口后才显示的问题。

改动内容

  • 增加原生视图挂载协调器,仅在 JCEF 组件同时 displayable 且 showing 后调用 createImmediately()。
  • 复用同一原生视图目标完成首次布局同步;创建前离开 Composition 时主动释放 Client 并通知退出协调器。
  • 新增挂载时序单元测试,覆盖延迟创建、幂等创建和销毁后不创建。

平台影响

  • Android:无改动。
  • iOS:无改动。
  • Desktop:修复 windowed JCEF 的首帧挂载时序;不改变公共 API。
  • JS/Wasm:无改动。

验证命令与结果

  • 通过:./gradlew --no-configuration-cache --rerun-tasks :webview-desktop:test :webview-compose:jvmTest :sample-compose:compileKotlinDesktop --console=plain
  • 运行结果:BUILD SUCCESSFUL(33 个任务均实际执行)。
  • 运行时:以 http://720yun.com/t/0e929mp6utn?pano_id=473004 启动 desktopRun,JCEF 初始化与页面导航路径正常;当前自动化环境无法读取 JBR 窗口像素,未能自动截图确认视觉首帧。

风险与兼容性

  • 无公共 API、JS 桥、Cookie、文件访问或外部导航策略变更。
  • 浏览器创建会延后到原生组件真实显示;创建前的首个加载请求沿用既有缓存并在 onAfterCreated 后回放。
  • 未创建浏览器即销毁时不再等待 onBeforeClose,避免应用退出协调器永久等待。

文档变更

  • 已补充相关内部 Kotlin KDoc,说明延迟创建与未创建时释放的原因;无需修改公开 README 或 API 文档。

Copilot AI lite review requested due to automatic review settings August 8, 2026 04:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@generalio
generalio merged commit ad28a21 into main Aug 8, 2026
2 checks passed
@generalio
generalio deleted the generalio/fix/desktop-webview-first-frame branch August 8, 2026 04:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants