From e7ef9921d3f91b02cfec4bbfd88b4968434e201c Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Tue, 15 Oct 2019 07:41:24 -0700 Subject: [PATCH] Fabric: Fixing crash in RCTScrollViewComponentView (2nd attempt) Summary: Seems a ScrollView sometimes calls the delegate in own destructor; and seems that in some configurations the delegate is also already destroyed at this point. I am not sure if this a bug in UIKit or not, but seems the fix is easy, we just have to clear the ScrollView's delegate on the delegate's deallocation. This issue is also looks similar: https://stackoverflow.com/questions/18778691/crash-on-exc-breakpoint-scroll-view/19011871 Changelog: [iOS] [Fixed] - Fixed crash in RCTScrollViewComponentView Reviewed By: sammy-SC Differential Revision: D17924429 fbshipit-source-id: 5727bca9f028e28f76f60304c187ee39eb6e1856 --- .../ComponentViews/ScrollView/RCTScrollViewComponentView.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm index 38ad88e8677b23..11ce0de3320228 100644 --- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm @@ -85,7 +85,8 @@ - (instancetype)initWithFrame:(CGRect)frame - (void)dealloc { - [_scrollViewDelegateSplitter removeDelegate:self]; + // This is not strictly necessary but that prevents a crash caused by a bug in UIKit. + _scrollView.delegate = nil; } #pragma mark - RCTComponentViewProtocol