fix: incorrect cache validation logic causing cache false hit#1965
Open
MaksimGalois wants to merge 1 commit into
Open
fix: incorrect cache validation logic causing cache false hit#1965MaksimGalois wants to merge 1 commit into
MaksimGalois wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@zeyap has imported this pull request. If you are a Meta employee, you can view this in D106414616. |
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.
Summary
In
YGLayout.cpp, when callingnewSizeIsStricterAndStillValidto check measure cache eligibility, the current constraintsizeis passed as net remaining space (availableHeight - marginColumn). However, the historical constraintlastSizeis erroneously passed as gross space (lastAvailableHeight) without subtracting the margin.This asymmetric comparison (comparing net space with gross space) leads Yoga to falsely assume that the available space has shrunk (triggering the
lastSize > sizebranch) when the container actually grows. Consequently, a truncated cache result from a previously compressed pass is incorrectly reused.Solution
Deduct the corresponding margin size (
marginColumn/marginRow) fromlastAvailableHeight/lastAvailableWidthrespectively when callingnewSizeIsStricterAndStillValidto ensure symmetrical net-to-net boundary comparisons.Changelog
[C++] [Fixed] - Correct net layout space comparison in measure cache check by deducting margin.
Test Plan & Minimal Reproducible Example
Added a new dedicated unit test
remeasure_when_container_grows_with_child_margininYGMeasureCacheTest.cpp, which serves as a MRE for this specific bug.Reproduction and Verification Steps:
10.0f). Due to a child margin (5.0f), the net available space for the child is constrained to5.0f. The child's measured layout height is compressed to5.0fand cached erroneously.15.0f, releasing enough net available space (10.0f) to completely accommodate the child's desired target height (10.0f).newSizeIsStricterAndStillValid, Yoga incorrectly triggers a false cache hit during the second pass. It blindly reuses the stale, compressed height of5.0ffrom the cache without re-measuring, causing themeasureCountassertion to fail (retains 1 instead of 2).measureCountincrements to 2) and the child layout height successfully recovers to its correct desired height of10.0f. All assertions pass green.