From 7027eac09aeaaba9c2025e72b1fa9434a293c7ee Mon Sep 17 00:00:00 2001 From: Joe Vilches Date: Mon, 19 Aug 2024 16:13:44 -0700 Subject: [PATCH] Extra log for case where availableHeight is undefined and sizing mode != max content (#45965) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45965 X-link: https://github.com/facebook/yoga/pull/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 --- .../yoga/yoga/algorithm/CalculateLayout.cpp | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp b/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp index 8db5fa41de131c..2cbeac69578b80 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp +++ b/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include @@ -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( @@ -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,