# DDZ-BC84-072 r1 · HOTFIX-READY 报告

- 任务：`/vol1/ai/projects/wyszz-new/frontend-rebuild-hm/tasks-out/DDZ-BC84-072/TASK.md`
- TASK sha256：`f7ec4740508e02836f4d87e0a1eea70a83100403f046dac5f769034fbeab0c97`
- 状态：**HOTFIX-READY（可审候选，未发布/未合并/未清档）**
- 生成：2026-11-14T00:51+08:00
- 唯一 writer：DSH

## 1. 结论

机主微信 `ReferenceError: performance is not defined` 已按“先红后绿”修复。真实微信 bundle（IIFE / es2017）
在 **Worker 内真正删除 `performance`** 后，默认 district1 启动成功，有 3D 首帧（48 draw calls / 8920 triangles），
已有存档 checkpoint/金币/已购地原样恢复，namespace 不变。**不是存档损坏，未调用 clearStorage/removeItem。**

手机真机仍是未验证项，需机主用微信确认；本报告不把 Chromium Worker 模拟宿主当成真机结论。

## 2. 根因

修复前 `src/bc84/p1/projection-host.mjs` 第 3 行：

```js
let next;const t0=performance.now();   // 在 try 之前
```

微信小游戏 Worker 不保证提供 `performance`，因此在切场景时先抛 `ReferenceError`，`try/catch` 还没有生效，
城市读取/建档被外层报成“城市读取/建档失败”。同属 wx 依赖闭包的 `scene.js`、`terrain.js` 也有裸
`performance.now()`（共 9 处裸调用）；只修 projection-host 会把错误推迟到 scene/terrain。

## 3. 最小修复

新增 `src/bc84/p1/platform-now.mjs`：

```js
export function resolveNow() {
  try {
    const perf = typeof performance !== 'undefined' ? performance : undefined;
    if (perf && typeof perf.now === 'function') return () => perf.now();
  } catch { /* 访问器抛错按缺失处理 */ }
  return () => Date.now();
}
```

- 一次测量内固定同一时钟，避免 performance/Date.now 混算导致数值单位错乱。
- 有 `performance.now` 时仍用它（亚毫秒）；缺失时才用 `Date.now()`（毫秒）。
- 只读全局，**不创建/覆盖 `globalThis.performance`**，不把控制器性能对象透传到 Worker。
- 不接管业务离线/收益时钟；`session-runtime` 的 `now`/`wallNow` 未改。
- `switchProjection` 的 `try/catch`、`next?.dispose()`、`current` 仅在新投影 `add` 成功后释放，语义未变。
- 浏览器专属 `web-host.mjs` 的裸 `performance` 保留不动（不进 wx bundle）。

改动文件（生产 patch 仅这 4 个）：

| 文件 | 类型 | before sha256 | after sha256 |
| --- | --- | --- | --- |
| `src/bc84/p1/platform-now.mjs` | added | — | `67477b0cb8baa9a0a815c2adf05e769425a3dd1b2665ea08db52c1a10b5c1b32` |
| `src/bc84/p1/projection-host.mjs` | modified | `5823377d4bc3b8f010bf6e59359c935619b1479bec46dedb49f3b82aefdc1c47` | `9ccdba71fda76695fe0f2a1043a9448873dc8f2ae05b67e031c1ca637f57ce4f` |
| `src/bc84/p1/scene.js` | modified | `90b22b128ce7b2b37cfddfa2893b82110dc2f031086ade72a2c7c6b89b7186b5` | `a307f7f92d4b3086bc9cfd051b9e195052b2c9fed195a30bf0142ac9ed8cc0a0` |
| `src/bc84/p1/terrain.js` | modified | `c9765ea130d8a1cab2b19b75b20ba5a858bb35aaba310787440e96fd4af0341c` | `57551d0ff9f9f8a8c0a59e7c599dad14e3d3529321e6ee2340807b74f9a67ff1` |

辅助证据文件（不属于最小 hotfix）：

- `test/bc84/p1/072-no-performance.test.mjs`：`48166b2d6251af73bca799b008da7d822398f290ce10ccec7c3cae8e92deb7e5`
- `tools/bc84/p1/wx-sim.mjs`：`821dc3744a075a6fae1eaa146a151937f135dd794c0eec4614ed04f92ef07fa5` → `923423808390e9e047e8004900a97e70e40d00f49ee5f2ee562fc5b3328b32e3`

## 4. 先红后绿（实际命令与日志）

### 红

