Files
workinf_Blender_Wasm/docs/web/HEADED-TOOLS.md
mes123456 29cb38adb6
Some checks are pending
M6 deployable RC / quick (push) Waiting to run
M6 deployable RC / chromium (push) Blocked by required conditions
M6 deployable RC / release (push) Blocked by required conditions
fix(web): rebuild offscreen region buffers whose storage was lost
the 3d viewport already recreates its attachments when a WebGL texture loses
live storage, but non-viewport regions only freed their offscreen on a size or
format change, so a lost color attachment could never regain pixels and the
region stayed blank. free and recreate the offscreen when its storage is gone,
matching the viewport recovery.

evidence: the mid-run blank was observed once (GPU-SOAK-20261205-185353, blank
from round 21 with a selection-abort notice) and did not reproduce in two
later fault soaks (each 50 rounds) or four targeted probes including a
cancel-then-toggle sequence. the rebuild was checked with a 3-minute fault
soak (GPU-SOAK-20261205-211912, 49 rounds, STABLE). the causal link to the
observed blank is unproven; acceptance stays NOT_CLAIMED.

wasm 6183479e78115f20e76dbdc6b98be5ce9e4c425a4e99abca9c3ed88972d236ae.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-05 22:05:18 +08:00

7.7 KiB
Raw Blame History

有头浏览器测试工具(tools/web/headed/)

这些工具从「原生桌面画布 GPU 进程崩溃」的排查中沉淀而来,按用途分为 probe / smoke / soak 三类。它们不绑定某一次排查:换任意页面入口、任意 Chrome 参数都能用。

与五个 run-*-headed.mjs 套件运行器的分工:run- 前缀负责编排一条验收流程并出回执; 这里的工具是单点动作,供排查和 soak 使用,也可以被其他脚本 import。

前置条件

  • Playwright 从 web/node_modules 解析(lib/browser.mjs 用 createRequire 加载)。
  • 有头采集需要可用的 DISPLAY(本机为 DISPLAY=:1)。
  • Chrome 解析顺序:WBV2_CHROME_PATH → google-chrome-stable / google-chrome / chromium → which。
  • 被测来源必须可达;默认 http://127.0.0.1:5173/。
  • 对照页由 lib/serve.mjs 自带静态服务在 127.0.0.1 拉起(带 COOP/COEP,保证 SharedArrayBuffer),不引入新依赖。

工具一览

工具 作用 典型用法
probe/probe-webgpu-flags.mjs 参数矩阵探测:每组 flags 各开一次应用,记录 navigator.gpu、适配器 vendor/architecture、能否建设备、WebGL2 renderer、引擎侧 WebGPU 报错 DISPLAY=:1 node tools/web/headed/probe/probe-webgpu-flags.mjs
probe/probe-page-state.mjs 打开页面读状态:引擎/WASM 状态、原生画布属性、回退提示、canvas 列表、WebGL2 renderer DISPLAY=:1 node tools/web/headed/probe/probe-page-state.mjs --url http://127.0.0.1:5173/
smoke/smoke-headed-boot.mjs 启动冒烟:等引擎 ready,断言原生画布/回退提示的期望状态 DISPLAY=:1 node tools/web/headed/smoke/smoke-headed-boot.mjs --flags="--enable-unsafe-webgpu" --expect-native true
smoke/check-canvas-render.mjs 原生画布真的画出了东西:适配器存在、画布打开、截图非空 DISPLAY=:1 node tools/web/headed/smoke/check-canvas-render.mjs --flags="--enable-unsafe-webgpu"
soak/soak-interaction.mjs 交互 soak:滚轮/拖拽/点击/快捷键循环,监听 Chrome stderr 崩溃行,截图差异做存活判定,可选调用 __WBV2_GPU_STATS() DISPLAY=:1 node tools/web/headed/soak/soak-interaction.mjs --minutes=10 --flags="--enable-unsafe-webgpu,--enable-features=Vulkan"
fixtures/webgpu-control/index.html 最小 WebGPU 对照页(WGSL compute + render 循环),区分「浏览器/驱动问题」与「应用负载问题」 由 soak/探针经 lib/serve.mjs 打开
fixtures/webgpu-control/main.js 最小对照页的 WGSL 与循环实现 由 index.html 引入
fixtures/webgpu-control/control-combined.html WebGL2 渲染 + WebGPU 计算共存对照页(引擎托管模型的最小复刻) 同上

共享库:

库 内容
lib/browser.mjs 仓库根/WEB_DIR 解析、Playwright 加载、硬件与 SwiftShader 参数表、resolveChrome()、freePort()、launchChrome()(spawn + --remote-debugging-port + connectOverCDP + stderr 逐行回调 + 确定性关闭)、normalizeArgs()
lib/crash-watch.mjs Chrome stderr 崩溃模式(GPU process exited unexpectedly、exit_code=133、Check failed、FATAL、ContextResult::kTransientFailure、GPU state invalid)与计数、时间戳
lib/receipt.mjs tests/golden/<topic>-<stamp>/report.json 写入(不覆盖、带 schemaVersion、acceptance:"NOT_CLAIMED");媒体默认写 /tmp/<topic>-<stamp>/
lib/preflight.mjs DISPLAY / Chrome / 来源可达性预检
lib/liveness.mjs 截图缓冲哈希与 snapshot(),供 soak 判「画布还在变」
lib/serve.mjs 对照页静态服务(127.0.0.1、COOP/COEP)

