diff --git a/ReactCommon/react/debug/react_native_assert.h b/ReactCommon/react/debug/react_native_assert.h index b152858b809f05..9ee5ce631c3d0d 100644 --- a/ReactCommon/react/debug/react_native_assert.h +++ b/ReactCommon/react/debug/react_native_assert.h @@ -12,6 +12,12 @@ // test before moving on. When all issues have been found, maybe we can use // `UNDEBUG` flag to disable NDEBUG in debug builds on Android. +// Asserting is appropriate for conditions that: +// 1. May or may not be recoverable, and +// 2. imply there is a bug in React Native when violated. +// For recoverable conditions that can be violated by user mistake (e.g. JS +// code passes an unexpected prop value), consider react_native_expect instead. + #include "flags.h" #undef react_native_assert diff --git a/ReactCommon/react/debug/react_native_expect.h b/ReactCommon/react/debug/react_native_expect.h new file mode 100644 index 00000000000000..45656664101e43 --- /dev/null +++ b/ReactCommon/react/debug/react_native_expect.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +// No header guards since it is legitimately possible to include this file more +// than once with and without REACT_NATIVE_DEBUG. + +// react_native_expect is a non-fatal counterpart of react_native_assert. +// In debug builds, when an expectation fails, we log and move on. +// In release builds, react_native_expect is a noop. + +// react_native_expect is appropriate for recoverable conditions that can be +// violated by user mistake (e.g. JS code passes an unexpected prop value). +// To enforce invariants that are internal to React Native, consider +// react_native_assert (or a stronger mechanism). +// Calling react_native_expect does NOT, by itself, guarantee that the user +// will see a helpful diagnostic (beyond a low level log). That concern is the +// caller's responsibility. + +#include "flags.h" + +#undef react_native_expect + +#ifndef REACT_NATIVE_DEBUG + +#define react_native_expect(e) ((void)0) + +#else // REACT_NATIVE_DEBUG + +#include +#include + +#define react_native_expect(cond) \ + if (!(cond)) { \ + LOG(ERROR) << "react_native_expect failure: " << #cond; \ + } + +#endif // REACT_NATIVE_DEBUG diff --git a/ReactCommon/react/renderer/attributedstring/conversions.h b/ReactCommon/react/renderer/attributedstring/conversions.h index f585794c678594..6e987b3aa91977 100644 --- a/ReactCommon/react/renderer/attributedstring/conversions.h +++ b/ReactCommon/react/renderer/attributedstring/conversions.h @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include @@ -60,7 +60,7 @@ inline std::string toString(const DynamicTypeRamp &dynamicTypeRamp) { } LOG(ERROR) << "Unsupported DynamicTypeRamp value"; - react_native_assert(false); + react_native_expect(false); // Sane default in case of parsing errors return "body"; @@ -70,7 +70,7 @@ inline void fromRawValue( const PropsParserContext &context, const RawValue &value, DynamicTypeRamp &result) { - react_native_assert(value.hasType()); + react_native_expect(value.hasType()); if (value.hasType()) { auto string = (std::string)value; if (string == "caption2") { @@ -98,14 +98,14 @@ inline void fromRawValue( } else { // sane default LOG(ERROR) << "Unsupported DynamicTypeRamp value: " << string; - react_native_assert(false); + react_native_expect(false); result = DynamicTypeRamp::Body; } return; } LOG(ERROR) << "Unsupported DynamicTypeRamp type"; - react_native_assert(false); + react_native_expect(false); // Sane default in case of parsing errors result = DynamicTypeRamp::Body; @@ -124,7 +124,7 @@ inline std::string toString(const EllipsizeMode &ellipsisMode) { } LOG(ERROR) << "Unsupported EllipsizeMode value"; - react_native_assert(false); + react_native_expect(false); // Sane default in case of parsing errors return "tail"; @@ -134,7 +134,7 @@ inline void fromRawValue( const PropsParserContext &context, const RawValue &value, EllipsizeMode &result) { - react_native_assert(value.hasType()); + react_native_expect(value.hasType()); if (value.hasType()) { auto string = (std::string)value; if (string == "clip") { @@ -148,14 +148,14 @@ inline void fromRawValue( } else { // sane default LOG(ERROR) << "Unsupported EllipsizeMode value: " << string; - react_native_assert(false); + react_native_expect(false); result = EllipsizeMode::Tail; } return; } LOG(ERROR) << "Unsupported EllipsizeMode type"; - react_native_assert(false); + react_native_expect(false); // Sane default in case of parsing errors result = EllipsizeMode::Tail; @@ -172,7 +172,7 @@ inline std::string toString(const TextBreakStrategy &textBreakStrategy) { } LOG(ERROR) << "Unsupported TextBreakStrategy value"; - react_native_assert(false); + react_native_expect(false); return "highQuality"; } @@ -180,7 +180,7 @@ inline void fromRawValue( const PropsParserContext &context, const RawValue &value, TextBreakStrategy &result) { - react_native_assert(value.hasType()); + react_native_expect(value.hasType()); if (value.hasType()) { auto string = (std::string)value; if (string == "simple") { @@ -192,14 +192,14 @@ inline void fromRawValue( } else { // sane default LOG(ERROR) << "Unsupported TextBreakStrategy value: " << string; - react_native_assert(false); + react_native_expect(false); result = TextBreakStrategy::HighQuality; } return; } LOG(ERROR) << "Unsupported TextBreakStrategy type"; - react_native_assert(false); + react_native_expect(false); result = TextBreakStrategy::HighQuality; } @@ -207,7 +207,7 @@ inline void fromRawValue( const PropsParserContext &context, const RawValue &value, FontWeight &result) { - react_native_assert(value.hasType()); + react_native_expect(value.hasType()); if (value.hasType()) { auto string = (std::string)value; if (string == "normal") { @@ -236,7 +236,7 @@ inline void fromRawValue( result = FontWeight::Weight900; } else { LOG(ERROR) << "Unsupported FontWeight value: " << string; - react_native_assert(false); + react_native_expect(false); // sane default for prod result = FontWeight::Regular; } @@ -244,7 +244,7 @@ inline void fromRawValue( } LOG(ERROR) << "Unsupported FontWeight type"; - react_native_assert(false); + react_native_expect(false); result = FontWeight::Regular; } @@ -256,7 +256,7 @@ inline void fromRawValue( const PropsParserContext &context, const RawValue &value, FontStyle &result) { - react_native_assert(value.hasType()); + react_native_expect(value.hasType()); if (value.hasType()) { auto string = (std::string)value; if (string == "normal") { @@ -267,7 +267,7 @@ inline void fromRawValue( result = FontStyle::Oblique; } else { LOG(ERROR) << "Unsupported FontStyle value: " << string; - react_native_assert(false); + react_native_expect(false); // sane default for prod result = FontStyle::Normal; } @@ -275,7 +275,7 @@ inline void fromRawValue( } LOG(ERROR) << "Unsupported FontStyle type"; - react_native_assert(false); + react_native_expect(false); // sane default for prod result = FontStyle::Normal; } @@ -291,7 +291,7 @@ inline std::string toString(const FontStyle &fontStyle) { } LOG(ERROR) << "Unsupported FontStyle value"; - react_native_assert(false); + react_native_expect(false); // sane default for prod return "normal"; } @@ -300,7 +300,7 @@ inline void fromRawValue( const PropsParserContext &context, const RawValue &value, FontVariant &result) { - react_native_assert(value.hasType>()); + react_native_expect(value.hasType>()); result = FontVariant::Default; if (value.hasType>()) { auto items = std::vector{value}; @@ -318,7 +318,7 @@ inline void fromRawValue( (FontVariant)((int)result | (int)FontVariant::ProportionalNums); } else { LOG(ERROR) << "Unsupported FontVariant value: " << item; - react_native_assert(false); + react_native_expect(false); } continue; } @@ -357,7 +357,7 @@ inline void fromRawValue( const PropsParserContext &context, const RawValue &value, TextTransform &result) { - react_native_assert(value.hasType()); + react_native_expect(value.hasType()); if (value.hasType()) { auto string = (std::string)value; if (string == "none") { @@ -372,7 +372,7 @@ inline void fromRawValue( result = TextTransform::Unset; } else { LOG(ERROR) << "Unsupported TextTransform value: " << string; - react_native_assert(false); + react_native_expect(false); // sane default for prod result = TextTransform::None; } @@ -380,7 +380,7 @@ inline void fromRawValue( } LOG(ERROR) << "Unsupported TextTransform type"; - react_native_assert(false); + react_native_expect(false); // sane default for prod result = TextTransform::None; } @@ -400,7 +400,7 @@ inline std::string toString(const TextTransform &textTransform) { } LOG(ERROR) << "Unsupported TextTransform value"; - react_native_assert(false); + react_native_expect(false); // sane default for prod return "none"; } @@ -409,7 +409,7 @@ inline void fromRawValue( const PropsParserContext &context, const RawValue &value, TextAlignment &result) { - react_native_assert(value.hasType()); + react_native_expect(value.hasType()); if (value.hasType()) { auto string = (std::string)value; if (string == "auto") { @@ -424,7 +424,7 @@ inline void fromRawValue( result = TextAlignment::Justified; } else { LOG(ERROR) << "Unsupported TextAlignment value: " << string; - react_native_assert(false); + react_native_expect(false); // sane default for prod result = TextAlignment::Natural; } @@ -459,7 +459,7 @@ inline void fromRawValue( const PropsParserContext &context, const RawValue &value, WritingDirection &result) { - react_native_assert(value.hasType()); + react_native_expect(value.hasType()); if (value.hasType()) { auto string = (std::string)value; if (string == "natural" || string == "auto") { @@ -470,7 +470,7 @@ inline void fromRawValue( result = WritingDirection::RightToLeft; } else { LOG(ERROR) << "Unsupported WritingDirection value: " << string; - react_native_assert(false); + react_native_expect(false); // sane default for prod result = WritingDirection::Natural; } @@ -501,7 +501,7 @@ inline void fromRawValue( const PropsParserContext &context, const RawValue &value, LineBreakStrategy &result) { - react_native_assert(value.hasType()); + react_native_expect(value.hasType()); if (value.hasType()) { auto string = (std::string)value; if (string == "none") { @@ -514,7 +514,7 @@ inline void fromRawValue( result = LineBreakStrategy::Standard; } else { LOG(ERROR) << "Unsupported LineBreakStrategy value: " << string; - react_native_assert(false); + react_native_expect(false); // sane default for prod result = LineBreakStrategy::None; } @@ -547,7 +547,7 @@ inline void fromRawValue( const PropsParserContext &context, const RawValue &value, TextDecorationLineType &result) { - react_native_assert(value.hasType()); + react_native_expect(value.hasType()); if (value.hasType()) { auto string = (std::string)value; if (string == "none") { @@ -564,7 +564,7 @@ inline void fromRawValue( result = TextDecorationLineType::UnderlineStrikethrough; } else { LOG(ERROR) << "Unsupported TextDecorationLineType value: " << string; - react_native_assert(false); + react_native_expect(false); // sane default for prod result = TextDecorationLineType::None; } @@ -590,7 +590,7 @@ inline std::string toString( } LOG(ERROR) << "Unsupported TextDecorationLineType value"; - react_native_assert(false); + react_native_expect(false); // sane default for prod return "none"; } @@ -599,7 +599,7 @@ inline void fromRawValue( const PropsParserContext &context, const RawValue &value, TextDecorationStyle &result) { - react_native_assert(value.hasType()); + react_native_expect(value.hasType()); if (value.hasType()) { auto string = (std::string)value; if (string == "solid") { @@ -612,7 +612,7 @@ inline void fromRawValue( result = TextDecorationStyle::Dashed; } else { LOG(ERROR) << "Unsupported TextDecorationStyle value: " << string; - react_native_assert(false); + react_native_expect(false); // sane default for prod result = TextDecorationStyle::Solid; } @@ -637,7 +637,7 @@ inline std::string toString(const TextDecorationStyle &textDecorationStyle) { } LOG(ERROR) << "Unsupported TextDecorationStyle value"; - react_native_assert(false); + react_native_expect(false); // sane default for prod return "solid"; } @@ -703,7 +703,7 @@ inline std::string toString(const AccessibilityRole &accessibilityRole) { } LOG(ERROR) << "Unsupported AccessibilityRole value"; - react_native_assert(false); + react_native_expect(false); // sane default for prod return "none"; } @@ -712,7 +712,7 @@ inline void fromRawValue( const PropsParserContext &context, const RawValue &value, AccessibilityRole &result) { - react_native_assert(value.hasType()); + react_native_expect(value.hasType()); if (value.hasType()) { auto string = (std::string)value; if (string == "none") { @@ -773,7 +773,7 @@ inline void fromRawValue( result = AccessibilityRole::Toolbar; } else { LOG(ERROR) << "Unsupported AccessibilityRole value: " << string; - react_native_assert(false); + react_native_expect(false); // sane default for prod result = AccessibilityRole::None; } @@ -781,7 +781,7 @@ inline void fromRawValue( } LOG(ERROR) << "Unsupported AccessibilityRole type"; - react_native_assert(false); + react_native_expect(false); // sane default for prod result = AccessibilityRole::None; } @@ -797,7 +797,7 @@ inline std::string toString(const HyphenationFrequency &hyphenationFrequency) { } LOG(ERROR) << "Unsupported HyphenationFrequency value"; - react_native_assert(false); + react_native_expect(false); return "none"; } @@ -805,7 +805,7 @@ inline void fromRawValue( const PropsParserContext &context, const RawValue &value, HyphenationFrequency &result) { - react_native_assert(value.hasType()); + react_native_expect(value.hasType()); if (value.hasType()) { auto string = (std::string)value; if (string == "none") { @@ -817,14 +817,14 @@ inline void fromRawValue( } else { // sane default LOG(ERROR) << "Unsupported HyphenationFrequency value: " << string; - react_native_assert(false); + react_native_expect(false); result = HyphenationFrequency::None; } return; } LOG(ERROR) << "Unsupported HyphenationFrequency type"; - react_native_assert(false); + react_native_expect(false); result = HyphenationFrequency::None; } diff --git a/ReactCommon/react/renderer/components/image/conversions.h b/ReactCommon/react/renderer/components/image/conversions.h index 4b4e3d9ca9d31c..c466702c0a43c6 100644 --- a/ReactCommon/react/renderer/components/image/conversions.h +++ b/ReactCommon/react/renderer/components/image/conversions.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include @@ -97,7 +97,7 @@ inline void fromRawValue( const PropsParserContext &context, const RawValue &value, ImageResizeMode &result) { - react_native_assert(value.hasType()); + react_native_expect(value.hasType()); if (!value.hasType()) { LOG(ERROR) << "Unsupported ImageResizeMode type"; // "cover" is default in non-Fabric web and iOS @@ -118,7 +118,7 @@ inline void fromRawValue( result = ImageResizeMode::Repeat; } else { LOG(ERROR) << "Unsupported ImageResizeMode value: " << stringValue; - react_native_assert(false); + react_native_expect(false); // "cover" is default in non-Fabric web and iOS result = ImageResizeMode::Cover; } diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/react/renderer/components/iostextinput/propsConversions.h b/ReactCommon/react/renderer/components/textinput/iostextinput/react/renderer/components/iostextinput/propsConversions.h index 15dc0004596da0..d3cdf58f32fe1e 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/react/renderer/components/iostextinput/propsConversions.h +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/react/renderer/components/iostextinput/propsConversions.h @@ -7,6 +7,7 @@ #pragma once +#include #include #include #include @@ -158,16 +159,16 @@ inline void fromRawValue( result.end = pair.second; } else { LOG(ERROR) << "Unsupported Selection map key: " << pair.first; - react_native_assert(false); + react_native_expect(false); } } return; } - react_native_assert(value.hasType>()); + react_native_expect(value.hasType>()); if (value.hasType>()) { auto array = (std::vector)value; - react_native_assert(array.size() == 2); + react_native_expect(array.size() == 2); if (array.size() >= 2) { result = {array.at(0), array.at(1)}; } else { diff --git a/ReactCommon/react/renderer/components/view/conversions.h b/ReactCommon/react/renderer/components/view/conversions.h index a77ae6b2ab72c8..1775a28b681ca2 100644 --- a/ReactCommon/react/renderer/components/view/conversions.h +++ b/ReactCommon/react/renderer/components/view/conversions.h @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include @@ -169,7 +169,7 @@ inline void fromRawValue( const PropsParserContext &context, const RawValue &value, YGDirection &result) { - react_native_assert(value.hasType()); + react_native_expect(value.hasType()); auto stringValue = (std::string)value; if (stringValue == "inherit") { result = YGDirectionInherit; @@ -184,14 +184,14 @@ inline void fromRawValue( return; } LOG(FATAL) << "Could not parse YGDirection:" << stringValue; - react_native_assert(false); + react_native_expect(false); } inline void fromRawValue( const PropsParserContext &context, const RawValue &value, YGFlexDirection &result) { - react_native_assert(value.hasType()); + react_native_expect(value.hasType()); auto stringValue = (std::string)value; if (stringValue == "row") { result = YGFlexDirectionRow; @@ -210,14 +210,14 @@ inline void fromRawValue( return; } LOG(FATAL) << "Could not parse YGFlexDirection:" << stringValue; - react_native_assert(false); + react_native_expect(false); } inline void fromRawValue( const PropsParserContext &context, const RawValue &value, YGJustify &result) { - react_native_assert(value.hasType()); + react_native_expect(value.hasType()); auto stringValue = (std::string)value; if (stringValue == "flex-start") { result = YGJustifyFlexStart; @@ -244,14 +244,14 @@ inline void fromRawValue( return; } LOG(FATAL) << "Could not parse YGJustify:" << stringValue; - react_native_assert(false); + react_native_expect(false); } inline void fromRawValue( const PropsParserContext &context, const RawValue &value, YGAlign &result) { - react_native_assert(value.hasType()); + react_native_expect(value.hasType()); auto stringValue = (std::string)value; if (stringValue == "auto") { result = YGAlignAuto; @@ -286,14 +286,14 @@ inline void fromRawValue( return; } LOG(FATAL) << "Could not parse YGAlign:" << stringValue; - react_native_assert(false); + react_native_expect(false); } inline void fromRawValue( const PropsParserContext &context, const RawValue &value, YGPositionType &result) { - react_native_assert(value.hasType()); + react_native_expect(value.hasType()); auto stringValue = (std::string)value; if (stringValue == "static") { result = YGPositionTypeStatic; @@ -308,14 +308,14 @@ inline void fromRawValue( return; } LOG(FATAL) << "Could not parse YGPositionType:" << stringValue; - react_native_assert(false); + react_native_expect(false); } inline void fromRawValue( const PropsParserContext &context, const RawValue &value, YGWrap &result) { - react_native_assert(value.hasType()); + react_native_expect(value.hasType()); auto stringValue = (std::string)value; if (stringValue == "nowrap") { result = YGWrapNoWrap; @@ -330,14 +330,14 @@ inline void fromRawValue( return; } LOG(FATAL) << "Could not parse YGWrap:" << stringValue; - react_native_assert(false); + react_native_expect(false); } inline void fromRawValue( const PropsParserContext &context, const RawValue &value, YGOverflow &result) { - react_native_assert(value.hasType()); + react_native_expect(value.hasType()); auto stringValue = (std::string)value; if (stringValue == "visible") { result = YGOverflowVisible; @@ -352,14 +352,14 @@ inline void fromRawValue( return; } LOG(FATAL) << "Could not parse YGOverflow:" << stringValue; - react_native_assert(false); + react_native_expect(false); } inline void fromRawValue( const PropsParserContext &context, const RawValue &value, YGDisplay &result) { - react_native_assert(value.hasType()); + react_native_expect(value.hasType()); auto stringValue = (std::string)value; if (stringValue == "flex") { result = YGDisplayFlex; @@ -370,7 +370,7 @@ inline void fromRawValue( return; } LOG(FATAL) << "Could not parse YGDisplay:" << stringValue; - react_native_assert(false); + react_native_expect(false); } inline void fromRawValue( @@ -433,14 +433,14 @@ inline void fromRawValue( } } LOG(FATAL) << "Could not parse YGFloatOptional"; - react_native_assert(false); + react_native_expect(false); } inline Float toRadians(const RawValue &value) { if (value.hasType()) { return (Float)value; } - react_native_assert(value.hasType()); + react_native_expect(value.hasType()); auto stringValue = (std::string)value; char *suffixStart; double num = strtod( @@ -456,7 +456,7 @@ inline void fromRawValue( const PropsParserContext &context, const RawValue &value, Transform &result) { - react_native_assert(value.hasType>()); + react_native_expect(value.hasType>()); auto transformMatrix = Transform{}; auto configurations = static_cast>(value); @@ -474,9 +474,9 @@ inline void fromRawValue( auto ¶meters = pair->second; if (operation == "matrix") { - react_native_assert(parameters.hasType>()); + react_native_expect(parameters.hasType>()); auto numbers = (std::vector)parameters; - react_native_assert(numbers.size() == transformMatrix.matrix.size()); + react_native_expect(numbers.size() == transformMatrix.matrix.size()); auto i = 0; for (auto number : numbers) { transformMatrix.matrix[i++] = number; @@ -534,7 +534,7 @@ inline void fromRawValue( const PropsParserContext &context, const RawValue &value, PointerEventsMode &result) { - react_native_assert(value.hasType()); + react_native_expect(value.hasType()); auto stringValue = (std::string)value; if (stringValue == "auto") { result = PointerEventsMode::Auto; @@ -553,14 +553,14 @@ inline void fromRawValue( return; } LOG(FATAL) << "Could not parse PointerEventsMode:" << stringValue; - react_native_assert(false); + react_native_expect(false); } inline void fromRawValue( const PropsParserContext &context, const RawValue &value, BackfaceVisibility &result) { - react_native_assert(value.hasType()); + react_native_expect(value.hasType()); auto stringValue = (std::string)value; if (stringValue == "auto") { result = BackfaceVisibility::Auto; @@ -575,14 +575,14 @@ inline void fromRawValue( return; } LOG(FATAL) << "Could not parse BackfaceVisibility:" << stringValue; - react_native_assert(false); + react_native_expect(false); } inline void fromRawValue( const PropsParserContext &context, const RawValue &value, BorderCurve &result) { - react_native_assert(value.hasType()); + react_native_expect(value.hasType()); auto stringValue = (std::string)value; if (stringValue == "circular") { result = BorderCurve::Circular; @@ -593,14 +593,14 @@ inline void fromRawValue( return; } LOG(FATAL) << "Could not parse BorderCurve:" << stringValue; - react_native_assert(false); + react_native_expect(false); } inline void fromRawValue( const PropsParserContext &context, const RawValue &value, BorderStyle &result) { - react_native_assert(value.hasType()); + react_native_expect(value.hasType()); auto stringValue = (std::string)value; if (stringValue == "solid") { result = BorderStyle::Solid; @@ -615,7 +615,7 @@ inline void fromRawValue( return; } LOG(FATAL) << "Could not parse BorderStyle:" << stringValue; - react_native_assert(false); + react_native_expect(false); } inline std::string toString( diff --git a/ReactCommon/react/renderer/components/view/propsConversions.h b/ReactCommon/react/renderer/components/view/propsConversions.h index ad7cc2f3a3488c..8f2e30df977c37 100644 --- a/ReactCommon/react/renderer/components/view/propsConversions.h +++ b/ReactCommon/react/renderer/components/view/propsConversions.h @@ -724,13 +724,13 @@ static inline void fromRawValue( auto map = (butter::map)rawValue; auto typeIterator = map.find("type"); - react_native_assert( + react_native_expect( typeIterator != map.end() && typeIterator->second.hasType()); std::string type = (std::string)typeIterator->second; if (type == "ThemeAttrAndroid") { auto attrIterator = map.find("attribute"); - react_native_assert( + react_native_expect( attrIterator != map.end() && attrIterator->second.hasType()); @@ -761,7 +761,7 @@ static inline void fromRawValue( }; } else { LOG(ERROR) << "Unknown native drawable type: " << type; - react_native_assert(false); + react_native_expect(false); } } diff --git a/ReactCommon/react/renderer/graphics/conversions.h b/ReactCommon/react/renderer/graphics/conversions.h index 8ce4f341f79696..c142b8e57bf8c0 100644 --- a/ReactCommon/react/renderer/graphics/conversions.h +++ b/ReactCommon/react/renderer/graphics/conversions.h @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include @@ -41,7 +41,7 @@ inline void fromRawValue( } else if (value.hasType>()) { auto items = (std::vector)value; auto length = items.size(); - react_native_assert(length == 3 || length == 4); + react_native_expect(length == 3 || length == 4); colorComponents.red = items.at(0); colorComponents.green = items.at(1); colorComponents.blue = items.at(2); @@ -86,10 +86,10 @@ inline void fromRawValue( return; } - react_native_assert(value.hasType>()); + react_native_expect(value.hasType>()); if (value.hasType>()) { auto array = (std::vector)value; - react_native_assert(array.size() == 2); + react_native_expect(array.size() == 2); if (array.size() >= 2) { result = {array.at(0), array.at(1)}; } else { @@ -114,16 +114,16 @@ inline void fromRawValue( result.height = pair.second; } else { LOG(ERROR) << "Unsupported Size map key: " << pair.first; - react_native_assert(false); + react_native_expect(false); } } return; } - react_native_assert(value.hasType>()); + react_native_expect(value.hasType>()); if (value.hasType>()) { auto array = (std::vector)value; - react_native_assert(array.size() == 2); + react_native_expect(array.size() == 2); if (array.size() >= 2) { result = {array.at(0), array.at(1)}; } else { @@ -158,16 +158,16 @@ inline void fromRawValue( result.right = pair.second; } else { LOG(ERROR) << "Unsupported EdgeInsets map key: " << pair.first; - react_native_assert(false); + react_native_expect(false); } } return; } - react_native_assert(value.hasType>()); + react_native_expect(value.hasType>()); if (value.hasType>()) { auto array = (std::vector)value; - react_native_assert(array.size() == 4); + react_native_expect(array.size() == 4); if (array.size() >= 4) { result = {array.at(0), array.at(1), array.at(2), array.at(3)}; } else { @@ -202,16 +202,16 @@ inline void fromRawValue( result.bottomRight = pair.second; } else { LOG(ERROR) << "Unsupported CornerInsets map key: " << pair.first; - react_native_assert(false); + react_native_expect(false); } } return; } - react_native_assert(value.hasType>()); + react_native_expect(value.hasType>()); if (value.hasType>()) { auto array = (std::vector)value; - react_native_assert(array.size() == 4); + react_native_expect(array.size() == 4); if (array.size() >= 4) { result = {array.at(0), array.at(1), array.at(2), array.at(3)}; } else { diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock index 353aa4e5bdfd70..a9654da05f8da7 100644 --- a/packages/rn-tester/Podfile.lock +++ b/packages/rn-tester/Podfile.lock @@ -956,7 +956,7 @@ SPEC CHECKSUMS: CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54 FBLazyVector: d68947eddece25638eb0f642d1b957c90388afd1 - FBReactNativeSpec: c530d2df977f98d0d72ce4440c074cb73bff6289 + FBReactNativeSpec: dbfbd06ef9022b1a0198d14654ca3f4d8bbdea04 Flipper: 186214d97e5c24edd706f39faf933e5acaaa8644 Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c Flipper-DoubleConversion: 2dc99b02f658daf147069aad9dbd29d8feb06d30 @@ -967,7 +967,7 @@ SPEC CHECKSUMS: FlipperKit: b353b63cb4048a5747529412524407d6efa68336 fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b - hermes-engine: 44aadce06e4021379728f804a9503c4c5030c246 + hermes-engine: c6856cfc0143b20743bc478ca77fc086d74b7bfe libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1