1. 总监反例固定为单测（未修复源码）：
   `node --test test/bc84/p1/072-no-performance.test.mjs`
   → **0 pass / 3 fail**，`ReferenceError: performance is not defined` at `projection-host.mjs:3:20`；
   真实 wx 宿主源码同报 `城市读取/建档失败：ReferenceError: performance is not defined`。
   日志：`logs/red-072-no-performance.log`
2. 真实 I3 bundle（sha256 `0b8bbd…`）删除 Worker performance 后启动：
   `node tools/bc84/p1/wx-sim.mjs --no-performance --default`
   → boot failed，`runtime: performance is not defined` / `start: 城市读取/建档失败：ReferenceError…`
   日志：`logs/red-wx-sim-no-performance-baseline.log`
   fatal：`evidence/wx-sim/072-red-baseline-fatal.json`

### 绿

1. 单测：`node --test test/bc84/p1/072-no-performance.test.mjs` → **4 pass / 0 fail**
   日志：`logs/final-green-072-no-performance.log`
   - 缺失 performance：不抛、不污染全局，fallback 的 5 个 `Date.now` 采样得到精确 ms 差值；
   - 存在 performance：5 个 `performance.now` 采样得到精确 ms 差值；
   - prepare 抛错：旧投影保留、失败候选 exactly once dispose；
   - 真实 wx 宿主源码（含 scene/terrain）district1 启动、namespace/checkpoint 校验、重启恢复。
2. 真实 bundle 删除 performance、默认 district1：
   `node tools/bc84/p1/wx-sim.mjs --no-performance --default` → **11 pass / 0 fail**
   日志：`logs/green-wx-sim-no-performance.log`
   结果：`evidence/wx-sim/072-no-performance-results.json`
   - Worker：`typeof performance === 'undefined'`，`'performance' in self === false`，property 从
     `WorkerGlobalScope` 删除（不是控制端透传）；
   - district1、`phase=idle`、`frames=3`；
   - 3D：`drawCalls=48`、`triangles=8920`；截图 89,540 B：
     `evidence/wx-sim/wx-sim-072-no-performance-district1.png`；
   - 存档 key 只有 `bc84.p1.roadland-biz-v8-067:wx-sim-a:32:bc84.p1.wx.{slotA,slotB,head}`；
   - 重启：checkpoint `5→5`、金币 `10000→10000`、已购地 `8→8`、同一 worldId，HEAD revision 5；
   - 双指平移：camera target 位移 `3.5228`。
3. 真实 bundle 正常环境（有 performance）：
   `node tools/bc84/p1/wx-sim.mjs --minimal` → **9 pass / 0 fail**，frames=4，drawCalls=30，triangles=7768。
   日志：`logs/green-wx-sim-normal-minimal.log`
   结果：`evidence/wx-sim/072-normal-minimal-results.json`
4. 既有回归：
   - `r2-projection-host.test.mjs` **3/3**（错误释放 F04）；
   - `wx-storage + wechat-smoke + host-core` **36/36**，含 `unknown(slot)→重试只扣一次`、
     `unknown(HEAD)→recover committed→不重复扣费`；
   - `dual-host-consistency` **2/2**，checkpoint 234 状态完全一致；
   - `wx-host-sim` 纯函数 **1/1**。
5. 6 个改动/新增文件 `node --check` 通过；I3 470/470 源文件 hash 复验一致。

## 5. 验收对照

| TASK 验收项 | 结果 | 证据 |
| --- | --- | --- |
| 缺失 global performance 时切场景不抛 | 通过 | 单测 4/4 + 真实 bundle 11/11 |
| 存在 performance / 仅 wx 计时 / 最小 fallback 分支 | 通过 | 确定性 performance/Date.now 序列断言 |
| 现有错误释放 / 不二次扣费路径 | 通过 | F04 3/3；wx-storage 36/36；072-06 重启金币/checkpoint 不变 |
| wx-sim 真实 bundle 删除 performance，默认 district1 有 3D 首帧 | 通过 | 11/11；48 draw calls / 8920 triangles / 89,540 B PNG |
| 已有 checkpoint 恢复 | 通过 | 072-06 `5→5`、`10000→10000`、`8→8` |
| 正常存档保留 / namespace 一致 | 通过 | 072-04/072-06，仅 067 经营前缀；HEAD revision 5 |
| 城市启动与手势关键路径 | 通过 | 072-02 / 072-05 |
| 不重跑旧 048 全量套件 | 遵守 | 只跑上述定向测试 |
| 手机真机 | **未验证** | 待机主微信确认 |

