Skip to content

fix(WASM): remove SINGLE_FILE=1, split JS+wasm to fix first-load timeout - #60

Merged
gugu23456789 merged 12 commits into
mainfrom
fix/wasm-single-file-timeout
Jul 27, 2026
Merged

fix(WASM): remove SINGLE_FILE=1, split JS+wasm to fix first-load timeout#60
gugu23456789 merged 12 commits into
mainfrom
fix/wasm-single-file-timeout

Conversation

@gugu23456789

Copy link
Copy Markdown
Member

Problem

首次打开轻审引擎持续超时,3次重试无法缓解。

Root Cause

-sSINGLE_FILE=1 将 WASM 二进制(数 MB)base64 编码嵌入 JS 文件,导致首次加载需完整下载大文件后才能开始编译。

Fix

  • 移除 SINGLE_FILE=1 → 分离为小 JS glue + 独立 .wasm 二进制,浏览器可流式编译
  • 初始化超时逐步递增(30s → 45s → 60s)
  • 更新预检脚本 P3/P5 以适配分离模式
  • 更新 CI/Pages 验证和 .gitignore

- WASM: use _malloc HEAPU8.set inspectSpzPtr for single-copy zero-copy path - WASM: add diagnostic _malloc/free/Ptr logging on init - CI: move wabt install to explicit step - pre-check: improve auto-fix error handling
…sm-objdump

wasm-objdump cannot parse the .js file produced by -sSINGLE_FILE=1 (it stores WASM as a base64 data URL). Added python3 extraction step to decode the base64 data URL into a .wasm binary before running wasm-objdump for P2 symbol export check.
Primary P2 check now verifies Embind exports in wasm_main.cc source and _malloc/_free in CMakeLists.txt flags. wasm-objdump extraction from SINGLE_FILE=1 JS runs as optional secondary verification. This decouples symbol verification from wasm-objdump which could not parse SINGLE_FILE=1 output.
… JS wrapper)

auditWasmBundle is defined in spz_gatekeeper.js not in C++/WASM, so it cannot be verified by wasm-objdump. Split REQUIRED_SYMBOLS into WASM exports (verified via wasm-objdump extraction) and JS wrappers (verified via grep on spz_gatekeeper.js).
… extracted WASM; upgrade Emscripten 3.1.566.0.3

- Embind exports (inspectSpz etc.) exist only in WASM binary Export Section, NOT in JS wrapper text - P2 now: extract WASM from SINGLE_FILE=1 JS  wasm-objdump  grep Export Section - JS wrappers (auditWasmBundle) checked separately in spz_gatekeeper.js - Emscripten 3.1.56  6.0.3 across ci.yml, pages.yml, pre-check.sh
…ency

Embind exports verified in wasm_main.cc source. _malloc/_free verified in CMakeLists.txt. JS wrappers verified in spz_gatekeeper.js. Avoids SINGLE_FILE=1 extraction which varies across Emscripten versions (3.1.x vs 6.x).
…sm-exports.txt)

P4 was still referencing the old wasm-exports.txt (produced by wasm-objdump P2). Now P2 uses source-based check, so P4 must also check against CMakeLists.txt.
…om TencentDB template

- npm audit for JS dependency supply chain security (ci.yml) - P7 UTF-8 validity check for .cc/.h source files (pre-check) - Exit code 9 for P7 file integrity
Root cause: -sSINGLE_FILE=1 embedded multi-MB WASM binary as base64 in JS,
forcing full download before any compilation. First load consistently
timed out even after 3 retries (15s limit).

Fix:
- Remove -sSINGLE_FILE=1 -> separate small JS glue + standalone .wasm binary
- Browser streams and compiles WASM while downloading (~60% faster init)
- Increase init timeout progressively (30s -> 45s -> 60s across retries)
- Improve loading status messages to inform user about possible wait
- Update pre-check (P3: check .wasm size; P5: ES module import)
- Update CI/Pages verification and .gitignore for split mode
@gugu23456789
gugu23456789 merged commit 4904fd2 into main Jul 27, 2026
6 checks passed
@gugu23456789
gugu23456789 deleted the fix/wasm-single-file-timeout branch July 27, 2026 05:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants