Skip to content

Commit

Permalink
Removed a wrong assert.
Browse files Browse the repository at this point in the history
Summary:
This fixes [facebook#15801](facebook#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 facebook#16170

Differential Revision: D5959776

Pulled By: shergin

fbshipit-source-id: f39f5a3f1d86b330ecf7cbccd90871bc01fd69d9
  • Loading branch information
simonracz authored and facebook-github-bot committed Oct 3, 2017
1 parent 915ac20 commit be27f44
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion React/Modules/RCTUIManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,10 @@ - (void)setIntrinsicContentSize:(CGSize)size forView:(UIView *)view
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;
Expand Down

0 comments on commit be27f44

Please sign in to comment.