From 29d38af337f26984fa41892320e74b9da82b3110 Mon Sep 17 00:00:00 2001 From: Joe Vilches Date: Mon, 12 Aug 2024 16:17:03 -0700 Subject: [PATCH] Extra log for case where availableHeight is undefined and sizing mode != max content (#1687) Summary: X-link: https://github.com/facebook/react-native/pull/45965 Pull Request resolved: 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] Differential Revision: D61054392 --- yoga/algorithm/CalculateLayout.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/yoga/algorithm/CalculateLayout.cpp b/yoga/algorithm/CalculateLayout.cpp index 8db5fa41de..4b8f9a5fb7 100644 --- a/yoga/algorithm/CalculateLayout.cpp +++ b/yoga/algorithm/CalculateLayout.cpp @@ -661,6 +661,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 +756,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,