perf(viewer): a reopened model is interactive once its stored scene and metadata are out; geometry input is ignored until the restore finishes

Merged
LO
17d ago
+1110-135

Status: CI on the final head, then queue. Merge approved by the user once clean.

What changed, by user decision (2026-11-14)

The meaning of "interactive" for a reopened model changed. The user chose an earlier mark with gating and accepted its measured cost.

  • A reopened model counts as interactive once its stored 3D scene is shown and its metadata is ready. From then on, orbit/zoom/pan, the model tree, the properties panel and metadata search work.
  • Held until the geometry restore finishes: picking (click-to-select), hover highlight and outline, measure/snap, command placement and section caps.
  • Input during the hold is ignored (second user decision, the same afternoon). A click, tap, right-click, command press or measure press, and the keyboard steps that advance a command, do nothing:
    • no selection change (the current selection is kept, not cleared);
    • no measure or command step;
    • a press that began during the hold places nothing even if it is released after the hold ends.
      The viewport shows a progress cursor once the hold lasts longer than a frame. Tree and properties selection work during the hold, and the 3D highlight appears at release. After release the same input works normally.
  • The earlier click queue and replay were removed after three review rounds had found 17 bugs in them.
  • Cold loads are unchanged: every gate this PR adds reads "a reopened model's restore is pending" (isGeometryHeld), so cold streaming keeps main's own gate and behaviour.

Measured: capped timed A/B (Pop, shared drain, 2026-11-14 15:47-16:02; main f64111d981 vs this PR at d7a4380f94, 5 rounds, own A/A in the same admission, 0 flagged samples)

Holter (169 MB)mainthis PRchange2x A/A floor
first reopen, new mark (scene shown + metadata ready)1,252856+31.6%7.4%
snapshot reopen, new mark1,249810+35.1%3.8%
first reopen, old mark (everything usable)1,2521,337-6.7%7.9% (n.s.)
snapshot reopen, old mark1,2491,295-3.7%3.7% (n.s.)
cold3,1723,248-2.4%4.4% (n.s.)
  • Main publishes metadata at the end of the load, so on main the new mark equals the old one.
  • Both reopen goals are met: first reopen <= 1,000 ms, snapshot reopen <= 900 ms.
  • Hold on Holter: 453-501 ms per sample (median about 480).
  • The old mark is 46-85 ms later than main; the user accepted this trade. Snapshot-reopen UI quiet is 1,808 -> 1,878 ms (-3.9%, flagged against a 3.2% 2x floor).
  • FZK is under the cache size tier: its reopens are fresh loads and the gate never engages. Cold identical output.

Timed commit vs final head: the PR's own commits after d7a4380f94 change only input, cursor and gating files (selectionHandlers, contextMenuSelection, commandPress/commandTouchPress/commandPointer, distanceClick, useRepositionPicking, useTouchControls, useMouseControls, useViewportCursor, useHoverOutline, keyboard command handlers, pick-gating). On the load path they add only a one-line stale-load guard on the milestone and a stricter type for its scene-show promise (useIfcCache, geometry-restore-gate). Neither runs for the current loads the timing measured, so the timed result stands. The rest of the diff since then is main.

Change

  • lib/geometry-restore-gate.ts: per-model geometryRestorePending.
    • Every load end releases it (settleOwnedLoadUi: completed, failed or cancelled); a superseding primary removes the model.
    • A 60 s backstop ends a stuck hold, counts it (geometryRestoreBackstopFires) and warns.
    • publishMetadataAtMark publishes the metadata store right after the metadata decode and emits load.metadataInteractive once the stored scene is shown, unless the load went stale.
  • lib/pick-gating.ts: isGeometryHeld / isGeometryRestoreHeld (restore pending only). Main's isGeometryLoadStreaming also counts a pending restore, so the picker never hits partial geometry.
  • useIfcCache: an adopted cache hit publishes metadata before chunk decode and hydrate.
  • Gated, with input ignored: selection click, context menu, touch tap, command press/drag/tap and its scheduled move callback, measure press/release, reposition, keyboard command steps, hover outline, selection highlight, section caps, drawing generation.
  • useViewportCursor: progress cursor after one frame of hold.
  • #9855's load window needs no change: hierarchy and properties do not read it, and geometry-derived counts stay held until load end.

Validation (final head)

  • Viewer tsc clean; check-module-size and check:source-text-assertions pass.
  • 80 viewer test files that import a touched module: 862 tests, 862 pass, 0 fail, 0 skipped. Run directly; the type-only store/types.ts is covered by tsc.
  • Failing-first tests for each behaviour fix:
    • a stale reopen emits no mark;
    • a touch begun during the hold does nothing on its lift;
    • an on-press drag released during a hold is cancelled, not left grabbed;
    • ignored click, tap, right-click, command and measure input during the hold, each working after release;
    • cold streaming keeps main's path.
  • Real-GPU e2e (Pop, untimed): reopen-held-pick plus the neighbouring specs (cold-load-scene-snapshot, entity-context-menu, federation-control-triplet, hierarchy-row-selection, section-extra-planes, section-measure-lasting-5893, selection-mask-depth, selective-clipping, viewer-smoke, visibility-scenarios). The rerun on the final head is pending here.
