Skip to content

Commit

Permalink
Extra log for case where availableHeight is undefined and sizing mode…
Browse files Browse the repository at this point in the history
… != max content (#1687)

Summary:
X-link: facebook/react-native#45965

Pull Request resolved: #1687

We are seeing some crashes that are hard to wrap our head around. Lets add more logs. I chose these values based on what could make the height/width undefined from looking at the code. We might need more but this should give us some more direction.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D61054392
  • Loading branch information
joevilches authored and facebook-github-bot committed Aug 19, 2024
1 parent ae8ede9 commit 0b19270
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions yoga/algorithm/CalculateLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <cfloat>
#include <cmath>
#include <cstring>
#include <string>

#include <yoga/Yoga.h>

Expand Down Expand Up @@ -661,6 +662,13 @@ static float distributeFreeSpaceSecondPass(
}
}

yoga::assertFatalWithNode(
currentLineChild,
yoga::isDefined(updatedMainSize),
("updatedMainSize is undefined. mainAxisownerSize: " +
std::to_string(mainAxisownerSize))
.c_str());

deltaFreeSpace += updatedMainSize - childFlexBasis;

const float marginMain = currentLineChild->style().computeMarginForAxis(
Expand Down Expand Up @@ -749,6 +757,20 @@ static float distributeFreeSpaceSecondPass(
const bool isLayoutPass = performLayout && !requiresStretchLayout;
// Recursively call the layout algorithm for this child with the updated
// main size.

yoga::assertFatalWithNode(
currentLineChild,
yoga::isUndefined(childMainSize)
? childMainSizingMode == SizingMode::MaxContent
: true,
"childMainSize is undefined so childMainSizingMode must be MaxContent");
yoga::assertFatalWithNode(
currentLineChild,
yoga::isUndefined(childCrossSize)
? childCrossSizingMode == SizingMode::MaxContent
: true,
"childCrossSize is undefined so childCrossSizingMode must be MaxContent");

calculateLayoutInternal(
currentLineChild,
childWidth,
Expand Down

0 comments on commit 0b19270

Please sign in to comment.