diff --git a/ReactCommon/react/debug/react_native_assert.h b/ReactCommon/react/debug/react_native_assert.h index 1c421cc2ff3..d8034845328 100644 --- a/ReactCommon/react/debug/react_native_assert.h +++ b/ReactCommon/react/debug/react_native_assert.h @@ -43,6 +43,8 @@ void react_native_assert_fail( #else // __ANDROID__ +#include + #define react_native_assert(e) assert(e) #endif // platforms besides __ANDROID__ diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp index 4c970f87bcb..20ad36d99cd 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp @@ -25,6 +25,7 @@ #include #include +#include namespace facebook { namespace react { @@ -79,8 +80,8 @@ void LayoutAnimationDriver::animationMutationsForFrame( // All generated Update mutations must have an "old" and "new" // ShadowView. Checking for nonzero tag doesn't guarantee that the views // are valid/correct, just that something is there. - assert(updateMutation.oldChildShadowView.tag > 0); - assert(updateMutation.newChildShadowView.tag > 0); + react_native_assert(updateMutation.oldChildShadowView.tag > 0); + react_native_assert(updateMutation.newChildShadowView.tag > 0); mutationsList.push_back(updateMutation); PrintMutationInstruction("Animation Progress:", updateMutation); @@ -125,8 +126,8 @@ void LayoutAnimationDriver::animationMutationsForFrame( keyframe.viewPrev, finalMutationForKeyFrame.newChildShadowView, finalMutationForKeyFrame.index}; - assert(mutation.oldChildShadowView.tag > 0); - assert( + react_native_assert(mutation.oldChildShadowView.tag > 0); + react_native_assert( mutation.newChildShadowView.tag > 0 || finalMutationForKeyFrame.type == ShadowViewMutation::Remove || finalMutationForKeyFrame.type == ShadowViewMutation::Delete); @@ -142,8 +143,8 @@ void LayoutAnimationDriver::animationMutationsForFrame( keyframe.viewPrev, keyframe.viewEnd, -1}; - assert(mutation.oldChildShadowView.tag > 0); - assert(mutation.newChildShadowView.tag > 0); + react_native_assert(mutation.oldChildShadowView.tag > 0); + react_native_assert(mutation.newChildShadowView.tag > 0); mutationsList.push_back(mutation); } } diff --git a/ReactCommon/react/renderer/attributedstring/AttributedStringBox.cpp b/ReactCommon/react/renderer/attributedstring/AttributedStringBox.cpp index 83d10b365bf..a73131c9f54 100644 --- a/ReactCommon/react/renderer/attributedstring/AttributedStringBox.cpp +++ b/ReactCommon/react/renderer/attributedstring/AttributedStringBox.cpp @@ -7,6 +7,8 @@ #include "AttributedStringBox.h" +#include + namespace facebook { namespace react { @@ -37,14 +39,14 @@ AttributedStringBox::Mode AttributedStringBox::getMode() const { } AttributedString const &AttributedStringBox::getValue() const { - assert(mode_ == AttributedStringBox::Mode::Value); - assert(value_); + react_native_assert(mode_ == AttributedStringBox::Mode::Value); + react_native_assert(value_); return *value_; } std::shared_ptr AttributedStringBox::getOpaquePointer() const { - assert(mode_ == AttributedStringBox::Mode::OpaquePointer); - assert(opaquePointer_); + react_native_assert(mode_ == AttributedStringBox::Mode::OpaquePointer); + react_native_assert(opaquePointer_); return opaquePointer_; } diff --git a/ReactCommon/react/renderer/attributedstring/BUCK b/ReactCommon/react/renderer/attributedstring/BUCK index 60fff2fb8cb..a793db14709 100644 --- a/ReactCommon/react/renderer/attributedstring/BUCK +++ b/ReactCommon/react/renderer/attributedstring/BUCK @@ -55,11 +55,12 @@ rn_xplat_cxx_library( "//xplat/folly:headers_only", "//xplat/folly:memory", "//xplat/folly:molly", - react_native_xplat_target("react/utils:utils"), + react_native_xplat_target("react/debug:debug"), react_native_xplat_target("react/renderer/debug:debug"), react_native_xplat_target("react/renderer/core:core"), react_native_xplat_target("react/renderer/graphics:graphics"), react_native_xplat_target("react/renderer/mounting:mounting"), + react_native_xplat_target("react/utils:utils"), ], ) diff --git a/ReactCommon/react/renderer/attributedstring/conversions.h b/ReactCommon/react/renderer/attributedstring/conversions.h index a121a09028e..203cc367ec8 100644 --- a/ReactCommon/react/renderer/attributedstring/conversions.h +++ b/ReactCommon/react/renderer/attributedstring/conversions.h @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -175,7 +176,7 @@ inline std::string toString(const FontStyle &fontStyle) { } inline void fromRawValue(const RawValue &value, FontVariant &result) { - assert(value.hasType>()); + react_native_assert(value.hasType>()); result = FontVariant::Default; auto items = std::vector{value}; for (const auto &item : items) { diff --git a/ReactCommon/react/renderer/componentregistry/BUCK b/ReactCommon/react/renderer/componentregistry/BUCK index 03497b5bf3b..d92813b4216 100644 --- a/ReactCommon/react/renderer/componentregistry/BUCK +++ b/ReactCommon/react/renderer/componentregistry/BUCK @@ -55,6 +55,7 @@ rn_xplat_cxx_library( "//xplat/folly:molly", "//xplat/jsi:JSIDynamic", "//xplat/jsi:jsi", + react_native_xplat_target("react/debug:debug"), react_native_xplat_target("react/renderer/core:core"), react_native_xplat_target("react/renderer/debug:debug"), react_native_xplat_target("react/utils:utils"), diff --git a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp index 77f9fbcab89..cb149393dde 100644 --- a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp +++ b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp @@ -7,6 +7,7 @@ #include "ComponentDescriptorRegistry.h" +#include #include #include @@ -26,10 +27,10 @@ void ComponentDescriptorRegistry::add( {parameters_.eventDispatcher, parameters_.contextContainer, componentDescriptorProvider.flavor}); - assert( + react_native_assert( componentDescriptor->getComponentHandle() == componentDescriptorProvider.handle); - assert( + react_native_assert( componentDescriptor->getComponentName() == componentDescriptorProvider.name); diff --git a/ReactCommon/react/renderer/components/inputaccessory/BUCK b/ReactCommon/react/renderer/components/inputaccessory/BUCK index 583bccda339..f51b5e43fe7 100644 --- a/ReactCommon/react/renderer/components/inputaccessory/BUCK +++ b/ReactCommon/react/renderer/components/inputaccessory/BUCK @@ -41,6 +41,7 @@ rn_xplat_cxx_library( ], visibility = ["PUBLIC"], deps = [ + react_native_xplat_target("react/debug:debug"), react_native_xplat_target("react/renderer/core:core"), "//xplat/js/react-native-github:generated_components-rncore", ], diff --git a/ReactCommon/react/renderer/components/inputaccessory/InputAccessoryComponentDescriptor.h b/ReactCommon/react/renderer/components/inputaccessory/InputAccessoryComponentDescriptor.h index 99898b2395b..31294546054 100644 --- a/ReactCommon/react/renderer/components/inputaccessory/InputAccessoryComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/inputaccessory/InputAccessoryComponentDescriptor.h @@ -7,6 +7,7 @@ #pragma once +#include #include #include @@ -22,11 +23,12 @@ class InputAccessoryComponentDescriptor final using ConcreteComponentDescriptor::ConcreteComponentDescriptor; void adopt(UnsharedShadowNode shadowNode) const override { - assert(std::dynamic_pointer_cast(shadowNode)); + react_native_assert( + std::dynamic_pointer_cast(shadowNode)); auto concreteShadowNode = std::static_pointer_cast(shadowNode); - assert(std::dynamic_pointer_cast( + react_native_assert(std::dynamic_pointer_cast( concreteShadowNode)); auto layoutableShadowNode = std::static_pointer_cast(concreteShadowNode); diff --git a/ReactCommon/react/renderer/components/progressbar/BUCK b/ReactCommon/react/renderer/components/progressbar/BUCK index 69a4705d49f..68baa280887 100644 --- a/ReactCommon/react/renderer/components/progressbar/BUCK +++ b/ReactCommon/react/renderer/components/progressbar/BUCK @@ -85,6 +85,7 @@ rn_xplat_cxx_library( "//xplat/folly:memory", "//xplat/folly:molly", YOGA_CXX_TARGET, + react_native_xplat_target("react/debug:debug"), react_native_xplat_target("react/renderer/debug:debug"), react_native_xplat_target("react/renderer/core:core"), react_native_xplat_target("react/renderer/components/image:image"), diff --git a/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarComponentDescriptor.h b/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarComponentDescriptor.h index 4b3802666a1..f9581933390 100644 --- a/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarComponentDescriptor.h @@ -7,6 +7,7 @@ #pragma once +#include #include #include "AndroidProgressBarMeasurementsManager.h" #include "AndroidProgressBarShadowNode.h" @@ -30,7 +31,8 @@ class AndroidProgressBarComponentDescriptor final void adopt(UnsharedShadowNode shadowNode) const override { ConcreteComponentDescriptor::adopt(shadowNode); - assert(std::dynamic_pointer_cast(shadowNode)); + react_native_assert( + std::dynamic_pointer_cast(shadowNode)); auto androidProgressBarShadowNode = std::static_pointer_cast(shadowNode); diff --git a/ReactCommon/react/renderer/components/safeareaview/BUCK b/ReactCommon/react/renderer/components/safeareaview/BUCK index 82b24d26549..f39d4317f18 100644 --- a/ReactCommon/react/renderer/components/safeareaview/BUCK +++ b/ReactCommon/react/renderer/components/safeareaview/BUCK @@ -41,6 +41,7 @@ rn_xplat_cxx_library( ], visibility = ["PUBLIC"], deps = [ + react_native_xplat_target("react/debug:debug"), react_native_xplat_target("react/renderer/core:core"), "//xplat/js/react-native-github:generated_components-rncore", ], diff --git a/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewComponentDescriptor.h b/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewComponentDescriptor.h index 55f0ad4e9e1..f59665f6f9e 100644 --- a/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewComponentDescriptor.h @@ -7,6 +7,7 @@ #pragma once +#include #include #include @@ -20,11 +21,12 @@ class SafeAreaViewComponentDescriptor final : public ConcreteComponentDescriptor { using ConcreteComponentDescriptor::ConcreteComponentDescriptor; void adopt(UnsharedShadowNode shadowNode) const override { - assert(std::dynamic_pointer_cast(shadowNode)); + react_native_assert( + std::dynamic_pointer_cast(shadowNode)); auto safeAreaViewShadowNode = std::static_pointer_cast(shadowNode); - assert(std::dynamic_pointer_cast( + react_native_assert(std::dynamic_pointer_cast( safeAreaViewShadowNode)); auto layoutableShadowNode = std::static_pointer_cast( diff --git a/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchComponentDescriptor.h b/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchComponentDescriptor.h index 42a249017da..398fece92ae 100644 --- a/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchComponentDescriptor.h @@ -10,6 +10,7 @@ #include "AndroidSwitchMeasurementsManager.h" #include "AndroidSwitchShadowNode.h" +#include #include namespace facebook { @@ -30,7 +31,8 @@ class AndroidSwitchComponentDescriptor final void adopt(UnsharedShadowNode shadowNode) const override { ConcreteComponentDescriptor::adopt(shadowNode); - assert(std::dynamic_pointer_cast(shadowNode)); + react_native_assert( + std::dynamic_pointer_cast(shadowNode)); auto androidSwitchShadowNode = std::static_pointer_cast(shadowNode); diff --git a/ReactCommon/react/renderer/components/text/BUCK b/ReactCommon/react/renderer/components/text/BUCK index c30c31c63df..c3616745a14 100644 --- a/ReactCommon/react/renderer/components/text/BUCK +++ b/ReactCommon/react/renderer/components/text/BUCK @@ -61,7 +61,7 @@ rn_xplat_cxx_library( "//xplat/folly:memory", "//xplat/folly:molly", YOGA_CXX_TARGET, - react_native_xplat_target("react/utils:utils"), + react_native_xplat_target("react/debug:debug"), react_native_xplat_target("react/renderer/attributedstring:attributedstring"), react_native_xplat_target("react/renderer/core:core"), react_native_xplat_target("react/renderer/debug:debug"), @@ -71,6 +71,7 @@ rn_xplat_cxx_library( react_native_xplat_target("react/renderer/uimanager:uimanager"), react_native_xplat_target("react/renderer/mounting:mounting"), react_native_xplat_target("react/renderer/componentregistry:componentregistry"), + react_native_xplat_target("react/utils:utils"), ], ) diff --git a/ReactCommon/react/renderer/components/text/ParagraphComponentDescriptor.h b/ReactCommon/react/renderer/components/text/ParagraphComponentDescriptor.h index c60b1da6001..4f8ef1258f5 100644 --- a/ReactCommon/react/renderer/components/text/ParagraphComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/text/ParagraphComponentDescriptor.h @@ -10,6 +10,7 @@ #include "ParagraphShadowNode.h" #include +#include #include #include #include @@ -47,7 +48,8 @@ class ParagraphComponentDescriptor final void adopt(UnsharedShadowNode shadowNode) const override { ConcreteComponentDescriptor::adopt(shadowNode); - assert(std::dynamic_pointer_cast(shadowNode)); + react_native_assert( + std::dynamic_pointer_cast(shadowNode)); auto paragraphShadowNode = std::static_pointer_cast(shadowNode); diff --git a/ReactCommon/react/renderer/components/text/ParagraphShadowNode.cpp b/ReactCommon/react/renderer/components/text/ParagraphShadowNode.cpp index 0adadd10b18..6b32654d891 100644 --- a/ReactCommon/react/renderer/components/text/ParagraphShadowNode.cpp +++ b/ReactCommon/react/renderer/components/text/ParagraphShadowNode.cpp @@ -9,6 +9,7 @@ #include +#include #include #include #include @@ -102,8 +103,8 @@ void ParagraphShadowNode::updateStateIfNeeded(Content const &content) { auto &state = getStateData(); - assert(textLayoutManager_); - assert( + react_native_assert(textLayoutManager_); + react_native_assert( (!state.layoutManager || state.layoutManager == textLayoutManager_) && "`StateData` refers to a different `TextLayoutManager`"); @@ -191,7 +192,8 @@ void ParagraphShadowNode::layout(LayoutContext layoutContext) { // only to keep it in memory for a while. auto paragraphOwningShadowNode = ShadowNode::Unshared{}; - assert(content.attachments.size() == measurement.attachments.size()); + react_native_assert( + content.attachments.size() == measurement.attachments.size()); for (auto i = 0; i < content.attachments.size(); i++) { auto &attachment = content.attachments.at(i); diff --git a/ReactCommon/react/renderer/components/textinput/BUCK b/ReactCommon/react/renderer/components/textinput/BUCK index 1ae5fec3cd1..76373d0d8e0 100644 --- a/ReactCommon/react/renderer/components/textinput/BUCK +++ b/ReactCommon/react/renderer/components/textinput/BUCK @@ -58,7 +58,7 @@ rn_xplat_cxx_library( "//xplat/folly:memory", "//xplat/folly:molly", YOGA_CXX_TARGET, - react_native_xplat_target("react/utils:utils"), + react_native_xplat_target("react/debug:debug"), react_native_xplat_target("react/renderer/attributedstring:attributedstring"), react_native_xplat_target("react/renderer/core:core"), react_native_xplat_target("react/renderer/debug:debug"), @@ -70,6 +70,7 @@ rn_xplat_cxx_library( react_native_xplat_target("react/renderer/uimanager:uimanager"), react_native_xplat_target("react/renderer/componentregistry:componentregistry"), react_native_xplat_target("react/renderer/imagemanager:imagemanager"), + react_native_xplat_target("react/utils:utils"), ], ) diff --git a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputComponentDescriptor.h b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputComponentDescriptor.h index 26abeff7b99..70bc8d2fec3 100644 --- a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputComponentDescriptor.h @@ -7,14 +7,17 @@ #pragma once -#include -#include #include "AndroidTextInputShadowNode.h" +#include + #include #include #include +#include +#include + namespace facebook { namespace react { @@ -86,7 +89,8 @@ class AndroidTextInputComponentDescriptor final protected: void adopt(UnsharedShadowNode shadowNode) const override { - assert(std::dynamic_pointer_cast(shadowNode)); + react_native_assert( + std::dynamic_pointer_cast(shadowNode)); auto textInputShadowNode = std::static_pointer_cast(shadowNode); diff --git a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputShadowNode.cpp b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputShadowNode.cpp index 6d3ad4e8308..750376eb2d9 100644 --- a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputShadowNode.cpp +++ b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputShadowNode.cpp @@ -8,6 +8,7 @@ #include "AndroidTextInputShadowNode.h" #include +#include #include #include #include @@ -118,8 +119,8 @@ void AndroidTextInputShadowNode::updateStateIfNeeded() { auto reactTreeAttributedString = getAttributedString(); auto const &state = getStateData(); - assert(textLayoutManager_); - assert( + react_native_assert(textLayoutManager_); + react_native_assert( (!state.layoutManager || state.layoutManager == textLayoutManager_) && "`StateData` refers to a different `TextLayoutManager`"); diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/BUCK b/ReactCommon/react/renderer/components/textinput/iostextinput/BUCK index f2ccdf1085b..cd0174c2f46 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/BUCK +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/BUCK @@ -58,7 +58,7 @@ rn_xplat_cxx_library( "//xplat/folly:memory", "//xplat/folly:molly", YOGA_CXX_TARGET, - react_native_xplat_target("react/utils:utils"), + react_native_xplat_target("react/debug:debug"), react_native_xplat_target("react/renderer/attributedstring:attributedstring"), react_native_xplat_target("react/renderer/core:core"), react_native_xplat_target("react/renderer/debug:debug"), @@ -70,6 +70,7 @@ rn_xplat_cxx_library( react_native_xplat_target("react/renderer/uimanager:uimanager"), react_native_xplat_target("react/renderer/componentregistry:componentregistry"), react_native_xplat_target("react/renderer/imagemanager:imagemanager"), + react_native_xplat_target("react/utils:utils"), ], ) diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputComponentDescriptor.h b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputComponentDescriptor.h index 55b4d8afa1b..39bbb524eb3 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputComponentDescriptor.h @@ -7,6 +7,7 @@ #pragma once +#include #include #include @@ -29,7 +30,8 @@ class TextInputComponentDescriptor final void adopt(UnsharedShadowNode shadowNode) const override { ConcreteComponentDescriptor::adopt(shadowNode); - assert(std::dynamic_pointer_cast(shadowNode)); + react_native_assert( + std::dynamic_pointer_cast(shadowNode)); auto concreteShadowNode = std::static_pointer_cast(shadowNode); diff --git a/ReactCommon/react/renderer/components/view/BUCK b/ReactCommon/react/renderer/components/view/BUCK index 2ffb578b7b4..9c79631f364 100644 --- a/ReactCommon/react/renderer/components/view/BUCK +++ b/ReactCommon/react/renderer/components/view/BUCK @@ -60,6 +60,7 @@ rn_xplat_cxx_library( "//xplat/folly:memory", "//xplat/folly:molly", YOGA_CXX_TARGET, + react_native_xplat_target("react/debug:debug"), react_native_xplat_target("react/renderer/core:core"), react_native_xplat_target("react/renderer/debug:debug"), react_native_xplat_target("react/renderer/graphics:graphics"), diff --git a/ReactCommon/react/renderer/components/view/ViewPropsInterpolation.h b/ReactCommon/react/renderer/components/view/ViewPropsInterpolation.h index 0470d696d51..a2ef22a7e4c 100644 --- a/ReactCommon/react/renderer/components/view/ViewPropsInterpolation.h +++ b/ReactCommon/react/renderer/components/view/ViewPropsInterpolation.h @@ -9,6 +9,8 @@ #include "ViewProps.h" +#include + namespace facebook { namespace react { @@ -29,7 +31,7 @@ static inline void interpolateViewProps( ViewProps *interpolatedProps = const_cast( dynamic_cast(interpolatedPropsShared.get())); - assert( + react_native_assert( oldViewProps != nullptr && newViewProps != nullptr && interpolatedProps != nullptr); diff --git a/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp b/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp index 3af58bd9926..f3bf618c95b 100644 --- a/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp +++ b/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp @@ -6,6 +6,7 @@ */ #include "YogaLayoutableShadowNode.h" +#include #include #include #include @@ -42,7 +43,8 @@ YogaLayoutableShadowNode::YogaLayoutableShadowNode( yogaNode_.setDirty(true); if (getTraits().check(ShadowNodeTraits::Trait::MeasurableYogaNode)) { - assert(getTraits().check(ShadowNodeTraits::Trait::LeafYogaNode)); + react_native_assert( + getTraits().check(ShadowNodeTraits::Trait::LeafYogaNode)); yogaNode_.setMeasureFunc( YogaLayoutableShadowNode::yogaNodeMeasureCallbackConnector); @@ -67,7 +69,7 @@ YogaLayoutableShadowNode::YogaLayoutableShadowNode( // dirty flag, measure function, and other properties being set originally in // the `YogaLayoutableShadowNode` constructor above. - assert( + react_native_assert( static_cast(sourceShadowNode) .yogaNode_.isDirty() == yogaNode_.isDirty() && "Yoga node must inherit dirty flag."); @@ -118,7 +120,8 @@ void YogaLayoutableShadowNode::enableMeasurement() { void YogaLayoutableShadowNode::appendYogaChild(ShadowNode const &childNode) { // The caller must check this before calling this method. - assert(!getTraits().check(ShadowNodeTraits::Trait::LeafYogaNode)); + react_native_assert( + !getTraits().check(ShadowNodeTraits::Trait::LeafYogaNode)); ensureYogaChildrenLookFine(); @@ -135,13 +138,14 @@ void YogaLayoutableShadowNode::adoptYogaChild(size_t index) { ensureYogaChildrenLookFine(); // The caller must check this before calling this method. - assert(!getTraits().check(ShadowNodeTraits::Trait::LeafYogaNode)); + react_native_assert( + !getTraits().check(ShadowNodeTraits::Trait::LeafYogaNode)); auto &children = getChildren(); // Overflow checks. - assert(children.size() > index); - assert(children.size() >= yogaNode_.getChildren().size()); + react_native_assert(children.size() > index); + react_native_assert(children.size() >= yogaNode_.getChildren().size()); auto &childNode = *children.at(index); @@ -151,13 +155,14 @@ void YogaLayoutableShadowNode::adoptYogaChild(size_t index) { // Note, the following (commented out) assert is conceptually valid but still // might produce false-positive signals because of the ABA problem (different // objects with non-interleaving life-times being allocated on the same - // address). assert(layoutableChildNode.yogaNode_.getOwner() != &yogaNode_); + // address). react_native_assert(layoutableChildNode.yogaNode_.getOwner() != + // &yogaNode_); if (layoutableChildNode.yogaNode_.getOwner() == nullptr) { // The child node is not owned. layoutableChildNode.yogaNode_.setOwner(&yogaNode_); // At this point the child yoga node must be already inserted by the caller. - // assert(layoutableChildNode.yogaNode_.isDirty()); + // react_native_assert(layoutableChildNode.yogaNode_.isDirty()); } else { // The child is owned by some other node, we need to clone that. auto clonedChildNode = childNode.clone({}); @@ -165,7 +170,8 @@ void YogaLayoutableShadowNode::adoptYogaChild(size_t index) { traitCast(*clonedChildNode); // The owner must be nullptr for a newly cloned node. - assert(layoutableClonedChildNode.yogaNode_.getOwner() == nullptr); + react_native_assert( + layoutableClonedChildNode.yogaNode_.getOwner() == nullptr); // Establishing ownership. layoutableClonedChildNode.yogaNode_.setOwner(&yogaNode_); @@ -201,7 +207,8 @@ void YogaLayoutableShadowNode::appendChild( // All children of a non-leaf `YogaLayoutableShadowNode` must be a // `YogaLayoutableShadowNode`s. - assert(traitCast(childNode.get())); + react_native_assert( + traitCast(childNode.get())); // Appending the Yoga node. appendYogaChild(*childNode); @@ -256,7 +263,7 @@ void YogaLayoutableShadowNode::updateYogaChildren() { } } - assert(getChildren().size() == yogaNode_.getChildren().size()); + react_native_assert(getChildren().size() == yogaNode_.getChildren().size()); yogaNode_.setDirty(!isClean); } @@ -338,18 +345,18 @@ void YogaLayoutableShadowNode::layoutTree( // The caller must ensure that layout constraints make sense. // Values cannot be NaN. - assert(!std::isnan(minimumSize.width)); - assert(!std::isnan(minimumSize.height)); - assert(!std::isnan(maximumSize.width)); - assert(!std::isnan(maximumSize.height)); + react_native_assert(!std::isnan(minimumSize.width)); + react_native_assert(!std::isnan(minimumSize.height)); + react_native_assert(!std::isnan(maximumSize.width)); + react_native_assert(!std::isnan(maximumSize.height)); // Values cannot be negative. - assert(minimumSize.width >= 0); - assert(minimumSize.height >= 0); - assert(maximumSize.width >= 0); - assert(maximumSize.height >= 0); + react_native_assert(minimumSize.width >= 0); + react_native_assert(minimumSize.height >= 0); + react_native_assert(maximumSize.width >= 0); + react_native_assert(maximumSize.height >= 0); // Mimimum size cannot be infinity. - assert(!std::isinf(minimumSize.width)); - assert(!std::isinf(minimumSize.height)); + react_native_assert(!std::isinf(minimumSize.width)); + react_native_assert(!std::isinf(minimumSize.height)); // Internally Yoga uses three different measurement modes controlling layout // constraints: `Undefined`, `Exactly`, and `AtMost`. These modes are an @@ -440,7 +447,7 @@ static EdgeInsets calculateOverflowInset( void YogaLayoutableShadowNode::layout(LayoutContext layoutContext) { // Reading data from a dirtied node does not make sense. - assert(!yogaNode_.isDirty()); + react_native_assert(!yogaNode_.isDirty()); auto contentFrame = Rect{}; @@ -449,17 +456,17 @@ void YogaLayoutableShadowNode::layout(LayoutContext layoutContext) { *static_cast(childYogaNode->getContext()); // Verifying that the Yoga node belongs to the ShadowNode. - assert(&childNode.yogaNode_ == childYogaNode); + react_native_assert(&childNode.yogaNode_ == childYogaNode); if (childYogaNode->getHasNewLayout()) { childYogaNode->setHasNewLayout(false); // Reading data from a dirtied node does not make sense. - assert(!childYogaNode->isDirty()); + react_native_assert(!childYogaNode->isDirty()); // We must copy layout metrics from Yoga node only once (when the parent // node exclusively ownes the child node). - assert(childYogaNode->getOwner() == &yogaNode_); + react_native_assert(childYogaNode->getOwner() == &yogaNode_); // We are about to mutate layout metrics of the node. childNode.ensureUnsealed(); @@ -731,7 +738,7 @@ void YogaLayoutableShadowNode::ensureYogaChildrenOwnersConsistency() const { if (!yogaChildren.empty()) { auto owner = yogaChildren.at(0)->getOwner(); for (auto const &child : yogaChildren) { - assert(child->getOwner() == owner); + react_native_assert(child->getOwner() == owner); } } #endif @@ -746,10 +753,10 @@ void YogaLayoutableShadowNode::ensureYogaChildrenLookFine() const { auto &yogaChildren = yogaNode_.getChildren(); for (auto const &yogaChild : yogaChildren) { - assert(yogaChild->getContext()); - assert(yogaChild->getChildren().size() < 16384); + react_native_assert(yogaChild->getContext()); + react_native_assert(yogaChild->getChildren().size() < 16384); if (!yogaChild->getChildren().empty()) { - assert(!yogaChild->hasMeasureFunc()); + react_native_assert(!yogaChild->hasMeasureFunc()); } } #endif @@ -766,16 +773,16 @@ void YogaLayoutableShadowNode::ensureYogaChildrenAlighment() const { auto &children = getChildren(); if (getTraits().check(ShadowNodeTraits::Trait::LeafYogaNode)) { - assert(yogaChildren.empty()); + react_native_assert(yogaChildren.empty()); return; } - assert(yogaChildren.size() == children.size()); + react_native_assert(yogaChildren.size() == children.size()); for (size_t i = 0; i < children.size(); i++) { auto &yogaChild = yogaChildren.at(i); auto &child = children.at(i); - assert( + react_native_assert( yogaChild->getContext() == traitCast(child.get())); } diff --git a/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.h b/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.h index 634c839df48..7fced8467c5 100644 --- a/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.h +++ b/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.h @@ -12,6 +12,7 @@ #include +#include #include #include #include @@ -185,10 +186,10 @@ inline YogaLayoutableShadowNode const & traitCast(ShadowNode const &shadowNode) { bool castable = shadowNode.getTraits().check(ShadowNodeTraits::Trait::YogaLayoutableKind); - assert( + react_native_assert( castable == (dynamic_cast(&shadowNode) != nullptr)); - assert(castable); + react_native_assert(castable); (void)castable; return static_cast(shadowNode); } @@ -201,7 +202,7 @@ traitCast(ShadowNode const *shadowNode) { } bool castable = shadowNode->getTraits().check( ShadowNodeTraits::Trait::YogaLayoutableKind); - assert( + react_native_assert( castable == (dynamic_cast(shadowNode) != nullptr)); if (!castable) { diff --git a/ReactCommon/react/renderer/components/view/conversions.h b/ReactCommon/react/renderer/components/view/conversions.h index 5e919762097..84ee48cfda0 100644 --- a/ReactCommon/react/renderer/components/view/conversions.h +++ b/ReactCommon/react/renderer/components/view/conversions.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -165,7 +166,7 @@ inline YGDirection yogaDirectionFromLayoutDirection(LayoutDirection direction) { } inline void fromRawValue(const RawValue &value, YGDirection &result) { - assert(value.hasType()); + react_native_assert(value.hasType()); auto stringValue = (std::string)value; if (stringValue == "inherit") { result = YGDirectionInherit; @@ -180,11 +181,11 @@ inline void fromRawValue(const RawValue &value, YGDirection &result) { return; } LOG(FATAL) << "Could not parse YGDirection:" << stringValue; - assert(false); + react_native_assert(false); } inline void fromRawValue(const RawValue &value, YGFlexDirection &result) { - assert(value.hasType()); + react_native_assert(value.hasType()); auto stringValue = (std::string)value; if (stringValue == "row") { result = YGFlexDirectionRow; @@ -203,11 +204,11 @@ inline void fromRawValue(const RawValue &value, YGFlexDirection &result) { return; } LOG(FATAL) << "Could not parse YGFlexDirection:" << stringValue; - assert(false); + react_native_assert(false); } inline void fromRawValue(const RawValue &value, YGJustify &result) { - assert(value.hasType()); + react_native_assert(value.hasType()); auto stringValue = (std::string)value; if (stringValue == "flex-start") { result = YGJustifyFlexStart; @@ -234,11 +235,11 @@ inline void fromRawValue(const RawValue &value, YGJustify &result) { return; } LOG(FATAL) << "Could not parse YGJustify:" << stringValue; - assert(false); + react_native_assert(false); } inline void fromRawValue(const RawValue &value, YGAlign &result) { - assert(value.hasType()); + react_native_assert(value.hasType()); auto stringValue = (std::string)value; if (stringValue == "auto") { result = YGAlignAuto; @@ -273,11 +274,11 @@ inline void fromRawValue(const RawValue &value, YGAlign &result) { return; } LOG(FATAL) << "Could not parse YGAlign:" << stringValue; - assert(false); + react_native_assert(false); } inline void fromRawValue(const RawValue &value, YGPositionType &result) { - assert(value.hasType()); + react_native_assert(value.hasType()); auto stringValue = (std::string)value; if (stringValue == "static") { result = YGPositionTypeStatic; @@ -292,11 +293,11 @@ inline void fromRawValue(const RawValue &value, YGPositionType &result) { return; } LOG(FATAL) << "Could not parse YGPositionType:" << stringValue; - assert(false); + react_native_assert(false); } inline void fromRawValue(const RawValue &value, YGWrap &result) { - assert(value.hasType()); + react_native_assert(value.hasType()); auto stringValue = (std::string)value; if (stringValue == "nowrap") { result = YGWrapNoWrap; @@ -311,11 +312,11 @@ inline void fromRawValue(const RawValue &value, YGWrap &result) { return; } LOG(FATAL) << "Could not parse YGWrap:" << stringValue; - assert(false); + react_native_assert(false); } inline void fromRawValue(const RawValue &value, YGOverflow &result) { - assert(value.hasType()); + react_native_assert(value.hasType()); auto stringValue = (std::string)value; if (stringValue == "visible") { result = YGOverflowVisible; @@ -330,11 +331,11 @@ inline void fromRawValue(const RawValue &value, YGOverflow &result) { return; } LOG(FATAL) << "Could not parse YGOverflow:" << stringValue; - assert(false); + react_native_assert(false); } inline void fromRawValue(const RawValue &value, YGDisplay &result) { - assert(value.hasType()); + react_native_assert(value.hasType()); auto stringValue = (std::string)value; if (stringValue == "flex") { result = YGDisplayFlex; @@ -345,7 +346,7 @@ inline void fromRawValue(const RawValue &value, YGDisplay &result) { return; } LOG(FATAL) << "Could not parse YGDisplay:" << stringValue; - assert(false); + react_native_assert(false); } inline void fromRawValue(const RawValue &value, YGStyle::ValueRepr &result) { @@ -384,14 +385,14 @@ inline void fromRawValue(const RawValue &value, YGFloatOptional &result) { } } LOG(FATAL) << "Could not parse YGFloatOptional"; - assert(false); + react_native_assert(false); } inline Float toRadians(const RawValue &value) { if (value.hasType()) { return (Float)value; } - assert(value.hasType()); + react_native_assert(value.hasType()); auto stringValue = (std::string)value; char *suffixStart; double num = strtod( @@ -404,7 +405,7 @@ inline Float toRadians(const RawValue &value) { } inline void fromRawValue(const RawValue &value, Transform &result) { - assert(value.hasType>()); + react_native_assert(value.hasType>()); auto transformMatrix = Transform{}; auto configurations = static_cast>(value); @@ -422,9 +423,9 @@ inline void fromRawValue(const RawValue &value, Transform &result) { auto ¶meters = pair->second; if (operation == "matrix") { - assert(parameters.hasType>()); + react_native_assert(parameters.hasType>()); auto numbers = (std::vector)parameters; - assert(numbers.size() == transformMatrix.matrix.size()); + react_native_assert(numbers.size() == transformMatrix.matrix.size()); auto i = 0; for (auto number : numbers) { transformMatrix.matrix[i++] = number; @@ -479,7 +480,7 @@ inline void fromRawValue(const RawValue &value, Transform &result) { } inline void fromRawValue(const RawValue &value, PointerEventsMode &result) { - assert(value.hasType()); + react_native_assert(value.hasType()); auto stringValue = (std::string)value; if (stringValue == "auto") { result = PointerEventsMode::Auto; @@ -498,11 +499,11 @@ inline void fromRawValue(const RawValue &value, PointerEventsMode &result) { return; } LOG(FATAL) << "Could not parse PointerEventsMode:" << stringValue; - assert(false); + react_native_assert(false); } inline void fromRawValue(const RawValue &value, BackfaceVisibility &result) { - assert(value.hasType()); + react_native_assert(value.hasType()); auto stringValue = (std::string)value; if (stringValue == "auto") { result = BackfaceVisibility::Auto; @@ -517,11 +518,11 @@ inline void fromRawValue(const RawValue &value, BackfaceVisibility &result) { return; } LOG(FATAL) << "Could not parse BackfaceVisibility:" << stringValue; - assert(false); + react_native_assert(false); } inline void fromRawValue(const RawValue &value, BorderStyle &result) { - assert(value.hasType()); + react_native_assert(value.hasType()); auto stringValue = (std::string)value; if (stringValue == "solid") { result = BorderStyle::Solid; @@ -536,7 +537,7 @@ inline void fromRawValue(const RawValue &value, BorderStyle &result) { return; } LOG(FATAL) << "Could not parse BorderStyle:" << stringValue; - assert(false); + react_native_assert(false); } inline std::string toString( diff --git a/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h b/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h index 18217e60e1e..6aa191263f0 100644 --- a/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h +++ b/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -63,7 +64,8 @@ class ConcreteComponentDescriptor : public ComponentDescriptor { ShadowNode::Shared createShadowNode( const ShadowNodeFragment &fragment, ShadowNodeFamily::Shared const &family) const override { - assert(std::dynamic_pointer_cast(fragment.props)); + react_native_assert( + std::dynamic_pointer_cast(fragment.props)); auto shadowNode = std::make_shared(fragment, family, getTraits()); @@ -76,7 +78,7 @@ class ConcreteComponentDescriptor : public ComponentDescriptor { UnsharedShadowNode cloneShadowNode( const ShadowNode &sourceShadowNode, const ShadowNodeFragment &fragment) const override { - assert( + react_native_assert( dynamic_cast(&sourceShadowNode) && "Provided `sourceShadowNode` has an incompatible type."); @@ -89,7 +91,7 @@ class ConcreteComponentDescriptor : public ComponentDescriptor { void appendChild( const ShadowNode::Shared &parentShadowNode, const ShadowNode::Shared &childShadowNode) const override { - assert( + react_native_assert( dynamic_cast(parentShadowNode.get()) && "Provided `parentShadowNode` has an incompatible type."); @@ -103,7 +105,7 @@ class ConcreteComponentDescriptor : public ComponentDescriptor { virtual SharedProps cloneProps( const SharedProps &props, const RawProps &rawProps) const override { - assert( + react_native_assert( !props || dynamic_cast(props.get()) && "Provided `props` has an incompatible type."); @@ -161,7 +163,7 @@ class ConcreteComponentDescriptor : public ComponentDescriptor { return nullptr; } - assert(data && "Provided `data` is nullptr."); + react_native_assert(data && "Provided `data` is nullptr."); return std::make_shared( std::static_pointer_cast(data), @@ -183,7 +185,8 @@ class ConcreteComponentDescriptor : public ComponentDescriptor { protected: virtual void adopt(UnsharedShadowNode shadowNode) const { // Default implementation does nothing. - assert(shadowNode->getComponentHandle() == getComponentHandle()); + react_native_assert( + shadowNode->getComponentHandle() == getComponentHandle()); } }; diff --git a/ReactCommon/react/renderer/core/ConcreteShadowNode.h b/ReactCommon/react/renderer/core/ConcreteShadowNode.h index bafe8e23946..6a3ffb80f5b 100644 --- a/ReactCommon/react/renderer/core/ConcreteShadowNode.h +++ b/ReactCommon/react/renderer/core/ConcreteShadowNode.h @@ -7,6 +7,7 @@ #pragma once +#include #include #include #include @@ -92,8 +93,9 @@ class ConcreteShadowNode : public BaseShadowNodeT { * Thread-safe after the node is sealed. */ ConcreteProps const &getConcreteProps() const { - assert(BaseShadowNodeT::props_ && "Props must not be `nullptr`."); - assert( + react_native_assert( + BaseShadowNodeT::props_ && "Props must not be `nullptr`."); + react_native_assert( std::dynamic_pointer_cast(props_) && "Props must be an instance of ConcreteProps class."); return static_cast(*props_); @@ -104,7 +106,7 @@ class ConcreteShadowNode : public BaseShadowNodeT { * Thread-safe after the node is sealed. */ ConcreteEventEmitter const &getConcreteEventEmitter() const { - assert( + react_native_assert( std::dynamic_pointer_cast( BaseShadowNodeT::getEventEmitter()) && "EventEmitter must be an instance of ConcreteEventEmitter class."); @@ -117,8 +119,8 @@ class ConcreteShadowNode : public BaseShadowNodeT { * Thread-safe after the node is sealed. */ ConcreteStateData const &getStateData() const { - assert(state_ && "State must not be `nullptr`."); - assert( + react_native_assert(state_ && "State must not be `nullptr`."); + react_native_assert( std::dynamic_pointer_cast(state_) && "State must be an instance of ConcreteState class."); return static_cast(state_.get())->getData(); diff --git a/ReactCommon/react/renderer/core/ConcreteState.h b/ReactCommon/react/renderer/core/ConcreteState.h index c3ce51fedca..f4ebd03b35e 100644 --- a/ReactCommon/react/renderer/core/ConcreteState.h +++ b/ReactCommon/react/renderer/core/ConcreteState.h @@ -10,6 +10,7 @@ #include #include +#include #include namespace facebook { @@ -89,7 +90,7 @@ class ConcreteState : public State { auto stateUpdate = StateUpdate{ family, [=](StateData::Shared const &oldData) -> StateData::Shared { - assert(oldData); + react_native_assert(oldData); return callback(*std::static_pointer_cast(oldData)); }}; diff --git a/ReactCommon/react/renderer/core/EventTarget.cpp b/ReactCommon/react/renderer/core/EventTarget.cpp index 01a5a77bd50..b8d84547016 100644 --- a/ReactCommon/react/renderer/core/EventTarget.cpp +++ b/ReactCommon/react/renderer/core/EventTarget.cpp @@ -7,6 +7,8 @@ #include "EventTarget.h" +#include + namespace facebook { namespace react { @@ -38,8 +40,8 @@ void EventTarget::retain(jsi::Runtime &runtime) const { // particular implementation of JSI was able to detect this inconsistency and // dealt with it, but some JSI implementation may not support this feature and // that case will lead to a crash in those environments. - assert(!strongInstanceHandle_.isNull()); - assert(!strongInstanceHandle_.isUndefined()); + react_native_assert(!strongInstanceHandle_.isNull()); + react_native_assert(!strongInstanceHandle_.isUndefined()); } void EventTarget::release(jsi::Runtime &runtime) const { diff --git a/ReactCommon/react/renderer/core/LayoutableShadowNode.h b/ReactCommon/react/renderer/core/LayoutableShadowNode.h index b30f1d21242..3ffb162198e 100644 --- a/ReactCommon/react/renderer/core/LayoutableShadowNode.h +++ b/ReactCommon/react/renderer/core/LayoutableShadowNode.h @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -169,10 +170,10 @@ inline LayoutableShadowNode const &traitCast( ShadowNode const &shadowNode) { bool castable = shadowNode.getTraits().check(ShadowNodeTraits::Trait::LayoutableKind); - assert( + react_native_assert( castable == (dynamic_cast(&shadowNode) != nullptr)); - assert(castable); + react_native_assert(castable); (void)castable; return static_cast(shadowNode); } @@ -185,7 +186,7 @@ inline LayoutableShadowNode const *traitCast( } bool castable = shadowNode->getTraits().check(ShadowNodeTraits::Trait::LayoutableKind); - assert( + react_native_assert( castable == (dynamic_cast(shadowNode) != nullptr)); if (!castable) { diff --git a/ReactCommon/react/renderer/core/RawProps.cpp b/ReactCommon/react/renderer/core/RawProps.cpp index fd55f40c0c5..f48dffa2cd7 100644 --- a/ReactCommon/react/renderer/core/RawProps.cpp +++ b/ReactCommon/react/renderer/core/RawProps.cpp @@ -7,6 +7,7 @@ #include "RawProps.h" +#include #include namespace facebook { @@ -47,7 +48,7 @@ RawProps::RawProps(folly::dynamic const &dynamic) noexcept { } void RawProps::parse(RawPropsParser const &parser) const noexcept { - assert(parser_ == nullptr && "A parser was already assigned."); + react_native_assert(parser_ == nullptr && "A parser was already assigned."); parser_ = &parser; parser.preparse(*this); } @@ -84,7 +85,7 @@ const RawValue *RawProps::at( char const *name, char const *prefix, char const *suffix) const noexcept { - assert( + react_native_assert( parser_ && "The object is not parsed. `parse` must be called before `at`."); return parser_->at(*this, RawPropsKey{prefix, name, suffix}); diff --git a/ReactCommon/react/renderer/core/RawPropsKey.cpp b/ReactCommon/react/renderer/core/RawPropsKey.cpp index 2bc87ea6a43..87af35384c3 100644 --- a/ReactCommon/react/renderer/core/RawPropsKey.cpp +++ b/ReactCommon/react/renderer/core/RawPropsKey.cpp @@ -10,6 +10,7 @@ #include #include +#include #include namespace facebook { @@ -37,14 +38,14 @@ void RawPropsKey::render(char *buffer, RawPropsPropNameLength *length) std::memcpy(buffer + *length, suffix, suffixLength); *length += suffixLength; } - assert(*length < kPropNameLengthHardCap); + react_native_assert(*length < kPropNameLengthHardCap); } RawPropsKey::operator std::string() const noexcept { char buffer[kPropNameLengthHardCap]; RawPropsPropNameLength length = 0; render(buffer, &length); - assert(length < kPropNameLengthHardCap); + react_native_assert(length < kPropNameLengthHardCap); return std::string{buffer, length}; } diff --git a/ReactCommon/react/renderer/core/RawPropsKeyMap.cpp b/ReactCommon/react/renderer/core/RawPropsKeyMap.cpp index 889cdbead36..a06f5c497aa 100644 --- a/ReactCommon/react/renderer/core/RawPropsKeyMap.cpp +++ b/ReactCommon/react/renderer/core/RawPropsKeyMap.cpp @@ -7,6 +7,8 @@ #include "RawPropsKeyMap.h" +#include + #include #include #include @@ -79,12 +81,12 @@ void RawPropsKeyMap::reindex() noexcept { RawPropsValueIndex RawPropsKeyMap::at( char const *name, RawPropsPropNameLength length) noexcept { - assert(length > 0); - assert(length < kPropNameLengthHardCap); + react_native_assert(length > 0); + react_native_assert(length < kPropNameLengthHardCap); // 1. Find the bucket. auto lower = int{buckets_[length - 1]}; auto upper = int{buckets_[length]} - 1; - assert(lower - 1 <= upper); + react_native_assert(lower - 1 <= upper); // 2. Binary search in the bucket. while (lower <= upper) { diff --git a/ReactCommon/react/renderer/core/RawValue.h b/ReactCommon/react/renderer/core/RawValue.h index 75c2e9527a7..1e0881e5bac 100644 --- a/ReactCommon/react/renderer/core/RawValue.h +++ b/ReactCommon/react/renderer/core/RawValue.h @@ -12,6 +12,8 @@ #include #include +#include + namespace facebook { namespace react { @@ -189,7 +191,7 @@ class RawValue { } for (const auto &item : dynamic.items()) { - assert(item.first.isString()); + react_native_assert(item.first.isString()); if (!checkValueType(item.second, (T *)nullptr)) { return false; } @@ -242,7 +244,7 @@ class RawValue { static std::vector castValue( const folly::dynamic &dynamic, std::vector *type) noexcept { - assert(dynamic.isArray()); + react_native_assert(dynamic.isArray()); auto result = std::vector{}; result.reserve(dynamic.size()); for (const auto &item : dynamic) { @@ -255,7 +257,7 @@ class RawValue { static std::vector> castValue( const folly::dynamic &dynamic, std::vector> *type) noexcept { - assert(dynamic.isArray()); + react_native_assert(dynamic.isArray()); auto result = std::vector>{}; result.reserve(dynamic.size()); for (const auto &item : dynamic) { @@ -268,10 +270,10 @@ class RawValue { static better::map castValue( const folly::dynamic &dynamic, better::map *type) noexcept { - assert(dynamic.isObject()); + react_native_assert(dynamic.isObject()); auto result = better::map{}; for (const auto &item : dynamic.items()) { - assert(item.first.isString()); + react_native_assert(item.first.isString()); result[item.first.getString()] = castValue(item.second, (T *)nullptr); } return result; diff --git a/ReactCommon/react/renderer/core/Sealable.cpp b/ReactCommon/react/renderer/core/Sealable.cpp index 5bc35e6908b..d2e6fc46432 100644 --- a/ReactCommon/react/renderer/core/Sealable.cpp +++ b/ReactCommon/react/renderer/core/Sealable.cpp @@ -7,7 +7,7 @@ #include "Sealable.h" -#include +#include namespace facebook { namespace react { @@ -56,7 +56,7 @@ bool Sealable::getSealed() const { } void Sealable::ensureUnsealed() const { - assert(!sealed_ && "Attempt to mutate a sealed object."); + react_native_assert(!sealed_ && "Attempt to mutate a sealed object."); } #endif diff --git a/ReactCommon/react/renderer/core/ShadowNode.cpp b/ReactCommon/react/renderer/core/ShadowNode.cpp index 3fb034f3b22..60f63ff3e72 100644 --- a/ReactCommon/react/renderer/core/ShadowNode.cpp +++ b/ReactCommon/react/renderer/core/ShadowNode.cpp @@ -11,6 +11,7 @@ #include +#include #include #include #include @@ -74,8 +75,8 @@ ShadowNode::ShadowNode( orderIndex_(0), family_(family), traits_(traits) { - assert(props_); - assert(children_); + react_native_assert(props_); + react_native_assert(children_); traits_.set(ShadowNodeTraits::Trait::ChildrenAreShared); @@ -104,8 +105,8 @@ ShadowNode::ShadowNode( family_(sourceShadowNode.family_), traits_(sourceShadowNode.traits_) { - assert(props_); - assert(children_); + react_native_assert(props_); + react_native_assert(children_); traits_.set(ShadowNodeTraits::Trait::ChildrenAreShared); @@ -227,7 +228,7 @@ void ShadowNode::replaceChild( } } - assert(false && "Child to replace was not found."); + react_native_assert(false && "Child to replace was not found."); } void ShadowNode::cloneChildrenIfShared() { @@ -267,7 +268,7 @@ ShadowNode::Unshared ShadowNode::cloneTree( auto newShadowNode = callback(*oldShadowNode); - assert( + react_native_assert( newShadowNode && "`callback` returned `nullptr` which is not allowed value."); @@ -278,7 +279,8 @@ ShadowNode::Unshared ShadowNode::cloneTree( auto childIndex = it->second; auto children = parentNode.getChildren(); - assert(ShadowNode::sameFamily(*children.at(childIndex), *childNode)); + react_native_assert( + ShadowNode::sameFamily(*children.at(childIndex), *childNode)); children[childIndex] = childNode; childNode = parentNode.clone({ diff --git a/ReactCommon/react/renderer/core/ShadowNodeFamily.cpp b/ReactCommon/react/renderer/core/ShadowNodeFamily.cpp index c76b3ab8d3a..f4c06442556 100644 --- a/ReactCommon/react/renderer/core/ShadowNodeFamily.cpp +++ b/ReactCommon/react/renderer/core/ShadowNodeFamily.cpp @@ -8,6 +8,7 @@ #include "ShadowNodeFamily.h" #include "ShadowNode.h" +#include #include #include @@ -29,7 +30,7 @@ ShadowNodeFamily::ShadowNodeFamily( componentName_(componentDescriptor.getComponentName()) {} void ShadowNodeFamily::setParent(ShadowNodeFamily::Shared const &parent) const { - assert(parent_.lock() == nullptr || parent_.lock() == parent); + react_native_assert(parent_.lock() == nullptr || parent_.lock() == parent); if (hasParent_) { return; } diff --git a/ReactCommon/react/renderer/graphics/BUCK b/ReactCommon/react/renderer/graphics/BUCK index ee43b891aca..aa3d8156388 100644 --- a/ReactCommon/react/renderer/graphics/BUCK +++ b/ReactCommon/react/renderer/graphics/BUCK @@ -96,6 +96,7 @@ rn_xplat_cxx_library( tests = [":tests"], visibility = ["PUBLIC"], deps = [ + react_native_xplat_target("react/debug:debug"), react_native_xplat_target("better:better"), "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", diff --git a/ReactCommon/react/renderer/graphics/Transform.cpp b/ReactCommon/react/renderer/graphics/Transform.cpp index 6caea8e9749..0f48c9d2d5c 100644 --- a/ReactCommon/react/renderer/graphics/Transform.cpp +++ b/ReactCommon/react/renderer/graphics/Transform.cpp @@ -10,6 +10,7 @@ #include #include +#include namespace facebook { namespace react { @@ -226,8 +227,8 @@ Transform Transform::Interpolate( (haveRHS && rhs.operations[j].type == type ? rhs.operations[j++] : Transform::DefaultTransformOperation(type)); - assert(type == lhsOp.type); - assert(type == rhsOp.type); + react_native_assert(type == lhsOp.type); + react_native_assert(type == rhsOp.type); result = result * Transform::FromTransformOperation(TransformOperation{ diff --git a/ReactCommon/react/renderer/graphics/conversions.h b/ReactCommon/react/renderer/graphics/conversions.h index 3a61d17fc62..df1b5b1442a 100644 --- a/ReactCommon/react/renderer/graphics/conversions.h +++ b/ReactCommon/react/renderer/graphics/conversions.h @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -34,7 +35,7 @@ inline void fromRawValue(const RawValue &value, SharedColor &result) { } else if (value.hasType>()) { auto items = (std::vector)value; auto length = items.size(); - assert(length == 3 || length == 4); + react_native_assert(length == 3 || length == 4); red = items.at(0); green = items.at(1); blue = items.at(2); @@ -85,7 +86,7 @@ inline void fromRawValue(const RawValue &value, Point &result) { if (value.hasType>()) { auto array = (std::vector)value; - assert(array.size() == 2); + react_native_assert(array.size() == 2); result = {array.at(0), array.at(1)}; return; } @@ -108,7 +109,7 @@ inline void fromRawValue(const RawValue &value, Size &result) { if (value.hasType>()) { auto array = (std::vector)value; - assert(array.size() == 2); + react_native_assert(array.size() == 2); result = {array.at(0), array.at(1)}; return; } @@ -140,7 +141,7 @@ inline void fromRawValue(const RawValue &value, EdgeInsets &result) { if (value.hasType>()) { auto array = (std::vector)value; - assert(array.size() == 4); + react_native_assert(array.size() == 4); result = {array.at(0), array.at(1), array.at(2), array.at(3)}; return; } @@ -172,7 +173,7 @@ inline void fromRawValue(const RawValue &value, CornerInsets &result) { if (value.hasType>()) { auto array = (std::vector)value; - assert(array.size() == 4); + react_native_assert(array.size() == 4); result = {array.at(0), array.at(1), array.at(2), array.at(3)}; return; } diff --git a/ReactCommon/react/renderer/imagemanager/BUCK b/ReactCommon/react/renderer/imagemanager/BUCK index 12b73f7743c..57315337059 100644 --- a/ReactCommon/react/renderer/imagemanager/BUCK +++ b/ReactCommon/react/renderer/imagemanager/BUCK @@ -105,6 +105,7 @@ rn_xplat_cxx_library( "//xplat/folly:headers_only", "//xplat/folly:molly", YOGA_CXX_TARGET, + react_native_xplat_target("react/debug:debug"), react_native_xplat_target("react/renderer/core:core"), react_native_xplat_target("react/renderer/mounting:mounting"), react_native_xplat_target("react/renderer/debug:debug"), diff --git a/ReactCommon/react/renderer/imagemanager/ImageResponseObserverCoordinator.cpp b/ReactCommon/react/renderer/imagemanager/ImageResponseObserverCoordinator.cpp index 3f3fd6a5ffb..c75fa5b4c19 100644 --- a/ReactCommon/react/renderer/imagemanager/ImageResponseObserverCoordinator.cpp +++ b/ReactCommon/react/renderer/imagemanager/ImageResponseObserverCoordinator.cpp @@ -8,7 +8,8 @@ #include "ImageResponseObserverCoordinator.h" #include -#include + +#include namespace facebook { namespace react { @@ -52,7 +53,7 @@ void ImageResponseObserverCoordinator::nativeImageResponseProgress( float progress) const { mutex_.lock(); auto observers = observers_; - assert(status_ == ImageResponse::Status::Loading); + react_native_assert(status_ == ImageResponse::Status::Loading); mutex_.unlock(); for (auto observer : observers) { @@ -65,7 +66,7 @@ void ImageResponseObserverCoordinator::nativeImageResponseComplete( mutex_.lock(); imageData_ = imageResponse.getImage(); imageMetadata_ = imageResponse.getMetadata(); - assert(status_ == ImageResponse::Status::Loading); + react_native_assert(status_ == ImageResponse::Status::Loading); status_ = ImageResponse::Status::Completed; auto observers = observers_; mutex_.unlock(); @@ -77,7 +78,7 @@ void ImageResponseObserverCoordinator::nativeImageResponseComplete( void ImageResponseObserverCoordinator::nativeImageResponseFailed() const { mutex_.lock(); - assert(status_ == ImageResponse::Status::Loading); + react_native_assert(status_ == ImageResponse::Status::Loading); status_ = ImageResponse::Status::Failed; auto observers = observers_; mutex_.unlock(); diff --git a/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp b/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp index d753a43ba93..98001cfa1c1 100644 --- a/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp +++ b/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp @@ -14,6 +14,7 @@ #include +#include #include namespace facebook { @@ -37,7 +38,7 @@ void MountingCoordinator::push(ShadowTreeRevision const &revision) const { { std::lock_guard lock(mutex_); - assert( + react_native_assert( !lastRevision_.has_value() || revision.number != lastRevision_->number); if (!lastRevision_.has_value() || lastRevision_->number < revision.number) { @@ -162,7 +163,8 @@ better::optional MountingCoordinator::pullTransaction() } } - assert((treesEqual) && "Incorrect set of mutations detected."); + react_native_assert( + (treesEqual) && "Incorrect set of mutations detected."); } } #endif diff --git a/ReactCommon/react/renderer/mounting/ShadowTree.cpp b/ReactCommon/react/renderer/mounting/ShadowTree.cpp index fdfa5b990fd..14299f4c2da 100644 --- a/ReactCommon/react/renderer/mounting/ShadowTree.cpp +++ b/ReactCommon/react/renderer/mounting/ShadowTree.cpp @@ -7,6 +7,7 @@ #include "ShadowTree.h" +#include #include #include #include @@ -305,7 +306,7 @@ CommitStatus ShadowTree::commit( // After multiple attempts, we failed to commit the transaction. // Something internally went terribly wrong. - assert(attempts < 1024); + react_native_assert(attempts < 1024); } } diff --git a/ReactCommon/react/renderer/mounting/ShadowTreeRegistry.cpp b/ReactCommon/react/renderer/mounting/ShadowTreeRegistry.cpp index 38540ecfd73..8c801d82270 100644 --- a/ReactCommon/react/renderer/mounting/ShadowTreeRegistry.cpp +++ b/ReactCommon/react/renderer/mounting/ShadowTreeRegistry.cpp @@ -7,11 +7,13 @@ #include "ShadowTreeRegistry.h" +#include + namespace facebook { namespace react { ShadowTreeRegistry::~ShadowTreeRegistry() { - assert( + react_native_assert( registry_.empty() && "Deallocation of non-empty `ShadowTreeRegistry`."); } diff --git a/ReactCommon/react/renderer/mounting/StubViewTree.cpp b/ReactCommon/react/renderer/mounting/StubViewTree.cpp index d7a6e426655..c2199462d29 100644 --- a/ReactCommon/react/renderer/mounting/StubViewTree.cpp +++ b/ReactCommon/react/renderer/mounting/StubViewTree.cpp @@ -8,6 +8,7 @@ #include "StubViewTree.h" #include +#include // For iOS especially: flush logs because some might be lost on iOS if an // assert is hit right after this. @@ -16,7 +17,7 @@ LOG(ERROR) << "ASSERT FAILURE: " << #cond; \ google::FlushLogFiles(google::INFO); \ } \ - assert(cond); + react_native_assert(cond); #ifdef STUB_VIEW_TREE_VERBOSE #define STUB_VIEW_LOG(code) code diff --git a/ReactCommon/react/renderer/mounting/TransactionTelemetry.cpp b/ReactCommon/react/renderer/mounting/TransactionTelemetry.cpp index d81ed7c6bf4..1f9afb44b27 100644 --- a/ReactCommon/react/renderer/mounting/TransactionTelemetry.cpp +++ b/ReactCommon/react/renderer/mounting/TransactionTelemetry.cpp @@ -7,7 +7,7 @@ #include "TransactionTelemetry.h" -#include +#include namespace facebook { namespace react { @@ -27,32 +27,32 @@ void TransactionTelemetry::unsetAsThreadLocal() { } void TransactionTelemetry::willCommit() { - assert(commitStartTime_ == kTelemetryUndefinedTimePoint); - assert(commitEndTime_ == kTelemetryUndefinedTimePoint); + react_native_assert(commitStartTime_ == kTelemetryUndefinedTimePoint); + react_native_assert(commitEndTime_ == kTelemetryUndefinedTimePoint); commitStartTime_ = telemetryTimePointNow(); } void TransactionTelemetry::didCommit() { - assert(commitStartTime_ != kTelemetryUndefinedTimePoint); - assert(commitEndTime_ == kTelemetryUndefinedTimePoint); + react_native_assert(commitStartTime_ != kTelemetryUndefinedTimePoint); + react_native_assert(commitEndTime_ == kTelemetryUndefinedTimePoint); commitEndTime_ = telemetryTimePointNow(); } void TransactionTelemetry::willDiff() { - assert(diffStartTime_ == kTelemetryUndefinedTimePoint); - assert(diffEndTime_ == kTelemetryUndefinedTimePoint); + react_native_assert(diffStartTime_ == kTelemetryUndefinedTimePoint); + react_native_assert(diffEndTime_ == kTelemetryUndefinedTimePoint); diffStartTime_ = telemetryTimePointNow(); } void TransactionTelemetry::didDiff() { - assert(diffStartTime_ != kTelemetryUndefinedTimePoint); - assert(diffEndTime_ == kTelemetryUndefinedTimePoint); + react_native_assert(diffStartTime_ != kTelemetryUndefinedTimePoint); + react_native_assert(diffEndTime_ == kTelemetryUndefinedTimePoint); diffEndTime_ = telemetryTimePointNow(); } void TransactionTelemetry::willLayout() { - assert(layoutStartTime_ == kTelemetryUndefinedTimePoint); - assert(layoutEndTime_ == kTelemetryUndefinedTimePoint); + react_native_assert(layoutStartTime_ == kTelemetryUndefinedTimePoint); + react_native_assert(layoutEndTime_ == kTelemetryUndefinedTimePoint); layoutStartTime_ = telemetryTimePointNow(); } @@ -61,20 +61,20 @@ void TransactionTelemetry::didMeasureText() { } void TransactionTelemetry::didLayout() { - assert(layoutStartTime_ != kTelemetryUndefinedTimePoint); - assert(layoutEndTime_ == kTelemetryUndefinedTimePoint); + react_native_assert(layoutStartTime_ != kTelemetryUndefinedTimePoint); + react_native_assert(layoutEndTime_ == kTelemetryUndefinedTimePoint); layoutEndTime_ = telemetryTimePointNow(); } void TransactionTelemetry::willMount() { - assert(mountStartTime_ == kTelemetryUndefinedTimePoint); - assert(mountEndTime_ == kTelemetryUndefinedTimePoint); + react_native_assert(mountStartTime_ == kTelemetryUndefinedTimePoint); + react_native_assert(mountEndTime_ == kTelemetryUndefinedTimePoint); mountStartTime_ = telemetryTimePointNow(); } void TransactionTelemetry::didMount() { - assert(mountStartTime_ != kTelemetryUndefinedTimePoint); - assert(mountEndTime_ == kTelemetryUndefinedTimePoint); + react_native_assert(mountStartTime_ != kTelemetryUndefinedTimePoint); + react_native_assert(mountEndTime_ == kTelemetryUndefinedTimePoint); mountEndTime_ = telemetryTimePointNow(); } @@ -83,50 +83,50 @@ void TransactionTelemetry::setRevisionNumber(int revisionNumber) { } TelemetryTimePoint TransactionTelemetry::getDiffStartTime() const { - assert(diffStartTime_ != kTelemetryUndefinedTimePoint); - assert(diffEndTime_ != kTelemetryUndefinedTimePoint); + react_native_assert(diffStartTime_ != kTelemetryUndefinedTimePoint); + react_native_assert(diffEndTime_ != kTelemetryUndefinedTimePoint); return diffStartTime_; } TelemetryTimePoint TransactionTelemetry::getDiffEndTime() const { - assert(diffStartTime_ != kTelemetryUndefinedTimePoint); - assert(diffEndTime_ != kTelemetryUndefinedTimePoint); + react_native_assert(diffStartTime_ != kTelemetryUndefinedTimePoint); + react_native_assert(diffEndTime_ != kTelemetryUndefinedTimePoint); return diffEndTime_; } TelemetryTimePoint TransactionTelemetry::getCommitStartTime() const { - assert(commitStartTime_ != kTelemetryUndefinedTimePoint); - assert(commitEndTime_ != kTelemetryUndefinedTimePoint); + react_native_assert(commitStartTime_ != kTelemetryUndefinedTimePoint); + react_native_assert(commitEndTime_ != kTelemetryUndefinedTimePoint); return commitStartTime_; } TelemetryTimePoint TransactionTelemetry::getCommitEndTime() const { - assert(commitStartTime_ != kTelemetryUndefinedTimePoint); - assert(commitEndTime_ != kTelemetryUndefinedTimePoint); + react_native_assert(commitStartTime_ != kTelemetryUndefinedTimePoint); + react_native_assert(commitEndTime_ != kTelemetryUndefinedTimePoint); return commitEndTime_; } TelemetryTimePoint TransactionTelemetry::getLayoutStartTime() const { - assert(layoutStartTime_ != kTelemetryUndefinedTimePoint); - assert(layoutEndTime_ != kTelemetryUndefinedTimePoint); + react_native_assert(layoutStartTime_ != kTelemetryUndefinedTimePoint); + react_native_assert(layoutEndTime_ != kTelemetryUndefinedTimePoint); return layoutStartTime_; } TelemetryTimePoint TransactionTelemetry::getLayoutEndTime() const { - assert(layoutStartTime_ != kTelemetryUndefinedTimePoint); - assert(layoutEndTime_ != kTelemetryUndefinedTimePoint); + react_native_assert(layoutStartTime_ != kTelemetryUndefinedTimePoint); + react_native_assert(layoutEndTime_ != kTelemetryUndefinedTimePoint); return layoutEndTime_; } TelemetryTimePoint TransactionTelemetry::getMountStartTime() const { - assert(mountStartTime_ != kTelemetryUndefinedTimePoint); - assert(mountEndTime_ != kTelemetryUndefinedTimePoint); + react_native_assert(mountStartTime_ != kTelemetryUndefinedTimePoint); + react_native_assert(mountEndTime_ != kTelemetryUndefinedTimePoint); return mountStartTime_; } TelemetryTimePoint TransactionTelemetry::getMountEndTime() const { - assert(mountStartTime_ != kTelemetryUndefinedTimePoint); - assert(mountEndTime_ != kTelemetryUndefinedTimePoint); + react_native_assert(mountStartTime_ != kTelemetryUndefinedTimePoint); + react_native_assert(mountEndTime_ != kTelemetryUndefinedTimePoint); return mountEndTime_; } diff --git a/ReactCommon/react/renderer/scheduler/BUCK b/ReactCommon/react/renderer/scheduler/BUCK index 9d6a9df0763..4ca4fb7d58f 100644 --- a/ReactCommon/react/renderer/scheduler/BUCK +++ b/ReactCommon/react/renderer/scheduler/BUCK @@ -55,11 +55,12 @@ rn_xplat_cxx_library( "//xplat/folly:molly", "//xplat/jsi:JSIDynamic", "//xplat/jsi:jsi", + react_native_xplat_target("react/config:config"), + react_native_xplat_target("react/debug:debug"), react_native_xplat_target("react/renderer/core:core"), react_native_xplat_target("react/renderer/mounting:mounting"), react_native_xplat_target("react/renderer/uimanager:uimanager"), react_native_xplat_target("react/renderer/templateprocessor:templateprocessor"), - react_native_xplat_target("react/config:config"), react_native_xplat_target("react/renderer/componentregistry:componentregistry"), react_native_xplat_target("react/renderer/debug:debug"), react_native_xplat_target("react/renderer/components/root:root"), diff --git a/ReactCommon/react/renderer/scheduler/Scheduler.cpp b/ReactCommon/react/renderer/scheduler/Scheduler.cpp index 026052ce5ac..2d7c286a631 100644 --- a/ReactCommon/react/renderer/scheduler/Scheduler.cpp +++ b/ReactCommon/react/renderer/scheduler/Scheduler.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -153,7 +154,7 @@ Scheduler::~Scheduler() { surfaceIds.push_back(shadowTree.getSurfaceId()); }); - assert( + react_native_assert( surfaceIds.empty() && "Scheduler was destroyed with outstanding Surfaces."); diff --git a/ReactCommon/react/renderer/scheduler/SurfaceHandler.cpp b/ReactCommon/react/renderer/scheduler/SurfaceHandler.cpp index b805dc54f02..0e01c6e8d4e 100644 --- a/ReactCommon/react/renderer/scheduler/SurfaceHandler.cpp +++ b/ReactCommon/react/renderer/scheduler/SurfaceHandler.cpp @@ -7,6 +7,7 @@ #include "SurfaceHandler.h" +#include #include #include @@ -55,7 +56,8 @@ Status SurfaceHandler::getStatus() const noexcept { void SurfaceHandler::start() const noexcept { { std::unique_lock lock(linkMutex_); - assert(link_.status == Status::Registered && "Surface must be registered."); + react_native_assert( + link_.status == Status::Registered && "Surface must be registered."); auto parameters = Parameters{}; { @@ -78,7 +80,8 @@ void SurfaceHandler::start() const noexcept { void SurfaceHandler::stop() const noexcept { std::unique_lock lock(linkMutex_); - assert(link_.status == Status::Running && "Surface must be running."); + react_native_assert( + link_.status == Status::Running && "Surface must be running."); link_.status = Status::Registered; link_.shadowTree = nullptr; @@ -136,8 +139,10 @@ folly::dynamic SurfaceHandler::getProps() const noexcept { std::shared_ptr SurfaceHandler::getMountingCoordinator() const noexcept { std::shared_lock lock(linkMutex_); - assert(link_.status != Status::Unregistered && "Surface must be registered."); - assert(link_.shadowTree && "`link_.shadowTree` must not be null."); + react_native_assert( + link_.status != Status::Unregistered && "Surface must be registered."); + react_native_assert( + link_.shadowTree && "`link_.shadowTree` must not be null."); return link_.shadowTree->getMountingCoordinator(); } @@ -152,7 +157,8 @@ Size SurfaceHandler::measure( return layoutConstraints.clamp({0, 0}); } - assert(link_.shadowTree && "`link_.shadowTree` must not be null."); + react_native_assert( + link_.shadowTree && "`link_.shadowTree` must not be null."); auto currentRootShadowNode = link_.shadowTree->getCurrentRevision().rootShadowNode; @@ -185,7 +191,8 @@ void SurfaceHandler::constraintLayout( return; } - assert(link_.shadowTree && "`link_.shadowTree` must not be null."); + react_native_assert( + link_.shadowTree && "`link_.shadowTree` must not be null."); link_.shadowTree->commit([&](RootShadowNode const &oldRootShadowNode) { return oldRootShadowNode.clone(layoutConstraints, layoutContext); }); @@ -205,8 +212,10 @@ LayoutContext SurfaceHandler::getLayoutContext() const noexcept { #pragma mark - Private void SurfaceHandler::applyDisplayMode(DisplayMode displayMode) const noexcept { - assert(link_.status == Status::Running && "Surface must be running."); - assert(link_.shadowTree && "`link_.shadowTree` must not be null."); + react_native_assert( + link_.status == Status::Running && "Surface must be running."); + react_native_assert( + link_.shadowTree && "`link_.shadowTree` must not be null."); switch (displayMode) { case DisplayMode::Visible: @@ -236,7 +245,8 @@ void SurfaceHandler::applyDisplayMode(DisplayMode displayMode) const noexcept { void SurfaceHandler::setUIManager(UIManager const *uiManager) const noexcept { std::unique_lock lock(linkMutex_); - assert(link_.status != Status::Running && "Surface must not be running."); + react_native_assert( + link_.status != Status::Running && "Surface must not be running."); if (link_.uiManager == uiManager) { return; @@ -247,7 +257,7 @@ void SurfaceHandler::setUIManager(UIManager const *uiManager) const noexcept { } SurfaceHandler::~SurfaceHandler() noexcept { - assert( + react_native_assert( link_.status == Status::Unregistered && "`SurfaceHandler` must be unregistered (or moved-from) before deallocation."); } diff --git a/ReactCommon/react/renderer/scheduler/SynchronousEventBeat.cpp b/ReactCommon/react/renderer/scheduler/SynchronousEventBeat.cpp index 245e07b463b..f80fd16d112 100644 --- a/ReactCommon/react/renderer/scheduler/SynchronousEventBeat.cpp +++ b/ReactCommon/react/renderer/scheduler/SynchronousEventBeat.cpp @@ -7,6 +7,8 @@ #include "SynchronousEventBeat.h" +#include + namespace facebook { namespace react { @@ -23,7 +25,7 @@ SynchronousEventBeat::SynchronousEventBeat( void SynchronousEventBeat::activityDidChange( RunLoopObserver::Delegate const *delegate, RunLoopObserver::Activity activity) const noexcept { - assert(delegate == this); + react_native_assert(delegate == this); lockExecutorAndBeat(); } diff --git a/ReactCommon/react/renderer/uimanager/BUCK b/ReactCommon/react/renderer/uimanager/BUCK index b6fc148707a..c879c476615 100644 --- a/ReactCommon/react/renderer/uimanager/BUCK +++ b/ReactCommon/react/renderer/uimanager/BUCK @@ -58,6 +58,7 @@ rn_xplat_cxx_library( "//xplat/jsi:JSIDynamic", "//xplat/jsi:jsi", react_native_xplat_target("react/config:config"), + react_native_xplat_target("react/debug:debug"), react_native_xplat_target("react/renderer/components/view:view"), react_native_xplat_target("react/renderer/mounting:mounting"), react_native_xplat_target("react/renderer/core:core"), diff --git a/ReactCommon/react/renderer/uimanager/UIManager.cpp b/ReactCommon/react/renderer/uimanager/UIManager.cpp index f13f0e76909..062fa60a923 100644 --- a/ReactCommon/react/renderer/uimanager/UIManager.cpp +++ b/ReactCommon/react/renderer/uimanager/UIManager.cpp @@ -7,6 +7,7 @@ #include "UIManager.h" +#include #include #include #include @@ -357,7 +358,7 @@ ShadowTreeRegistry const &UIManager::getShadowTreeRegistry() const { void UIManager::registerCommitHook( UIManagerCommitHook const &commitHook) const { std::unique_lock lock(commitHookMutex_); - assert( + react_native_assert( std::find(commitHooks_.begin(), commitHooks_.end(), &commitHook) == commitHooks_.end()); commitHook.commitHookWasRegistered(*this); @@ -369,7 +370,7 @@ void UIManager::unregisterCommitHook( std::unique_lock lock(commitHookMutex_); auto iterator = std::find(commitHooks_.begin(), commitHooks_.end(), &commitHook); - assert(iterator != commitHooks_.end()); + react_native_assert(iterator != commitHooks_.end()); commitHooks_.erase(iterator); commitHook.commitHookWasUnregistered(*this); } diff --git a/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp b/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp index 59fe6908618..28c5fb76d76 100644 --- a/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp +++ b/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -29,7 +30,7 @@ static jsi::Object getModule( if (!moduleAsValue.isObject()) { LOG(ERROR) << "getModule of " << moduleName << " is not an object"; } - assert(moduleAsValue.isObject()); + react_native_assert(moduleAsValue.isObject()); return moduleAsValue.asObject(runtime); } @@ -170,7 +171,7 @@ void UIManagerBinding::dispatchEvent( if (!payload.isObject()) { LOG(ERROR) << "payload for dispatchEvent is not an object: " << eventTarget->getTag(); } - assert(payload.isObject()); + react_native_assert(payload.isObject()); payload.asObject(runtime).setProperty(runtime, "target", eventTarget->getTag()); return instanceHandle; }()