From 110ef5bf3068fead964073ed8a8ebfbb866bafab Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Mon, 26 Jul 2021 10:19:22 -0700 Subject: [PATCH] Back out "Use atomic pointer for animationDelegate_ to prevent race during teardown" Summary: Changelog: [internal] Original commit changeset: 6cb898caf7c2 This change doesn't fix LayoutAnimation crashes. Let's back it out. Reviewed By: fkgozali Differential Revision: D29909973 fbshipit-source-id: 34926ace220e6b269bb938a3da72c977b0608187 --- ReactCommon/react/renderer/uimanager/UIManager.cpp | 14 ++++++-------- ReactCommon/react/renderer/uimanager/UIManager.h | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/ReactCommon/react/renderer/uimanager/UIManager.cpp b/ReactCommon/react/renderer/uimanager/UIManager.cpp index a15c46313ab..ea5e77036a0 100644 --- a/ReactCommon/react/renderer/uimanager/UIManager.cpp +++ b/ReactCommon/react/renderer/uimanager/UIManager.cpp @@ -341,9 +341,8 @@ void UIManager::configureNextLayoutAnimation( RawValue const &config, jsi::Value const &successCallback, jsi::Value const &failureCallback) const { - auto animationDelegate = animationDelegate_.load(); - if (animationDelegate) { - animationDelegate->uiManagerDidConfigureNextLayoutAnimation( + if (animationDelegate_) { + animationDelegate_->uiManagerDidConfigureNextLayoutAnimation( runtime, config, std::move(successCallback), @@ -431,15 +430,14 @@ void UIManager::setAnimationDelegate(UIManagerAnimationDelegate *delegate) { } void UIManager::stopSurfaceForAnimationDelegate(SurfaceId surfaceId) const { - auto animationDelegate = animationDelegate_.load(); - if (animationDelegate) { - animationDelegate->stopSurface(surfaceId); + if (animationDelegate_ != nullptr) { + animationDelegate_->stopSurface(surfaceId); } } void UIManager::animationTick() { - auto animationDelegate = animationDelegate_.load(); - if (animationDelegate && animationDelegate->shouldAnimateFrame()) { + if (animationDelegate_ != nullptr && + animationDelegate_->shouldAnimateFrame()) { shadowTreeRegistry_.enumerate( [&](ShadowTree const &shadowTree, bool &stop) { shadowTree.notifyDelegatesOfUpdates(); diff --git a/ReactCommon/react/renderer/uimanager/UIManager.h b/ReactCommon/react/renderer/uimanager/UIManager.h index 13729bae024..ebb8a419bd0 100644 --- a/ReactCommon/react/renderer/uimanager/UIManager.h +++ b/ReactCommon/react/renderer/uimanager/UIManager.h @@ -185,7 +185,7 @@ class UIManager final : public ShadowTreeDelegate { SharedComponentDescriptorRegistry componentDescriptorRegistry_; UIManagerDelegate *delegate_; - std::atomic animationDelegate_{nullptr}; + UIManagerAnimationDelegate *animationDelegate_{nullptr}; RuntimeExecutor const runtimeExecutor_{}; ShadowTreeRegistry shadowTreeRegistry_{}; BackgroundExecutor const backgroundExecutor_{};