Skip to content

Commit ae418b8

Browse files
sammy-SCfacebook-github-bot
authored andcommitted
Fix crash when blurring image
Summary: Changelog: [internal] Copy `blurRadius` into a variable instead of accessing it through a reference which might not exist when the block is dispatched. Reviewed By: cpojer Differential Revision: D24472850 fbshipit-source-id: 936ef671255ae0e825e1d2dfda9649824b63d297
1 parent a8c90e6 commit ae418b8

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,25 +153,17 @@ - (void)didReceiveImage:(UIImage *)image metadata:(id)metadata fromObserver:(voi
153153
resizingMode:UIImageResizingModeStretch];
154154
}
155155

156-
void (^didSetImage)() = ^() {
157-
auto data = self->_stateTeller.getData();
158-
if (!data.hasValue()) {
159-
return;
160-
}
161-
};
162-
163156
if (imageProps.blurRadius > __FLT_EPSILON__) {
164157
// Blur on a background thread to avoid blocking interaction.
158+
CGFloat blurRadius = imageProps.blurRadius;
165159
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
166-
UIImage *blurredImage = RCTBlurredImageWithRadius(image, imageProps.blurRadius);
160+
UIImage *blurredImage = RCTBlurredImageWithRadius(image, blurRadius);
167161
RCTExecuteOnMainQueue(^{
168162
self->_imageView.image = blurredImage;
169-
didSetImage();
170163
});
171164
});
172165
} else {
173166
self->_imageView.image = image;
174-
didSetImage();
175167
}
176168
}
177169

0 commit comments

Comments
 (0)