Repository navigation
fix(toolpkg): stop the parent WebView popup crash - #1506
Open
yoruuuchan wants to merge 1 commit into
Open
yoruuuchan wants to merge 1 commit into
yoruuuchan wants to merge 1 commit into
Conversation
onCreateWindow handed the parent WebView back to Chromium as the popup host, so every window.open() call threw "IllegalArgumentException: Parent WebView cannot host its own popup window" on the main thread and killed the app. Report the request as unhandled instead, and default supportMultipleWindows to false so pages that call window.open() become a no-op instead of a process crash. Fixes AAswordman#1434
CATMIAOZHI
self-requested a review
November 16, 2026 13:37
CATMIAOZHI
approved these changes
Nov 16, 2026
CATMIAOZHI
left a comment
Collaborator
There was a problem hiding this comment.
审计结论:✅ 批准合并
改动(1 个文件,+7/−6):修复 ToolPkg Compose DSL UI.WebView 在页面调用 window.open() 时整 App 崩溃的问题(Fixes #1434)——onCreateWindow 改为 return false、不再把父 WebView 自己塞进 WebViewTransport,同时 supportMultipleWindows 默认值由 true 改为 false。
通过的检查:
- 根因判断正确:旧代码把发起弹窗的父 WebView 自身赋给
transport.webView,正是 Chromium 抛IllegalArgumentException: Parent WebView cannot host its own popup window的模式。已与项目内另外两处同类实现核对:BrowserWebViewSupport.kt(新建 popup session 承载)和WebViewConfig.kt(新建WebView(view?.context)承载)都是新建 WebView 做宿主,只有本处把父 WebView 自己传了回去。 - 双重防护合理:
supportMultipleWindows默认false后onCreateWindow正常不再被调用;显式传入true的插件仍由return false兜底,不再崩溃。 - 兼容性说明属实:此前依赖默认值的插件本来就会 100% 崩溃,没有可用的旧行为被移除;
supportMultipleWindows仍可显式传入;examples/types/compose-dsl.d.ts未写死该属性的默认值,无需同步文档。页面加载、JS bridge、下载、文件选择等路径未改动。 - 与 #1424 无重叠:#1424 改的是同文件约 70、166-225、1271-1410 行的 JS bridge 参数传递,本 PR 改的是 2019-2270 行,可独立合并。
- 目标分支为
dev,符合规范;单文件小改动,无无关内容;CI(Fast checks、Android JVM tests、Candidate checks)已通过。
问题:
- [P2]
window.open()被静默丢弃:当前实现既不记日志、也不触发任何事件回调,插件作者遇到 OAuth 登录"点开没反应"时无法区分是页面问题还是弹窗被丢弃。建议后续在onCreateWindow里记一条日志,或补一个onWindowOpenRequest回调供 ToolPkg 感知。不阻塞合并(作者已在 PR 描述中明确说明"弹窗请求会被丢弃,后续可以单独实现"这一取舍)。 - [question] 作者声明未做真机验证,
window.open()的实际行为留给维护者/CI。合并前是否方便在真机上验证一次:调用window.open()的页面不再崩溃、且原页面可继续正常使用?
后续可跟进(不阻塞):
- 真正的弹窗承载(独立 WebView + Dialog 或新窗口)可后续单独实现,届时
supportMultipleWindows默认值与onCreateWindow的return false需要一并改回。 - #1315 报告的是同一个
IllegalArgumentException,作者已说明因缺少具体调用点而不自动关闭,维持现状即可。
由 水晴喵的muse 审计
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.
变更说明 / Description
侧边栏 ToolPkg 的 UI.WebView 在页面调用 window.open() 时会让整个 App 崩溃:onCreateWindow 把发起弹窗的父 WebView 自己塞进了 WebView.WebViewTransport,Chromium 判定为「父 WebView 承载自己的弹窗」,在主线程抛 IllegalArgumentException 直接杀进程。本 PR 不再伪造宿主,并默认关闭多窗口,window.open() 变成无操作而不是崩溃。
背景与动机 / Context and motivation
Issue #1434:任何使用 Compose DSL UI.WebView 的 ToolPkg,只要页面里有 window.open()(OAuth 登录、外链、分享都很常见)就会 100% 崩溃,属于通用问题。同文件 2258 行的 supportMultipleWindows 默认 true,保证每次调用都走到这段错误实现。
改动范围 / Changes
兼容性与风险 / Compatibility and risks
关联 Issue / Related issue
Fixes #1434
#1315 报告的是同一个 IllegalArgumentException: Parent WebView cannot host its own popup window,疑似同根因;但该报告没有附出具体 WebView 调用点,本 PR 只修 Compose DSL 这一处,所以不自动关闭它。
验证方式 / Verification
证据 / Evidence
无(未在真机复现;修复点是单行逻辑,CI 会重新跑检查)。
检查清单 / Checklist