Files
react-native/React/Fabric/Mounting/RCTComponentViewDescriptor.h
T
Valentin Shergin 83f0210cee Fabric: Attempt to fix a crash in RCTMountingTransactionObserverCoordinator
Summary:
We see a quite small but probably dangerous crash in RCTMountingTransactionObserverCoordinator, it's unclear why exactly it happens but seems it's somehow connected with a shape of RCTComponentViewDescriptor struct.
Specifying storage attribute (`__strong`) correctly/explicitly might fix the issue.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18567763

fbshipit-source-id: 57d9f96c4609a38ddf44ce02df53f2d713dfb116
2019-11-19 09:50:52 -08:00

53 lines
1.4 KiB
Objective-C

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import <UIKit/UIKit.h>
#import <React/RCTComponentViewProtocol.h>
NS_ASSUME_NONNULL_BEGIN
/*
* Holds a native view instance and a set of attributes associated with it.
* Mounting infrastructure uses these objects to bookkeep views and cache their
* attributes for efficient access.
*/
class RCTComponentViewDescriptor final {
public:
/*
* Associated (and owned) native view instance.
*/
__strong UIView<RCTComponentViewProtocol> *view = nil;
/*
* Indicates a requirement to call on the view methods from
* `RCTMountingTransactionObserving` protocol.
*/
bool observesMountingTransactionWillMount{false};
bool observesMountingTransactionDidMount{false};
};
inline bool operator==(RCTComponentViewDescriptor const &lhs, RCTComponentViewDescriptor const &rhs)
{
return lhs.view == rhs.view;
}
inline bool operator!=(RCTComponentViewDescriptor const &lhs, RCTComponentViewDescriptor const &rhs)
{
return lhs.view != rhs.view;
}
template <>
struct std::hash<RCTComponentViewDescriptor> {
size_t operator()(RCTComponentViewDescriptor const &componentViewDescriptor) const
{
return std::hash<void *>()((__bridge void *)componentViewDescriptor.view);
}
};
NS_ASSUME_NONNULL_END