Measure both axes so width-only measurements are safe to cache - #619
Open
maurerdietmar wants to merge 1 commit into
Open
Measure both axes so width-only measurements are safe to cache#619maurerdietmar wants to merge 1 commit into
maurerdietmar wants to merge 1 commit into
Conversation
maurerdietmar
force-pushed
the
width-only-measure-cache
branch
from
August 8, 2026 07:47
c67a466 to
41f081a
Compare
Asking a box only for its width, when its width is already known, gets a height of zero back: taffy's block layout short-circuits, because the caller said it did not want the height. The measurement cache keys on the known dimensions and treats the requested axis as irrelevant, so that answer is stored where a later height query for the same box finds it, and the box reports no content at all. Table cells are laid out at the width of their column, which is what makes them ask for this. A row then falls back to whatever height is specified elsewhere in it: a data table row carrying a spacer cell of `height: 22px` came out 22 tall around a 30px cell, clipping the text against the bottom of every row, and a row with no specified height anywhere collapsed onto its padding. An earlier revision of this fix kept width-only answers out of the cache instead. That traded the wrong answer for recomputation: every width probe a flex or block parent issues laid its subtree out again, and a page nested a few flex and scroll containers deep re-shaped its text dozens of times over in a single pass - a 33x difference in inline layout work for the same content, and seconds of delay when a form-heavy view appeared. Upgrade width-only size requests to both axes before they reach the layout algorithms instead. The height at the resolved width is computed once per cache key, every stored entry answers any axis, and repeated probes hit the cache. The zero-height short-circuits in the algorithms become dead paths rather than cache poison. Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
maurerdietmar
force-pushed
the
width-only-measure-cache
branch
from
August 8, 2026 07:57
41f081a to
3ebb2d4
Compare
Contributor
Author
|
Reworked: instead of keeping width-only answers out of the cache, width-only requests are upgraded to both axes so every cached entry is complete — the exclusion made every width probe re-lay-out its subtree, which we measured as a 33x inline-layout overhead on deeply nested pages. Tests 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.
Asking a box only for its width, when its width is already known, gets a height of zero back: taffy's block layout short-circuits, because the caller said it did not want the height. The measurement cache keys on the known dimensions and treats the requested axis as irrelevant, so that answer is stored where a later height query for the same box finds it, and the box reports no content at all.
Table cells are laid out at the width of their column, which is what makes them ask for this. A row then falls back to whatever height is specified elsewhere in it: a data table row carrying a spacer cell of
height: 22pxcame out 22 tall around a 30px cell, clipping the text against the bottom of every row, and a row with no specified height anywhere collapsed onto its padding.Answer width-only requests from the cache when a full measurement is already there, and otherwise measure without storing the result. The height a later query needs is computed once either way, so this trades no work for the correct answer.
WPT results
22 newly passing, 8 newly failing (net +14).
Full diff (30 changed tests)
Generated by the WPT workflow.