feat(viewer): type visibility hides ids on the GPU instead of re-uploading (#10264)
Part of #10264: the type-visibility prerequisite before CPU-geometry release (S4). Internal work, so it carries the unqueued label and claims no issue. Product release stays off.
What changes
Type visibility no longer decides which meshes the scene uploads. That covers the class toggles (spaces, spatial zones, openings, virtual elements, site/terrain, annotations), the Model/Types switch and the analytical/physical modes. Every merged mesh is uploaded once, including the IfcSpace and IfcOpeningElement geometry hidden by default. A toggle only changes which entity ids the viewport hides, through the S2 GPU hide table. Nothing is re-uploaded from the store's CPU arrays.
-
type-hidden-index.ts. For each (geometry class, IFC class) pair, it keeps the global ids of the entities whose meshes carry that pair. Ids are appended per streamed batch, read once fromexpressId,ifcType,geometryClassand the distinctentityIds; no mesh arrays are kept. A toggle rebuilds the id set; a batch that hides more ids produces a new set (copy-on-write). The verdict is the per-mesh rule the old upload filter applied, evaluated per entity. -
useFilteredGeometryreturns every mesh (sceneGeometry), the existing replacement detection, andtypeHidden. The CPU filter and the toggle-driven rebuild are removed. -
useVisibilityState(typeHidden)folds the type-hidden ids into the derived set the viewport draws, picks, frames and highlights by. This happens in a separate memo, so a batch's new ids don't re-run the structural mask over every entity. The store'shiddenEntitiesis never written. -
Cached reopen. A scene snapshot holds every mesh, and adoption paints before the meshes decode. The snapshot now stores the index's buckets (
typeIndexin its host data: classes and ids, no geometry). Adoption then:- installs the stored index (
snapshot-type-index.ts); - waits until the viewport has committed the ids it hides under the toggles current at reopen (not at capture), and only then adopts and paints;
- stops using the stored index once the meshes are published or the load ends. A newer load supersedes an older one.
A snapshot without a type index is not adopted, and the hit streams instead. The snapshot key drops the type filter.
- installs the stored index (
-
Framing. The camera-fit accumulator folds every mesh:
full(clipping and section range) covers every mesh, shown or not;fitandrobust(framing) apply the exclusions current at each call, so a class shown mid-stream frames again.
Frame building extent and the renderable-bounds lookup behind
resolveHighlightIdstreat type-hidden meshes as absent. Cesium gets the mesh list without them. -
Point clouds. A type toggle over models without point clouds keeps the previous empty point-cloud list. Before, it re-synced an empty list, which recomputed model bounds and refit the shadows.
Not changed: release, readback and S4 (all still off); the S2 and S3 paths; coldGeometryProvider.
Validation at 4e1f9b8c7b (main merged, 2026-11-20)
- Queue head 9558b27781 = 68f2b07480 + main at 2d54af0de6 (#11038). Full viewer suite as above; all six required checks pass on 9558b27781. Entry JS with #10880 also merged measures 2,005,258 bytes, within the 2,012,040 ceiling #11042 set (#11066, opened for this, was closed as superseded).
- Merge-queue batch #11036 (18:38): three
visibility-scenarios.e2e.spec.tstests failed because they asserted that type-hidden entities have no scene owner, while this PR keeps them in the scene and hides them on the GPU. 68f2b07480 asserts "not drawn" instead (renderer visibility); the old spec fails and the new one passes all three locally. Test-only change; the full viewer suite above still applies. The same batch'sViewer E2E smoke (2/8)was killed at its 13-minute cap with 27 tests passed; passing batches today took 9 to 13 minutes on that shard. - full viewer suite: 4 shards, 25,064 tests, 0 failed, on 4e1f9b8c7b. Shards 0-2 are from fleet job baa5bb5f. Shard 3 failed there once, in
useSymbolicAnnotations.afterLoad.test.tsx:196, a pre-existing load-timing flake this PR does not touch (root cause and fix: #11002). Shard 3 was then rerun on the same head (fleet job auto-bed73e1a): 6,733 tests, 0 failed. - Perf ratchet: all metrics within their ceilings on the main merge, after #10852 raised the eager-JS ceiling, so the 6,082-byte overage below is resolved.
- #10865 merged as aad7a26. Its three files here are byte-identical, so they drop out of this diff on merge.
Evidence at head d50f0de1f7 (merge-base 9e47ef2960)
Real GPU (Pop, NVIDIA lovelace, headed Chromium on a private Xvfb with Vulkan ANGLE, ifc-gpu-check, untimed). All four #10264 specs ran on this head: 24 passed, 2 skipped (the Holter tower fixture is absent), 1 failed: S2 storey-isolation. That failure is the #10853 overlay race: grid and dimension overlays arrive between the A and B captures. With #10861's overlay setting applied temporarily (not committed), the same test passes on this head.
Scenario (gpu-type-visibility) | Type-hidden flat | Batches and vertex buffers kept | Shown vs hidden (strong px) | Hidden again vs first frame | Against the visible pieces alone, hide table cleared |
|---|---|---|---|---|---|
| C20-Institute, shadows on | 369 | yes (45) | 2,496 | 0 px | 0 strong / 0 differing |
| Institute + duplex federation | 440 (71 in model 2) | yes (82) | 2,985 | 0 px | 0 / 0 |
Test-only releaseGeometryData(), classes never shown before | 369 | yes | 2,496 | 0 px | shown frame vs a scene with its CPU copy: 0 / 0 |
| Model/Types switch | 784 hidden in Types | yes (45) | 55,618 | 0 px | ā |
| Cached reopen: spaces shown at capture, hidden at reopen | 369 | ā | first adopted frame vs capture-time view: 2,036 | ā | probed at adoptSceneSnapshot, 0 meshes published: 0 of 369 missing from the hidden set; first frame vs settled frame 0 / 0 |
In every test, no type-hidden entity was picked, by GPU or CPU raycast.
Unit and behaviour tests
type-hidden-index.test.ts(new): across 768 combinations of toggles and modes, the hidden ids equal what the old per-mesh filter dropped. Also covers retypes, copy-on-write streaming, the snapshot metadata round trip, malformed metadata, and the install fences (superseded load, foreign clear, no viewport).sceneSnapshotLoad.typeIndex.test.tsx(new, realScene): cold stream, capture, stored entry, then adoption with the decode held back. The first paint request already hides what the toggles hide at reopen, for capture/reopen pairs hidden/hidden, shown/hidden and hidden/shown. A toggle inside the window applies; abandoning the load clears it. No metadata, or no viewport, means no adoption.robustFitBoundsAccumulator.excluded.test.ts(new): a hidden 900 m cutter shown mid-stream frames again,fullalways covers it, and each incremental result equals a full rescan.useGeometryStreaming.meshlessModel.test.tsx(realScene): a toggle creates no GPU buffer, makes noappendToBatchescall and makes noclearFlatGeometryForRebuildcall, before and afterreleaseGeometryData().
Gates
- Full 4-shard viewer suite at d50f0de1f7 (Pop job
25aa9998, requestauto-89abe3ed,IFCLITE_TEST_CHROME_EXECUTABLEset): all four shards exit 0.- shard 0: tests 6395, pass 6283, skipped 112
- shard 1: tests 6402, pass 6295, skipped 107
- shard 2: tests 5446, pass 5333, skipped 113
- shard 3: tests 6694, pass 6664, skipped 30
- total: 24,937 tests, 24,575 passed, 0 failed, 0 cancelled, 362 skipped (fixtures were not fetched on the worker).
- Earlier head 173f18143d (request
auto-f3bbaf42): 24,906 tests, 24,544 passed, 0 failed, 362 skipped. node scripts/pre-handoff.mjs --base 9e47ef2960: all 16 gates pass, including retained-free viewer (1,687 files) and the revert oracle (the change is observed: 37 failures with it reverted). New modules have surgical mutation witnesses, all OBSERVED and restored green: thetype-hidden-index.tsview-mode verdict, its incremental add, and thesnapshot-type-index.tsstale-load fence.- Root
pnpm typecheckat d50f0de1f7: exit 0. Pop jobbc90c753, requestauto-2449fbdf; 24 GiB, 8 GiB heap, Turbo concurrency 1, with the root tail: 148/148 tasks, and all 5,359 test files are in a typecheck program. Two earlier PC requests (auto-03f5e3db, and the bundle A/Bauto-e34f0717) ended at launch withValueErrorand never ran: the prepared PC checkout was not at this head. Their records are kept unchanged.
Dependencies and limitations
- Perf ratchet (
viewer-eager-js-bytes). CI measures this head's merge commita4c9899at 13,473,318 bytes. Today's allowed value is 13,467,236, so it is 6,082 over. #10852 (maintainer-owned, open) sets the ceiling to main's 13,465,340, which allows 13,478,805; this head would pass with 5,487 bytes to spare. No ceiling is changed here. The only writer-only code in the eager bundle isTypeHiddenIndex.metadataOf, a few hundred bytes. The base-vs-head bundle A/B (requestauto-e34f0717) never ran (see above), so the split between this change and main's growth is not measured. - 2306278404 belongs to #10865 (validated, queued). It shows in this diff until #10865 merges, after which main will be merged in so it drops out naturally.
- S2
storey-isolationdepends on #10861 for overlay-race stability, as shown above. - Cost (not measured): a batch that hides more ids builds a new set, O(hidden). The renderer compares and re-sorts its hidden table per change and compares its contents each frame, as for any hide. Spaces and openings keep the set small; the Types view and the structural modes hide most entities.
- Other limitations:
- spaces and openings now take GPU memory from the first load;
- section slider bounds include type-hidden geometry;
- follow-up (review r4640413144, deferred under the review-round cap): a model with no far outlier tail fits its first camera to the raw
shiftedBounds, so types hidden at load can widen that framing. Fix: when exclusions are active andrbEarly.fitis set, fit to it before theshiftedBoundspath. Same class (r4646867585): a model whose only meshes are default-hidden spaces frames those hidden meshes at streaming completion; with nothing visible it should keep the default camera; - the #10653 caveat still applies to secondary vertex-lane ids;
- the embed viewer keeps its own filter;
- inline point clouds are still filtered by class.
- Test gaps: the structural modes are covered by unit tests only (no public fixture with analytical members). Grid and annotation meshes are not exercised as type-hidden on the GPU.
š¤ Generated with Claude Code