fix(desktop): 修复 macOS 首屏与受控退出 - #18
Merged
Merged
Conversation
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.
目的
修复 macOS Compose Desktop 中 JCEF windowed WebView 首次进入黑屏、调整窗口后才显示的问题,并将窗口关闭与 Cmd+Q 统一为受控退出流程,降低 AppKit/JCEF 清理竞争导致
NSEvent.removeMonitor原生崩溃的风险。改动内容
revalidate() -> paintImmediately() -> repaint()。DesktopWebViewRuntime.createMacOsTerminationHandler()、bindApplicationExit()、requestApplicationExit()。CefApp.dispose(),并等待TERMINATED后执行宿主退出回调。兼容性:保留既有
initialize(cefApp, onBrowserClosed)签名与行为;新增 API 仅位于 Desktop JVM Runtime,不影响 common、Android、iOS、JS/Wasm。平台影响
验证命令与结果
./gradlew :webview-desktop:test --stacktrace --console=plain --no-configuration-cache:通过。./gradlew :webview-compose:jvmTest --stacktrace --console=plain --no-configuration-cache:通过。./gradlew :sample-compose:compileKotlinDesktop --stacktrace --console=plain --no-configuration-cache:通过。./gradlew :sample-compose:desktopTest --stacktrace --console=plain --no-configuration-cache:通过。./gradlew :webview-compose:jvmApiCheck --stacktrace --console=plain --no-configuration-cache:通过。./gradlew :webview-compose:apiCheck --stacktrace --console=plain --no-configuration-cache:JVM/Android API 阶段通过;iOS cinterop 被本机缺失 Xcode 阻断(xcrun xcodebuildexit 72),与本次 Desktop 改动无关。git diff --check:通过。未执行真实 macOS JCEF 回归;合并前请验证首次进入无需调整窗口、连续进出、Window 关闭、Cmd+Q,以及 WebView 打开/返回页面后的退出。
风险与兼容性
createMacOsTerminationHandler()返回true拦截 JCEF 默认终止;非 macOS 保持默认行为。bindApplicationExit(::exitApplication),且不得同时在旧onBrowserClosed回调中自行销毁 CEF。close(false)路径,不切换 OSR、不使用强制关闭。文档变更