mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Migrate Differentiator and RawPropsParser to rn_assert
Summary: This will allow these asserts to crash on Android debug builds. We will migrate more sites as we confirm this is stable through testing. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D26409354 fbshipit-source-id: fb35cd8de29890f7c2b761435eaa02de377bdd1e
This commit is contained in:
committed by
Facebook GitHub Bot
parent
ec4833f06d
commit
16cf45ac3d
@@ -58,6 +58,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/utils:utils"),
|
||||
react_native_xplat_target("react/renderer/debug:debug"),
|
||||
react_native_xplat_target("react/renderer/graphics:graphics"),
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "RawPropsParser.h"
|
||||
|
||||
#include <folly/Likely.h>
|
||||
#include <react/debug/rn_assert.h>
|
||||
#include <react/renderer/core/RawProps.h>
|
||||
|
||||
#include <glog/logging.h>
|
||||
@@ -62,14 +63,14 @@ RawValue const *RawPropsParser::at(
|
||||
// the same order every time. This is trivial if you have a simple Props
|
||||
// constructor, but difficult or impossible if you have a shared sub-prop
|
||||
// Struct that is used by multiple parent Props.
|
||||
#ifndef NDEBUG
|
||||
#ifdef RN_DEBUG
|
||||
bool resetLoop = false;
|
||||
#endif
|
||||
do {
|
||||
rawProps.keyIndexCursor_++;
|
||||
|
||||
if (UNLIKELY(rawProps.keyIndexCursor_ >= size_)) {
|
||||
#ifndef NDEBUG
|
||||
#ifdef RN_DEBUG
|
||||
if (resetLoop) {
|
||||
LOG(ERROR) << "Looked up RawProps key that does not exist: "
|
||||
<< (std::string)key;
|
||||
@@ -106,7 +107,7 @@ void RawPropsParser::preparse(RawProps const &rawProps) const noexcept {
|
||||
if (!rawProps.value_.isObject()) {
|
||||
LOG(ERROR) << "Preparse props: rawProps value is not object";
|
||||
}
|
||||
assert(rawProps.value_.isObject());
|
||||
rn_assert(rawProps.value_.isObject());
|
||||
auto object = rawProps.value_.asObject(runtime);
|
||||
|
||||
auto names = object.getPropertyNames(runtime);
|
||||
|
||||
@@ -37,16 +37,6 @@ rn_xplat_cxx_library(
|
||||
"-std=c++14",
|
||||
"-Wall",
|
||||
],
|
||||
exported_platform_linker_flags = [
|
||||
(
|
||||
"^android.*",
|
||||
["-llog"],
|
||||
),
|
||||
],
|
||||
fbandroid_linker_flags = [
|
||||
# for android rn_assert
|
||||
"-llog",
|
||||
],
|
||||
fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,
|
||||
fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(),
|
||||
force_static = True,
|
||||
|
||||
@@ -57,6 +57,7 @@ rn_xplat_cxx_library(
|
||||
"//xplat/folly:memory",
|
||||
"//xplat/folly:molly",
|
||||
react_native_xplat_target("better:better"),
|
||||
react_native_xplat_target("react/debug:debug"),
|
||||
react_native_xplat_target("react/renderer/components/root:root"),
|
||||
react_native_xplat_target("react/renderer/components/view:view"),
|
||||
react_native_xplat_target("react/renderer/core:core"),
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <better/map.h>
|
||||
#include <better/small_vector.h>
|
||||
#include <react/debug/rn_assert.h>
|
||||
#include <react/renderer/core/LayoutableShadowNode.h>
|
||||
#include <react/renderer/debug/SystraceSection.h>
|
||||
#include <algorithm>
|
||||
@@ -82,7 +83,7 @@ class TinyMap final {
|
||||
inline Iterator find(KeyT key) {
|
||||
cleanVector();
|
||||
|
||||
assert(key != 0);
|
||||
rn_assert(key != 0);
|
||||
|
||||
if (begin_() == nullptr) {
|
||||
return end();
|
||||
@@ -98,7 +99,7 @@ class TinyMap final {
|
||||
}
|
||||
|
||||
inline void insert(Pair pair) {
|
||||
assert(pair.first != 0);
|
||||
rn_assert(pair.first != 0);
|
||||
vector_.push_back(pair);
|
||||
}
|
||||
|
||||
@@ -1489,7 +1490,7 @@ ShadowViewMutation::List calculateShadowViewMutations(
|
||||
SystraceSection s("calculateShadowViewMutations");
|
||||
|
||||
// Root shadow nodes must be belong the same family.
|
||||
assert(ShadowNode::sameFamily(oldRootShadowNode, newRootShadowNode));
|
||||
rn_assert(ShadowNode::sameFamily(oldRootShadowNode, newRootShadowNode));
|
||||
|
||||
auto mutations = ShadowViewMutation::List{};
|
||||
mutations.reserve(256);
|
||||
|
||||
Reference in New Issue
Block a user