Files
FreeCADWasmDev/docs/current/web-document-view-routing-20260913.md
wangdequan 9a7c4f0335 Save FreeCAD Web workspace sources and user validation evidence
IFC native binding remains incomplete; preserve accurate test results.
2026-09-15 22:01:58 +08:00

4.4 KiB

Web Document View Routing

Status: wrong-runtime call path replaced, compiled and published. No automated tests, browser checks or user acceptance were run, per the execution policy. This is not a declaration of complete desktop view parity or project completion.

Root Cause

Web view requests used web.statefulFamilyBatch. The facade required fields absent from that request and its Worker loaded DocumentProbe's legacy stateful fixture, not WebViewCommands. Separately compiled WebRuntimeProbe had no access to live PartBox/DocumentProbe documents. Native marker additions could not fix ownership.

Actual Paths

Owner Typed Endpoint Existing Worker Existing WASM
PartBox part.viewCommand part.worker.ts FreeCADWebPartBoxProbe
DocumentProbe part.documentViewCommand part-save.worker.ts FreeCADWebDocumentProbe

Both native dispatchers call NativeDocumentView.h and the existing WebViewCommands.h against documents in their own runtime. No raw pointers or fabricated documents cross WASM instances. Four commands are supported: AlignToSelection, BoxElementSelection, BoxSelection and DrawStyle. Workbench explicitly selects an owner (PartBox default); Project's View Tools pins DocumentProbe and passes its real native document name. Views use real returned meshes/selection/state.

document-view-routes.json is shared by typed endpoint selection and capability discovery. The module generator maps both endpoints to their actual workers. Canonical desktop IDs remain Web:desktop:*, although execution belongs to Part. Implementation packets include both owning bridges and select PartBox, not the unrelated Web server target. Missing ownership is not treated as a native marker gap.

Guards Preserved

  • Requests require matching owner, document, supported command and parameters.
  • Missing native documents fail; the helper no longer falls back to ActiveDocument.
  • Selection entries and native subelements are resolved against that document.
  • Typed responses check owner/document/command, geometry coordinates, indices, view state and selection. Late responses do not replace a newly selected view.
  • Both requests use existing serialized document queues; Project reset/cancel tracking includes its view requests. No extra document Worker is spawned.
  • Legacy stateful dispatch rejects Web desktop IDs before any fixture execution.
  • Dock/scene browser handlers retain precedence over dedicated Web native views.
  • Other GUI commands now require a real dedicated host instead of silently using the wrong stateful endpoint. Existing browser-only axes/demo/overlay remain intact.

The existing native view logic is reused. Geometry tessellation, face normals and edge tangents still come from Part/OCCT; Three.js displays returned data and provides view projection/input. This does not prove every module uses one global OCCT memory instance. Only the explicitly supported document owners are connected here.

Build Accounting

Both existing target builds exited 0. The first build command took 35.209 seconds; the follow-on legacy-route guard build took 35.789 seconds. The PartBox object and runtime were already current for the new bridge when these commands ran; no unchanged kernel was rebuilt to force a new receipt.

Publication Step Seconds
Incremental asset synchronization 1.250
Frontend build (FREECAD_WEB_FAST_LINK=ON) 11.511
Public sync inside frontend build 9.933
Final formal handoff pipeline, built artifacts reused 1.471

Formal receipt: web-document-view-handoff-pipeline.json, four ready and zero missing. buildRequired=false at that final handoff; no additional compile. Direct build command timings are not a runtime performance or throughput benchmark.

Remaining Scope

Other modules' documents require explicit owner integration; they are not aliased to PartBox or DocumentProbe. Desktop camera/selection nuances and rendering modes were not reimplemented or validated in this routing task. Project's main tree still selects one object while the dedicated view keeps its detailed selection result. Global live-document unification and full desktop rendering parity remain separate.

The prior wrong-route source findings were updated in native-semantic-decisions.json with the previous diagnosis retained. Reuse these new endpoints; do not resurrect the stateful fixture transport or re-add missing fields to the old request.