## 6. 边界与安全

- 066/067/071 只读：未改；I3 470 个源文件 hash 全对；066/071 的 `game.js` 均仍为 `0b8bbd…`。
- 未调用 `clearStorage`/`removeStorage`/`removeItem`，未换 namespace，未迁移存档。
- 未改经济/经营模型、离线结算、收益时钟、I4 路由或 UI。
- 未在全局安装 performance 假对象；Worker 的 performance 是真正删除。
- 浏览器专属裸 performance 未重写（不进 wx bundle）。

## 7. 已知基线问题（与 072 无关）

1. `test/bc84/p1/wx-host-sim.test.mjs` 的“微信宿主默认 050r2”期望 `roadcells-v6`，但当前默认 profile 是
   064 `roadland-v7`；在未修改 I3 上同样失败（`logs/baseline-i3-wx-host-sim-050.log`）。未改该测试。
2. 冻结 I3 的 `npm run build:bc84-p1` 会在 stale `src/bc84/model.d.*` 上触发 tsc 错误；这是基线问题
   （`logs/build-bc84-p1.log`）。r2 测试所需 `dist/bc84-p1` 用临时无 tsc 构建，测试后已删除，不进交付。

## 8. 交付物

| 内容 | 路径 / sha256 |
| --- | --- |
| 候选包 | `project/dist/bc84-p1-wx/` |
| game.js | `974348 B` / `8998d73ea56444bb8721a65671e033da3b46ad6ab9fc11500fe8f93133d47c1b` |
| game.json | `82526622d158db584fe0783eb469d01eaaa33a85360c28d83bf2b01cb031b8ec` |
| project.config.json | `fa3c8d7495e3a67ee50fc36091f0f91f22c41f7b003a7230aa3669332fe6764d` |
| 最小 patch | `patches/072-hotfix-minimal.patch` / `886dca90b3923680a9d7f6cca2e65c2435250a622ee62a0811e225faba8b5905` |
| 回归测试 patch | `patches/072-regression-test.patch` / `bd365acd45de647b549df32acad0ff02fe0836a3f7af2fc45023b6556ccedba9` |
| 证据工具 patch | `patches/072-wx-sim-evidence-tool.patch` / `774cfb7c1f4a96237ef95bfe3aa6a8671e2c78882912d59cde988b8911ac857e` |
| 机器可读状态 | `HOTFIX-READY.json` |
| 红日志 | `logs/red-072-no-performance.log`、`logs/red-wx-sim-no-performance-baseline.log` |
| 绿日志 | `logs/final-green-072-no-performance.log`、`logs/green-wx-sim-no-performance.log` |
| 3D 首帧截图 | `evidence/wx-sim/wx-sim-072-no-performance-district1.png` |

对照：I3 `974298 B / 0b8bbd…` → 072 `974348 B / 8998d73e…`，只增加 50 B；game.json 与
project.config.json 字节未变。

## 9. 供 067 受控合入

```bash
cd <067-project>
git apply --check /vol1/ai/projects/wyszz-new/frontend-rebuild-hm/tasks-out/DDZ-BC84-072/patches/072-hotfix-minimal.patch
git apply          /vol1/ai/projects/wyszz-new/frontend-rebuild-hm/tasks-out/DDZ-BC84-072/patches/072-hotfix-minimal.patch
node tools/bc84/p1/build-wx.mjs
```

本任务**不**代为修改 067、不发布、不合并。根总监独立核验后由 066 出新内部码；手机真机由机主验证。

## 10. 未验证项

- 微信真机 / 微信开发者工具的启动与 3D 首帧（模拟宿主 ≠ 真机）。
- 真实手机 GPU/驱动/内存、长时间运行与前后台切换。
- 真实 `wx.getStorageSync/setStorageSync` 的配额、淘汰、异常形态。
- 真实触摸手感与安全区差异。
- 067 受控合入、066 出新内部码、正式发布或清档。

## 11. 手机验证建议

1. 用 066 以本 patch 重建的内部包导入微信开发者工具/真机；
2. 冷启动，确认不再出现 `ReferenceError: performance is not defined`；
3. 确认默认 district1 城市有 3D 画面，顶部金币/产速/声望正常；
4. 杀掉重进，确认原存档 checkpoint、金币、已购地保留（namespace 不应变化）；
5. 双指平移/缩放正常，前后台切换不重复扣费；
6. 如仍失败，保留 `wx.onError` / err.log 原文交给总监。
