feat(wasm): occ-split — lazy occ_service worker; kicad_editor drops OCC (−31%)
Move OpenCASCADE out of the merged editor image into occ_service: a separate
emscripten module (-sASYNCIFY=0, MODULARIZE, in-container -Oz finalize, 2N+8
pre-warmed pthread pool) booted lazily in a dedicated Web Worker on the first
STEP export or STEP/IGES model parse. kicad_editor.wasm ~190 MB -> 130 MB;
sessions that never touch OCC never fetch its 57 MB. STEP export works in the
browser for the first time: the unchanged desktop dialog runs EXPORTER_STEP,
whose wasm shadow suspends into globalThis.occService and the export bytes go
straight to a browser download (never entering the editor heap). STEP/IGES 3D
models parse in the worker via the oce shadow (S3D WriteCache/ReadCache wire).
- wasm/occ-service/: service CMake target (hooked from the kicad fork's
top-level CMakeLists, wasm/editor pattern), embind entry
(occExport/occLoadModel), wxConfig pre-js.
- wasm/stubs/{exporter_step,oce_plugin}_stub.cpp: EM_ASYNC_JS worker bridges
(callee-shadowing; no caller #ifdefs).
- web/standalone: provider installed whenever the kicad_editor bundle boots
(cross-face safe); ONE shared worker-boot source occ-worker.js (vite ?raw;
the e2e stub reads the same file) — blob worker with locateFile absolutized
against the glue URL; export download-name guard.
- deps: OCC builds with RapidJSON so its glTF/GLB writer exists — pinned to
the vcpkg master snapshot 2025-02-26 (24b5e7a8b27f), the same code official
KiCad consumes via vcpkg.json's opencascade[rapidjson]; rapidjson's latest
tag (v1.1.0, 2016) is ill-formed under modern clang.
- tests: occ-export dialog e2e (lazy-fetch boundary + STEP download bytes),
occ-probe incl. a 9-format matrix (step/stpz/brep/xao/ply/stl/glb/u3d/pdf),
3d-viewer-models hard-asserts the worker parse; occ provider stub installed
ambiently by the kicad fixtures.
Validated against desktop kicad-cli 10.0.4: geometric exact equality (bbox
delta 0 um, volume delta 0.0000%) for STEP/GLB/STL/BREP/STPZ across three
boards and option sweeps — with desktop OCC 7.9 vs wasm OCC 7.8; PLY/XAO/PDF
structurally equal; U3D same-size (quantizer float LSBs differ). Full kicad
e2e green on Firefox and Chromium; standalone verified end to end (lazy fetch
only on the Export click; export.step 60,628 B ISO-10303-21; loadModel 700 KB
STEP -> 569 KB scenegraph cache).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
96abe5d4a5
commit
db9d6ee04b
28 changed files with 2296 additions and 23 deletions
|
|
@ -67,7 +67,7 @@ trap 'kw_fail 130; exit 130' INT TERM
|
|||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
VALID_APPS="kicad_editor | pcbnew | eeschema | calculator | pl_editor | gerbview | sym_convert | all"
|
||||
VALID_APPS="kicad_editor | pcbnew | eeschema | calculator | pl_editor | gerbview | sym_convert | occ_service | all"
|
||||
|
||||
usage() {
|
||||
echo "Usage: ./docker/build.sh <app>[,<app>...] [args...]" >&2
|
||||
|
|
@ -95,12 +95,12 @@ shift
|
|||
# possible (especially with KICAD_PIPELINE=1). pcbnew/eeschema stay buildable as
|
||||
# standalone debug aids but are not part of "all" (not deployed).
|
||||
if [[ "$APP_NAME" == "all" ]]; then
|
||||
APPS=(kicad_editor calculator pl_editor gerbview)
|
||||
APPS=(kicad_editor occ_service calculator pl_editor gerbview)
|
||||
else
|
||||
IFS=',' read -r -a APPS <<< "$APP_NAME"
|
||||
for app in "${APPS[@]}"; do
|
||||
case "$app" in
|
||||
kicad_editor|pcbnew|eeschema|calculator|pl_editor|gerbview|sym_convert) ;;
|
||||
kicad_editor|pcbnew|eeschema|calculator|pl_editor|gerbview|sym_convert|occ_service) ;;
|
||||
*)
|
||||
echo "Error: unknown app '$app' (expected: ${VALID_APPS})" >&2
|
||||
usage
|
||||
|
|
@ -256,9 +256,10 @@ postprocess_app() {
|
|||
local app="$1"
|
||||
local out_dir="output"
|
||||
|
||||
# The converter is finalized in-container (real tools, small -g0 wasm) and is
|
||||
# a synchronous node CLI, so it needs no host post-processing.
|
||||
if [ "$app" = "sym_convert" ]; then
|
||||
# The converter and the OCC service are finalized in-container (real tools,
|
||||
# small -g0 wasm) and build with ASYNCIFY=0, so they need no host
|
||||
# post-processing (no dyncall shims, no finalize, no asyncify).
|
||||
if [ "$app" = "sym_convert" ] || [ "$app" = "occ_service" ]; then
|
||||
echo "Skipping host post-processing for ${app} (finalized in-container)"
|
||||
return 0
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in a new issue