Batch node measurements and mount toolbars only while active

This commit is contained in:
2026-11-10 00:03:14 +08:00
parent da7d9d056f
commit d8bf6406c6
9 changed files with 97 additions and 14 deletions
+26
View File
@@ -694,3 +694,29 @@ are not an SLA or proof of overall speedup. The 10000-child baseline probe at
0ce3abb remained unresponsive with a CPU-active renderer and approximately
4.4 GiB sampled physical footprint, and was interrupted. Its completion, first
frame and root cause remain unverified; 10000-node support is not claimed.
Node measurement requests now share a microtask batch per React Flow store.
`createNodeInternalsBatch` owns a Map from mount tokens to node IDs and a dirty
Set of tokens. A flush deduplicates live IDs and invokes the public bulk update
once. Releasing a mount removes its pending request without touching a replacement
mount for the same ID. Reentrant invalidation schedules another flush; separate
stores never share work. The React adapter keys its WeakMap by `getState`, because
`useStoreApi()` creates a separate wrapper per hook. Acquisition/release happens
in effects, and the invalidate callback stays stable across renders. The SDK
still schedules its own animation frame; the adapter adds no extra frame timer.
Inactive node/frame toolbars no longer mount `NodeToolbar`. AnimatePresence owns
the conditional toolbar so selection, portal editing and exit animation remain
available. In React Flow 12.12.1 each mounted toolbar subscribes to a selector
that scans the whole node array; an empty child was not an inactive subscription.
Likewise each individual forced measurement updates all absolute positions, so
per-node mount calls multiplied work. Both paths are bounded by actual active
UI needs now. These are renderer resources; no model, history or durable queue
state changes.
A 10000-node page reached its initial scene after these changes, but its copy
probe still exceeded the 240-second completion window. During the copy it accepted
read-only diagnostics and displayed incremental content; commit/persistence costs
remain unresolved at that scale. Do not interpret the initial-scene improvement
or the batching checks as a passed 10000-node copy budget.