mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fabric: Fixed another crash in RCTImageComponentView (nulled event emitter)
Summary: This fixes a crash happened in Image component caused by a race between recycling a component and image loading event are being delivered asynchronously. Reviewed By: mdvacca Differential Revision: D15977418 fbshipit-source-id: ac6f4b3d2b995af2afd56e551380a32d0f14ab15
This commit is contained in:
committed by
Facebook Github Bot
parent
970bd2c69c
commit
4b8d07ebf3
@@ -125,6 +125,13 @@
|
||||
|
||||
- (void)didReceiveImage:(UIImage *)image fromObserver:(void *)observer
|
||||
{
|
||||
if (!_eventEmitter) {
|
||||
// Notifications are delivered asynchronously and might arrive after the view is already recycled.
|
||||
// In the future, we should incorporate an `EventEmitter` into a separate object owned by `ImageRequest` or `State`.
|
||||
// See for more info: T46311063.
|
||||
return;
|
||||
}
|
||||
|
||||
std::static_pointer_cast<const ImageEventEmitter>(_eventEmitter)->onLoad();
|
||||
|
||||
const auto &imageProps = *std::static_pointer_cast<const ImageProps>(_props);
|
||||
@@ -153,11 +160,19 @@
|
||||
|
||||
- (void)didReceiveProgress:(float)progress fromObserver:(void *)observer
|
||||
{
|
||||
if (!_eventEmitter) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::static_pointer_cast<const ImageEventEmitter>(_eventEmitter)->onProgress(progress);
|
||||
}
|
||||
|
||||
- (void)didReceiveFailureFromObserver:(void *)observer
|
||||
{
|
||||
if (!_eventEmitter) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::static_pointer_cast<const ImageEventEmitter>(_eventEmitter)->onError();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user