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 (#45965)

Summary:
Pull Request resolved: #45965

X-link: facebook/yoga#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

fbshipit-source-id: 654ff96f94aa89605a603e2e36335bb48b61f4a2
  • Loading branch information
joevilches authored and facebook-github-bot committed Aug 19, 2024
1 parent 0f3ed90 commit 7027eac
Showing 1 changed file with 22 additions and 0 deletions.
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 7027eac

Please sign in to comment.