Repository navigation
fix(trial): 记录隔离试运行的网页握手状态 - #174
Closed
Ashena1017 wants to merge 1 commit into
Closed
Ashena1017 wants to merge 1 commit into
Ashena1017 wants to merge 1 commit into
Conversation
网页上报现在会带上 ready/transport、boot 遮罩和 mux socket 的状态与关闭码, 插件按状态变化写出一行 DSHA_TRIAL_PAGE_STATE 到进程输出,宿主已把它保存在 失败记录的 output 里,TRIAL_TIMEOUT:RENDERING 因此能看到握手卡在哪一步。 进度上报只在页面运行 4 秒后按 2 秒节流发送;成功确认路径、致命失败上报和 重试节奏保持不变,已确认的 renderer 也不会被后续进度上报回退。 合成夹具补充进度上报、socket 关闭码与节流三项用例。
Author
|
补一条真机验证结果,说明这套诊断在同类设备上能看到什么,也给后续修复一个方向。 验证环境HUAWEI NOH-AN00(Mate 40 Pro)/ HarmonyOS 4.2.0 / Android 12(SDK 31)/ 系统 WebView 结果
试运行期间抓运行中窗口的无障碍树,能看到完整 DSH 前端(新建会话/全局面板/插件/设置等),说明页面已加载并渲染,缺的只有 mux 的 对上游的建议
说明:本 PR 未在本地构建 APK(缺少离线 rootfs 与发布证书),Java 侧行为需要维护方打包后复核;上面的真机结论针对的是当前已发布 build 170,用来证明诊断字段的必要性。 |
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.
现象
Android 12 / SDK 31 的华为设备(HarmonyOS 4.2,系统 WebView
com.huawei.webview14.0.2.316)上,首次安装与「更新运行时」固定停在维护页并报TRIAL_TIMEOUT:RENDERING;同一份 APK 在 Android 16 设备上正常。关联 issue #167(HONOR Android 12,Standard 与 Low 均复现)。现场证据(未 root,adh shell uid=2000)
设备侧
logcat由华为 WebView 进程持续输出:约每 9 秒一次,与「重新连接中」的重连节奏一致,说明页面的
/api/remote.muxWebSocket 升级请求被服务端以非 101 响应拒绝,ready && opened && message里的opened/message永远不成立。用 PC 经
adb forward直接对该 dsh 实例发起升级请求,可复现服务端的两种拒绝:无凭据 →401 unauthorized;Origin与Host不一致或为null→403 forbidden。导航与静态资源正常,所以页面本身能渲染。因此失败点在网页侧握手,而当前试运行只在成功时才上报,
TRIAL_TIMEOUT:RENDERING的失败记录里没有任何ready/transport/socket 状态,无法判断是脚本没跑、页面没启动完成,还是 mux 升级被拒。改动
只增加诊断,不改变成功判定:
runtime-trial-page.js:记录[data-dsh-boot]遮罩是否仍在、mux socket 的connecting/open/closed/error状态与关闭码;页面运行 4 秒后按 2 秒节流上报进度(kind: "progress")。成功确认(kind: "ack")与致命失败(kind: "fail")的上报路径、重试节奏与clearInterval时机保持不变。runtime-trial-plugin.js:收到上报后按状态变化写出一行DSHA_TRIAL_PAGE_STATE {...}到进程输出。宿主RuntimeTrial.Output已把 stdout 尾巴写进失败记录的output,因此下一次失败会直接带上握手卡在哪一步。同时把renderer改为只置真,避免后到的进度上报把它从true覆盖回false。tools/test-runtime-trial.mjs:合成夹具补三项用例(进度上报字段、socket 关闭码、2 秒节流),原有五项不变式保持通过。改动只涉及字段白名单(布尔/短枚举/整数关闭码),不写入 cookie、token、URL 或页面内容。
验证
在 Windows / Node v24.19.0 上:
node --check通过(两个资产文件)。tools/test-runtime-trial.mjs抽出浏览器握手段落,用仓库里的真实runtime-trial-page.js跑合成夹具:原有 5 项 + 新增 3 项全部 PASS(含foreign_socket_cannot_acknowledge_trial、wrong_trial_home_cannot_acknowledge等不变式)。reportPage()做独立行为检查:首次上报、状态去重、字段裁剪、null/非对象忽略、renderer只置真。python tools/check-source-hygiene.pyPASS;python tools/run-host-tests.py --check-manifestPASS(157 项)。未验证:没有离线 rootfs 资产与发布证书,未在本机构建或安装 APK,也没有跑
:app:testStandardDebugUnitTest/ Release Lint。真机 APK 行为需要仓库维护方在打包后复核。期望产出
打包后在同类设备上重跑一次维护,失败记录的
output里应出现DSHA_TRIAL_PAGE_STATE行。据此可区分三种根因并决定真正的修复:ready:false或boot:true→ 页面没启动完成;ready:true, transport:false+socket.state→ mux 升级被拒(本次最可能),再看是401(cookie 没随升级请求发送)还是403(Origin 校验)以决定改成 query 凭据与 Origin 放行的哪一侧。