Commit 3e962d3
guard shrink-factor division against floating-point near-zero (#57175)
Summary:
Pull Request resolved: #57175
fixes react/yoga#1665.
**problem:** when all flex children are frozen to their min-width in the first
pass, `totalFlexShrinkScaledFactors` is reduced to near-zero by floating-point
cancellation rather than exactly 0. the guard in `distributeFreeSpaceSecondPass`
uses exact equality (`== 0`), so it never fires, and the second pass divides
`remainingFreeSpace` by a value on the order of 1e-7, producing a childSize on
the order of 1e11 that overwhelms the min/max clamp.
**fix:** replace the exact-zero check with a relative epsilon guard
(`shrinkFactorMagnitude < 1e-6f`). when the magnitude is that small, all items
were already frozen in the first pass; the safe fallback (`childFlexBasis +
flexShrinkScaledFactor`) applies and the subsequent `boundAxisWithAutoMin` clamps
correctly to minWidth.
regression: `YGFlexShrinkBorderBug.flex_basis_0_border_minwidth_row` reproduces
the original crash — 4 children, `borderWidth` difference of 1e-6 across them,
all now compute to their correct minWidth.
## Changelog:
[Internal] -
X-link: react/yoga#1974
Reviewed By: javache
Differential Revision: D108030908
Pulled By: cipolleschi
fbshipit-source-id: 3e8d4ef6773bc31703a54005bf610b2432f22d2d1 parent b933d18 commit 3e962d3
1 file changed
Lines changed: 8 additions & 1 deletion
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1104 | 1104 | | |
1105 | 1105 | | |
1106 | 1106 | | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
1107 | 1114 | | |
1108 | | - | |
| 1115 | + | |
1109 | 1116 | | |
1110 | 1117 | | |
1111 | 1118 | | |
| |||
0 commit comments