From 970bd2c69cfa7af782061cee3df08767dc25acfc Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Mon, 24 Jun 2019 17:17:47 -0700 Subject: [PATCH] Fabric: Fixed a crash in RCTImageComponentView Summary: The app crashed on assert which was not actually legit. See the comment in the code. Reviewed By: JoshuaGross Differential Revision: D15976177 fbshipit-source-id: 612bbbd510187ffdc86369aa943d4b652b748694 --- .../ComponentViews/Image/RCTImageComponentView.mm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm b/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm index 955a315eb4d..6d579e16452 100644 --- a/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm @@ -78,7 +78,13 @@ { SharedImageLocalData previousData = _imageLocalData; _imageLocalData = std::static_pointer_cast(localData); - assert(_imageLocalData); + + if (!_imageLocalData) { + // This might happen in very rare cases (e.g. inside a subtree inside a node with `display: none`). + // That's quite normal. + return; + } + bool havePreviousData = previousData != nullptr; if (!havePreviousData || _imageLocalData->getImageSource() != previousData->getImageSource()) {