共享命令行契约

与五个 run-*-headed.mjs 对齐:

参数 含义
--url <origin> 被测来源,默认 http://127.0.0.1:5173/
--flags <csv> 追加给 Chrome 的参数,逗号分隔;--name=value 与 --name value 两种写法都接受
--minutes N soak 时长(soak-interaction,默认 3)
--expect-native true|false|any smoke-headed-boot 对原生画布的期望
--expect-fallback true|false|any smoke-headed-boot 对回退提示的期望
--shots <dir> 截图目录(默认 /tmp/<topic>-<stamp>/)
--out <dir> 回执目录(默认 tests/golden/<topic>-<stamp>/)
--json-only 完整报告打到 stdout
--help 用法

退出码:0 通过 / 1 判定失败(或 soak 非 STABLE)/ 2 前置条件不满足 / 64 参数错误。

回执

  • 位置:tests/golden/GPU-PROBE-<stamp>/、tests/golden/HEADED-SMOKE-<stamp>/、tests/golden/GPU-SOAK-<stamp>/。
  • 结构:schemaVersion: 1、tool、url、flags、chrome、preflight、acceptance: "NOT_CLAIMED" 加各工具自己的字段。
  • 重复运行不会覆盖:每次新时间戳一个目录。
  • 截图与完整 stderr 默认不入库;需要留证时用 --shots/--out 指到指定位置。

已验证结论(2026-12-05,Chrome google-chrome-stable,NVIDIA RTX 4060,DISPLAY=:1)

参数矩阵(probe-webgpu-flags.mjs,回执 tests/golden/GPU-PROBE-20261205-035922/):

flags navigator.gpu 适配器 建设备
无参数 有 null —
--enable-unsafe-webgpu 有 google / swiftshader 成功
--enable-unsafe-webgpu --ignore-gpu-blocklist 有 google / swiftshader 成功
--enable-unsafe-webgpu --enable-features=Vulkan 有 nvidia / lovelace 成功
同上 + --use-angle=vulkan 有 nvidia / lovelace 成功
  • 无参数(Chrome 默认)拿不到适配器:应用侧已回退到 Web 业务工具视图并显示提示 (data-testid="webgpu-fallback-notice")。smoke-headed-boot.mjs 两种模式均 PASS:有 flags → 原生画布打开; 无 flags → 原生画布关闭 + 回退提示出现。
  • 10 分钟交互 soak:SwiftShader 稳定;--enable-features=Vulkan(真实 NVIDIA)在约 408 秒出现 GPU process exited unexpectedly,退出码 133;同参数最小 WebGPU 对照页稳定 → 崩溃由引擎负载触发, 不是浏览器/驱动本身。
  • 根因已定位并修复:WebGLFrameBuffer::release_transfer_images() 泄漏 transfer FBO(见 docs/web/KNOWN_LIMITATIONS.md)。修复后 20 分钟 Vulkan soak 为 0 次 GPU 进程崩溃;暴露出的 CANVAS_STALL(约 5 分钟后主区域停绘)已定位为流内状态提示条反复 resize 原生画布、触发 region draw buffer 重建,提示条改为绝对定位覆盖层后,连续三次 20 分钟 Vulkan soak 判 STABLE (tests/golden/GPU-SOAK-20261205-161007/、-165031/、-171129/)。
  • 2 分钟 soak 冒烟:STABLE,33 轮,画布持续刷新,零崩溃行(回执 tests/golden/GPU-SOAK-20261205-040136/)。
  • 故障注入联调:--url "http://127.0.0.1:5173/?computeFault=destroy-after-3" 在附着期触发 COMPUTE_DEVICE_LOST;重放后第二次 attach 成功、frame=1440x900、画面恢复渲染。 一次故障 soak 曾在重放后出现主区域空白;随后两次同参数 soak 与 4 个定向探针未复现, 离屏 region 绘制缓冲的丢失存储重建已补上(见 docs/status/GPU-VULKAN-CRASH-FIX.md)。

新增工具的约定

  1. 按用途放进 probe/ / smoke/ / soak/,动词前缀与上表一致。
  2. 复用 lib/:启动一律走 launchChrome(),参数一律先 normalizeArgs(),回执一律走 writeReceipt()。
  3. 回执 topic 用大写短横线名(GPU-PROBE、HEADED-SMOKE、GPU-SOAK)。
  4. 写完后在本文件的工具表登记,并运行 node tools/web/check-headed-tools.mjs 校验表与磁盘一致。