Back out "Use atomic pointer to prevent race during teardown"

Summary:
Changelog: [internal]

Original commit changeset: 390e773283a7

Original diff didn't resolve crash T82119127. Let's back this out and investigate again.

Reviewed By: mdvacca

Differential Revision: D29909878

fbshipit-source-id: 54b054f4a5c97b8f6369f8790c2cf32a56c4fbd2
This commit is contained in:
Samuel Susla
2021-07-26 10:20:55 -07:00
committed by Facebook GitHub Bot
parent d27288044e
commit cfd425406a
2 changed files with 13 additions and 19 deletions
@@ -72,9 +72,8 @@ SharedShadowNode UIManager::createNode(
},
family);
auto delegate = delegate_.load();
if (delegate) {
delegate->uiManagerDidCreateShadowNode(*shadowNode.get());
if (delegate_) {
delegate_->uiManagerDidCreateShadowNode(*shadowNode.get());
}
if (leakChecker_) {
leakChecker_->uiManagerDidCreateShadowNodeFamily(family);
@@ -100,9 +99,8 @@ SharedShadowNode UIManager::cloneNode(
/* .children = */ children,
});
auto delegate = delegate_.load();
if (delegate) {
delegate->uiManagerDidCloneShadowNode(
if (delegate_) {
delegate_->uiManagerDidCloneShadowNode(
*shadowNode.get(), *clonedShadowNode.get());
}
@@ -142,9 +140,8 @@ void UIManager::setIsJSResponder(
ShadowNode::Shared const &shadowNode,
bool isJSResponder,
bool blockNativeResponder) const {
auto delegate = delegate_.load();
if (delegate) {
delegate->uiManagerDidSetIsJSResponder(
if (delegate_) {
delegate_->uiManagerDidSetIsJSResponder(
shadowNode, isJSResponder, blockNativeResponder);
}
}
@@ -326,18 +323,16 @@ void UIManager::dispatchCommand(
const ShadowNode::Shared &shadowNode,
std::string const &commandName,
folly::dynamic const args) const {
auto delegate = delegate_.load();
if (delegate) {
delegate->uiManagerDidDispatchCommand(shadowNode, commandName, args);
if (delegate_) {
delegate_->uiManagerDidDispatchCommand(shadowNode, commandName, args);
}
}
void UIManager::sendAccessibilityEvent(
const ShadowNode::Shared &shadowNode,
std::string const &eventType) {
auto delegate = delegate_.load();
if (delegate) {
delegate->uiManagerDidSendAccessibilityEvent(shadowNode, eventType);
if (delegate_) {
delegate_->uiManagerDidSendAccessibilityEvent(shadowNode, eventType);
}
}
@@ -424,9 +419,8 @@ void UIManager::shadowTreeDidFinishTransaction(
MountingCoordinator::Shared const &mountingCoordinator) const {
SystraceSection s("UIManager::shadowTreeDidFinishTransaction");
auto delegate = delegate_.load();
if (delegate) {
delegate->uiManagerDidFinishTransaction(mountingCoordinator);
if (delegate_) {
delegate_->uiManagerDidFinishTransaction(mountingCoordinator);
}
}
@@ -184,7 +184,7 @@ class UIManager final : public ShadowTreeDelegate {
ShadowTreeRegistry const &getShadowTreeRegistry() const;
SharedComponentDescriptorRegistry componentDescriptorRegistry_;
std::atomic<UIManagerDelegate *> delegate_;
UIManagerDelegate *delegate_;
std::atomic<UIManagerAnimationDelegate *> animationDelegate_{nullptr};
RuntimeExecutor const runtimeExecutor_{};
ShadowTreeRegistry shadowTreeRegistry_{};