From cf906cc59999f96ba8eabd7f731cd14ef679b4c0 Mon Sep 17 00:00:00 2001 From: Mattias Pfeiffer Date: Wed, 28 Sep 2016 13:26:16 -0700 Subject: [PATCH] Use strong reference in RCTImageLoader Summary: This PR is related to the multitude of crashes (#10016, #9751, #9882). From my understanding, we should be using a strong reference when calling `decodeImageData` or we could be calling the method on a deallocated instance. PR #9751 have mitigated this by adding a fail-safe, but I think the culprint is the weak reference, which this PR fixes. Tested on iOS only, since it doesn't touch Android. Closes https://github.com/facebook/react-native/pull/10147 Differential Revision: D3938763 fbshipit-source-id: 7389d4ae7a98926014401a1fe0cbbdcdd5ee6a01 --- Libraries/Image/RCTImageLoader.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/Image/RCTImageLoader.m b/Libraries/Image/RCTImageLoader.m index 42e4ebac3dd..7c6685a0704 100644 --- a/Libraries/Image/RCTImageLoader.m +++ b/Libraries/Image/RCTImageLoader.m @@ -553,7 +553,7 @@ static UIImage *RCTResizeImageIfNeeded(UIImage *image, completionBlock(error_, image); }; - cancelLoad = [weakSelf decodeImageData:imageOrData + cancelLoad = [strongSelf decodeImageData:imageOrData size:size scale:scale clipped:clipped