Repository navigation
Batch size measurements - #673
Conversation
11a33d0 to
13245a4
Compare
| @@ -152,9 +152,8 @@ export class FlowResizeBatchProcessorService { | |||
| */ | |||
| private processNodeBatch(entries: ProcessedEntry[]): void { | |||
There was a problem hiding this comment.
The post-init path now emits commandHandler.emit('updateNodes', { nodes: nodeSizeUpdates }) for all size updates - both nodes without an initial size and nodes whose size changed.
Before this PR, the size-changed branch went through flowCore.updater.applyNodeSize(nodeId, size), which is implemented in InternalUpdater as:
applyNodeSize(nodeId, size): void {
const node = this.flowCore.getNodeById(nodeId);
if (!node || this.isResizing() || this.hasSameSize(node, size)) {
return;
}
this.flowCore.commandHandler.emit('resizeNode', { id: nodeId, size });
}InternalUpdater.applyNodeSize is unchanged in this PR - but the new call site bypasses it entirely for post-init size-changed nodes. As a result:
- The
isResizing()early-return is no longer reached on this path. While the user is mid-drag on a resize handle,actionStateManager.isResizing()returnstrueand the resize action is the source of truth (with snapping, constraints, transforms). Previously, ResizeObserver-driven updates were suppressed during this window. Now they fireupdateNodesand may compete with the resize action - risk of size flicker, fighting snapping, or overwriting transformed values with raw DOM measurements. - The
isResizingflag is still computed inprocessNodeBatch, but it now only gates the port-measurement follow-up - not the size update itself.
Either restore the guard (skip pushing to nodeSizeUpdates when isResizing is true), or document explicitly why ResizeObserver-driven updates are now expected to fire mid-resize.
There was a problem hiding this comment.
resolved - restored isResizing guards
| } | ||
|
|
||
| flowCore.updater.applyNodeSize(metadata.nodeId, size); | ||
| nodeSizeUpdates.push({ id: metadata.nodeId, size }); |
There was a problem hiding this comment.
Size-changed nodes post-init are now routed through 'updateNodes' instead of 'resizeNode', silently dropping resize-domain logic
To be clear about what changed: commandHandler.emit('updateNodes', ...) was already present in the post-init branch before this PR. The structural shape of if (flowCore.isInitialized) { emit('updateNodes', ...) } else { ...applyNodeSize... } is identical before and after. The change is what gets pushed into the emitted array.
Before this PR, the loop split entries into two paths:
- Branch A - no current size (
!currentSize): pushed intonodesNeedingInitialSize, emitted as a singleupdateNodespost-loop. - Branch B - size changed (
isSizeChanged(currentSize, size)): calledflowCore.updater.applyNodeSize(id, size)per-node inside the loop, which routes throughInternalUpdater.applyNodeSize→ emits'resizeNode'with the full domain pipeline.
After this PR, both branches are merged into a single nodeSizeUpdates array, and the post-loop updateNodes emit now carries entries from Branch B as well. So Branch A is unchanged, but Branch B's command path silently switches from 'resizeNode' to 'updateNodes'.
The two handlers are not equivalent:
resizeNode(resize-node.ts) handles missing-initial-size viahandleMissingInitialSize, applieshandleGroupNodeResize(children bounds containment,applyMinimumSizeConstraints), andhandleSingleNodeResize(minimum size, snapping).updateNodes(add-update-delete.ts) is a bare passthrough toapplyUpdate({ nodesToUpdate: nodes }, 'updateNodes')- no constraints, no group containment, no snapping.
Concrete scenarios that regress post-init (only Branch B - size-changed nodes):
- A selected group node whose child reflows: ResizeObserver fires for the group →
updateNodesis emitted → children bounds containment and minimum-size constraints are not applied. - An unselected group node whose child reflows: this is the most surprising case.
resizeNodeearly-returns atresize-node.ts:120forisGroup(node) && !node.selected, so previously the group's stored size was not touched during a child reflow - it was treated as user-set source of truth. Post-PR,updateNodesoverwrites the stored size with the raw DOM measurement on every reflow. This silently mutates an invariant that previously held. - A non-group node with dynamic content (e.g. content-driven CSS sizing) shrinks below
getMinNodeSize:updateNodesaccepts the raw size; previouslyresizeNodeclamped it viaapplyMinimumSizeConstraints. - Snapping configured for resize: previously applied via
handleSingleNodeResize→applySnappingIfNeeded; now skipped on this path.
Branch A (no-initial-size) is unaffected: even pre-PR it bypassed resizeNode's constraint pipeline, because resizeNode's handleMissingInitialSize (resize-node.ts:195-207) itself just emits a bare updateNode without constraints. So the pre-PR updateNodes emit was effectively equivalent to what resizeNode would have done for that case. The regression is exclusively about Branch B - size-changed nodes that previously preserved the full resize-domain semantics and now do not.
Options:
- Keep the per-node
applyNodeSizecall for size-changed nodes (preserves'resizeNode'and its logic), and only batch the no-initial-size path (status quo before the PR). - Or introduce a new bulk command like
'resizeNodesBulk'that runs the same group/min-size/snapping pipeline as'resizeNode'but for an array of nodes, and emit that instead. - Or explicitly document that ResizeObserver-driven post-init updates intentionally skip resize-domain logic, and accept the regression.
Tests to add in flow-resize-processor.service.spec.ts and/or resize-node.test.ts:
- Selected group node with children whose total bounds exceed a shrunk parent size → trigger ResizeObserver post-init → assert children-bounds containment is still applied.
- Unselected group node whose child reflows → trigger ResizeObserver post-init → assert the group's stored size is not silently overwritten with the raw DOM measurement (preserving the prior invariant), or explicitly document that this invariant is dropped.
- Non-group node with
getMinNodeSizeconfig → trigger ResizeObserver with smaller size post-init → assert size is clamped to minimum. - Snapping enabled + ResizeObserver-driven update post-init → assert snapping is applied (or document drop).
Suggested fix (combined with Comment 4):
Re-introduce the pre-PR partition between Branch A and Branch B inside processNodeBatch:
- Branch A - no current size → batch via
commandHandler.emit('updateNodes', ...)(preserves the original batching intent for palette drops / virtualization). - Branch B - size changed → per-node
flowCore.updater.applyNodeSize(id, size), which already routes through'resizeNode'with the full pipeline (group containment, min-size, snapping) and respects theisResizing()guard.
This restores pre-PR semantics for size-changed nodes while keeping the bulk benefit for the case the batching was actually introduced for.
There was a problem hiding this comment.
We resolved this intentionally by choosing a different approach than any of the three options suggested. After analyzing
resizeNode's domain logic, I concluded that none of it was appropriate for ResizeObserver-driven updates — it was
user-resize logic that was historically applied to DOM measurements only because all sizes happened to route through
applyNodeSize → resizeNode:
- Min-size constraints / snapping: These are user-resize concerns. The DOM already rendered at its actual size — clamping
or snapping a DOM measurement would fight the real layout. - Group containment: Prevents the user from dragging a group smaller than its children. Not relevant when the DOM is
reporting the group's actual rendered size. - Unselected group skip (isGroup(node) && !node.selected): This means "you can't resize a group unless it's selected" — a
user-interaction guard. For ResizeObserver, autoSize: false groups have explicit CSS dimensions, so the DOM reports the
same size as stored → isSizeChanged already filters it as unchanged. autoSize: true groups should accept DOM measurements
regardless of selection state. - isResizing guard: The only guard that actually matters for ResizeObserver. I restored it in applyNodeSizes — it
suppresses size-changed nodes during active user drag, but allows initial sizes through (nodes without size yet need their
first measurement regardless).
What I did:
- processNodeBatch now collects all size updates and delegates to updater.applyNodeSizes() — no branching, no domain
logic at the call site - InternalUpdater.applyNodeSizes handles the guards (isResizing for size-changed nodes, isSameRect dedup) and emits
'updateNodes' - InternalUpdater.applyNodeSize (singular) also emits 'updateNodes' instead of 'resizeNode' for consistency
- resizeNode command is now exclusively for user-initiated resize (drag handles, public API)
Addressing each scenario:
- Selected group, child reflows: Previously resizeNode applied containment. Now updateNodes accepts the DOM size. Correct
— the DOM is the source of truth for content-driven changes, containment is for user drag. - Unselected group, child reflows: Previously resizeNode skipped the update. Now it passes through, but isSizeChanged
filters it because autoSize: false groups have explicit CSS size matching the stored size. Same effective behavior. - Node shrinks below minSize: Previously resizeNode clamped it. Now updateNodes accepts the DOM size. Correct — the DOM
already rendered at that size, clamping would create a mismatch. - Snapping configured: Previously resizeNode snapped. Now updateNodes accepts the DOM size. Correct — snapping is for
user-driven drag, not content reflow. - Active user resize: isResizing guard suppresses the update. Same behavior as before.
f63467c to
fe224a5
Compare
fe224a5 to
2d1c288
Compare
* Size measurement batching * BatchDomObserver with MutationObserver for styles * Method rename + unobserve for styles * Reverted changes to position discovery * Reverted observeResize rename * Dynamic ports & labels test mode * Moved new tests to separate component * Reformatting * Disabled some buttons when default node type is used * OnPush + signals in batch-test-toolbar * Measurement tracking reworked (#685) * Measurement tracking reworked * Manual test cases * Api report updated * Measurement tests improved * Css port reposition test * Update discovery window timeout * Test name updated * Comment update
* New batch processors + bulk as only methods * Batch processors unified * Fixed order of actions in batch-processor * Better onFlush callbacks support for batch-processor * Simpified port update strategies * Reference stabilization for callbacks * Better support for virtualization in batch processors * Batch size measurements (#673) * Size measurement batching * BatchDomObserver with MutationObserver for styles * Method rename + unobserve for styles * Reverted changes to position discovery * Reverted observeResize rename * IsResizing gate re-added to processNodeBatch * Routing size changes through updater once again (but with batching) * Ports measurement optimization * Further port/label processing optimization * Additional unit tests and and minor optimization * Dynamic ports labels test (#683) * Size measurement batching * BatchDomObserver with MutationObserver for styles * Method rename + unobserve for styles * Reverted changes to position discovery * Reverted observeResize rename * Dynamic ports & labels test mode * Moved new tests to separate component * Reformatting * Disabled some buttons when default node type is used * OnPush + signals in batch-test-toolbar * Measurement tracking reworked (#685) * Measurement tracking reworked * Manual test cases * Api report updated * Measurement tests improved * Css port reposition test * Update discovery window timeout * Test name updated * Comment update
* Batching all port and label changed props * Better support for undefined values in internal-updater * Batch processor race conditions fix (#672) * New batch processors + bulk as only methods * Batch processors unified * Fixed order of actions in batch-processor * Better onFlush callbacks support for batch-processor * Simpified port update strategies * Reference stabilization for callbacks * Better support for virtualization in batch processors * Batch size measurements (#673) * Size measurement batching * BatchDomObserver with MutationObserver for styles * Method rename + unobserve for styles * Reverted changes to position discovery * Reverted observeResize rename * IsResizing gate re-added to processNodeBatch * Routing size changes through updater once again (but with batching) * Ports measurement optimization * Further port/label processing optimization * Additional unit tests and and minor optimization * Dynamic ports labels test (#683) * Size measurement batching * BatchDomObserver with MutationObserver for styles * Method rename + unobserve for styles * Reverted changes to position discovery * Reverted observeResize rename * Dynamic ports & labels test mode * Moved new tests to separate component * Reformatting * Disabled some buttons when default node type is used * OnPush + signals in batch-test-toolbar * Measurement tracking reworked (#685) * Measurement tracking reworked * Manual test cases * Api report updated * Measurement tests improved * Css port reposition test * Update discovery window timeout * Test name updated * Comment update
No description provided.