Repository navigation
Conversation
Pass five numbers across the private measure crossing and reconstruct public MeasureArgs in the wrapper. Ignore extra fields on the returned size.
Encode absent known sizes as NaN, MinContent as -1, and MaxContent as -2. Layout sizes are non-negative, so those values do not collide with a definite size.
Constraints cross in a caller-owned Float64Array that the binding fills before each request, and the callback argument is only the getStyle handle. Presence and AvailableSpaceKind live in their own tag slot, so a numeric slot never doubles as its own tag: a caller-supplied definite -1 or -2 stays a definite available space instead of arriving as MinContent or MaxContent. Taffy's node id crosses as two 32-bit halves, so a slot whose version has advanced past the double-precision range still reaches the right measure function instead of failing the layout. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016docmM5eMBWUXY4vvhztBN
Owner
Author
|
Landed on That commit carries the measure constraints in a caller-owned reusable Ignoring extra own properties on a measure result lands unchanged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Measure callbacks receive the same public
MeasureArgsvalues. The private crossing now carries the constraints in a caller-owned reusableFloat64Arrayrecord, and the callback argument is only the existinggetStylehandle. Extra properties on the returned size are ignored.A return of
{ width: 40, height: 16, extra: 3 }measures as{ width: 40, height: 16 }. Missing fields,null, arrays, and non-number payloads still throwTypeError.Why
Each measured layout pauses into JavaScript once per exact request. The cost of that pause was dominated by building a nested constraint object per request and enumerating the returned object's keys. In the coding-agent chat scenarios,
#computeMeasuredLayoutitself was 68.9% and 77.6% of CPU on the@taffyjs/nodepath.The record keeps the private transport independent of the public representation, so no numeric slot has to double as its own tag:
AvailableSpaceKindof each axis occupy one tag slot. A caller-supplied definite-1or-2therefore stays a definite available space rather than becomingMinContentorMaxContent.knownDimensions,availableSpace, andNodeIdbefore calling the user function, and those values stay ordinary mutable objects created per request.One shared record serves the common case. A measure callback may lay out another tree, so a nested compute takes its own record and leaves the outer one untouched.
This does not change how often Taffy asks for a measurement, and it does not make
@taffyjs/nodematch yoga-layout's callback count.Performance
Same machine, Node v24.19.0, local
vp run benchmarkprofile,mainand this branch measured in alternating rounds. Scenarios were not edited.@taffyjs/nodemainThe
yoga-layoutcontrol moved by less than the spread between rounds: 0.8129 ms and 0.9057 ms for the initial layout, 0.2078 ms and 0.2085 ms for the resize.benchmarks/results/published.jsonis unchanged.Validation
vp run checkvp run check:wasm-1and-2available space reaches the callback asDefinite, alongside the existing-4,-0,NaN, and infinity cases