From be27f44e1b67cff6e8c20f6ccf385feee2f65fae Mon Sep 17 00:00:00 2001 From: Simon Racz Date: Mon, 2 Oct 2017 17:40:01 -0700 Subject: [PATCH] Removed a wrong assert. Summary: This fixes [#15801](https://github.com/facebook/react-native/issues/15801) We ran into a strange crash on iOS (debug only). After removing the clutter I was able to reproduce it in a tiny app. You can check it out [here.](https://github.com/simonracz/textinput_stress) The UI in JS and native are not always in sync (which is okay). Due to this, a native view might call back into JS, which is no longer present in the shadow view hierarchy there. I think this should be also okay. TextInput in some cases calls into [setIntrinsicContentView](https://github.com/facebook/react-native/blob/6d67e2dbbcd658b7f845ebb0d0156bd64dc68226/React/Modules/RCTUIManager.m#L382), where it triggers an overly enthusiastic `NSAssert` and crashes the app. Check out [textinput_stress](https://github.com/simonracz/textinput_stress) Rotate the simulator a few times to see the crash or the lack of crash. Closes https://github.com/facebook/react-native/pull/16170 Differential Revision: D5959776 Pulled By: shergin fbshipit-source-id: f39f5a3f1d86b330ecf7cbccd90871bc01fd69d9 --- React/Modules/RCTUIManager.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/React/Modules/RCTUIManager.m b/React/Modules/RCTUIManager.m index 76a61688473..b22453b9334 100644 --- a/React/Modules/RCTUIManager.m +++ b/React/Modules/RCTUIManager.m @@ -376,7 +376,10 @@ static NSDictionary *deviceOrientationEventBody(UIDeviceOrientation orientation) NSNumber *reactTag = view.reactTag; dispatch_async(RCTGetUIManagerQueue(), ^{ RCTShadowView *shadowView = self->_shadowViewRegistry[reactTag]; - RCTAssert(shadowView != nil, @"Could not locate view with tag #%@", reactTag); + if (shadowView == nil) { + RCTLogWarn(@"Could not locate shadow view with tag #%@, this is probably caused by a temporary inconsistency between native views and shadow views.", reactTag); + return; + } if (!CGSizeEqualToSize(shadowView.intrinsicContentSize, size)) { shadowView.intrinsicContentSize = size;