Skip to content

Commit

Permalink
Fix crash when blurring image
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sammy-SC authored and facebook-github-bot committed Oct 22, 2020
1 parent a8c90e6 commit ae418b8
Showing 1 changed file with 2 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,25 +153,17 @@ - (void)didReceiveImage:(UIImage *)image metadata:(id)metadata fromObserver:(voi
resizingMode:UIImageResizingModeStretch];
}

void (^didSetImage)() = ^() {
auto data = self->_stateTeller.getData();
if (!data.hasValue()) {
return;
}
};

if (imageProps.blurRadius > __FLT_EPSILON__) {
// Blur on a background thread to avoid blocking interaction.
CGFloat blurRadius = imageProps.blurRadius;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
UIImage *blurredImage = RCTBlurredImageWithRadius(image, imageProps.blurRadius);
UIImage *blurredImage = RCTBlurredImageWithRadius(image, blurRadius);
RCTExecuteOnMainQueue(^{
self->_imageView.image = blurredImage;
didSetImage();
});
});
} else {
self->_imageView.image = image;
didSetImage();
}
}

Expand Down

0 comments on commit ae418b8

Please sign in to comment.