The 80 test files
  • components/viewer/ClashPanel.theme-repaint.test.tsx
  • components/viewer/Viewport.canvasObserver.test.tsx
  • components/viewer/captureHeldCommitPaths.test.tsx
  • components/viewer/commandPointer.aim-through.test.tsx
  • components/viewer/commandPointer.test.ts
  • components/viewer/contextMenuSelection.test.ts
  • components/viewer/heldSelection.test.ts
  • components/viewer/measureHandlers.constraint-triad.test.tsx
  • components/viewer/measureHandlers.distance-click.test.tsx
  • components/viewer/measureHandlers.gesture-reset.test.tsx
  • components/viewer/measureHandlers.polyline.test.ts
  • components/viewer/measurePick.held.test.ts
  • components/viewer/measurePointMode.test.tsx
  • components/viewer/placement/LocalTab.test.tsx
  • components/viewer/referenceSelection.test.tsx
  • components/viewer/ribbon/RibbonToolbar.model.test.tsx
  • components/viewer/selectionHandlers.angle.test.ts
  • components/viewer/selectionHandlers.appearanceFace.test.ts
  • components/viewer/selectionHandlers.polyline.test.ts
  • components/viewer/selectionHandlers.radius.test.ts
  • components/viewer/tools/MeasurementList.live-row-focus.test.tsx
  • components/viewer/tools/command/SnapHud.test.tsx
  • components/viewer/tools/measure-radius-panel.test.tsx
  • components/viewer/useHoverOutline.test.tsx
  • components/viewer/useMouseControls.clash-pivot.test.tsx
  • components/viewer/useMouseControls.depthPivot.test.tsx
  • components/viewer/useMouseControls.wheelZoom.test.tsx
  • components/viewer/useRenderUpdates.extraCaps.test.tsx
  • components/viewer/useRenderUpdates.overlayInk.test.tsx
  • components/viewer/useTouchControls.depthPivot.test.tsx
  • components/viewer/useTouchControls.pinchZoom.test.tsx
  • hooks/ingest/cacheRevalidation.test.ts
  • hooks/ingest/geometryEventSource.test.ts
  • hooks/modelLoadActivityOutcome.test.ts
  • hooks/modelLoadCanceller.test.ts
  • hooks/modelLoadEnd.test.ts
  • hooks/useDrawingGeneration.planCutAboveTop.test.tsx
  • hooks/useDrawingGeneration.planProjectionDefault.test.tsx
  • hooks/useDrawingGeneration.projection.test.tsx
  • hooks/useDrawingGeneration.restoredSectionConfig.test.tsx
  • hooks/useDrawingGeneration.rtcFrame.test.tsx
  • hooks/useDrawingGeneration.terminalState.test.tsx
  • hooks/useDrawingGeneration.test.tsx
  • hooks/useDrawingGeneration.type-visibility.test.tsx
  • hooks/useExtraSectionCaps.test.tsx
  • hooks/useIfcCache.fullhash.test.tsx
  • hooks/useIfcCache.inflateOffMain.test.tsx
  • hooks/useIfcCache.staleness.test.tsx
  • hooks/useIfcCache.v3TypeCase.test.tsx
  • hooks/useIfcFederation.ifcxSupersession.test.tsx
  • hooks/useIfcFederation.supersededWaiter.test.tsx
  • hooks/useIfcLoader.sharedLoadUi.test.tsx
  • hooks/useIfcServer.modelProperties.test.tsx
  • hooks/useKeyboardShortcuts.context.test.tsx
  • hooks/useKeyboardShortcuts.escape.test.tsx
  • hooks/useKeyboardShortcuts.measure-clear.test.tsx
  • hooks/useKeyboardShortcuts.section-planes.test.tsx
  • hooks/useKeyboardShortcuts.semantics.test.tsx
  • hooks/useKeyboardShortcuts.undo-focus.test.tsx
  • hooks/useModelUrlAutoload.test.tsx
  • hooks/useReloadResume.test.tsx
  • lib/activity/activity-recorders.test.ts
  • lib/commands/modeling/commands/copy-array.test.tsx
  • lib/commands/modeling/commands/room-place.test.tsx
  • lib/commands/modeling/commands/slab-place.test.tsx
  • lib/commands/modeling/commands/space-envelope-snap.test.tsx
  • lib/commands/modeling/commands/trim-extend.test.tsx
  • lib/commands/modeling/keys-workspace.test.tsx
  • lib/geometry-restore-gate.test.ts
  • lib/pick-gating.test.ts
  • lib/remesh/affected-set-opening.test.ts
  • lib/remesh/affected-set.grid-context.test.ts
  • lib/remesh/affected-set.test.ts
  • lib/retained/retainedLoad.test.ts
  • lib/viewport-debug-hooks.test.ts
  • sdk/adapters/store-adapter-publication.test.ts
  • sdk/adapters/store-adapter-roof-room.test.ts
  • store/hideSelection.surfaces.test.tsx
  • store/slices/authoringSessionSlice.workspace.test.tsx
  • store/slices/mutation-roof.test.ts

full viewer suite: 2884 files, 24144 tests, 0 failed, on 7c48be295e (head 0765357cf2 merged with main; ifc-viewer-tests 8, fleet job 037312e0 on Pop, receipt completed/exit 0; 23791 pass, 353 skipped, 0 cancelled).

šŸ¤– Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Cached scenes become interactive sooner: model metadata and tree-based selection are available while geometry restores.
    • Viewport selection, measurements, context menus, modeling commands, and section overlays wait until geometry restoration is complete.
    • Deferred camera framing resumes when the relevant geometry is ready.
  • Bug Fixes
    • Prevented presses and clicks made during restoration from unexpectedly selecting, placing, or repositioning items after release.
    • Restored normal viewport interactions once geometry restoration finishes.