diff --git a/ReactCommon/react/renderer/uimanager/UIManager.cpp b/ReactCommon/react/renderer/uimanager/UIManager.cpp index bc35cd74e82..b99cd3be700 100644 --- a/ReactCommon/react/renderer/uimanager/UIManager.cpp +++ b/ReactCommon/react/renderer/uimanager/UIManager.cpp @@ -345,8 +345,9 @@ void UIManager::configureNextLayoutAnimation( RawValue const &config, jsi::Value const &successCallback, jsi::Value const &failureCallback) const { - if (animationDelegate_) { - animationDelegate_->uiManagerDidConfigureNextLayoutAnimation( + auto animationDelegate = animationDelegate_.load(); + if (animationDelegate) { + animationDelegate->uiManagerDidConfigureNextLayoutAnimation( runtime, config, std::move(successCallback), @@ -435,14 +436,15 @@ void UIManager::setAnimationDelegate(UIManagerAnimationDelegate *delegate) { } void UIManager::stopSurfaceForAnimationDelegate(SurfaceId surfaceId) const { - if (animationDelegate_ != nullptr) { - animationDelegate_->stopSurface(surfaceId); + auto animationDelegate = animationDelegate_.load(); + if (animationDelegate) { + animationDelegate->stopSurface(surfaceId); } } void UIManager::animationTick() { - if (animationDelegate_ != nullptr && - animationDelegate_->shouldAnimateFrame()) { + auto animationDelegate = animationDelegate_.load(); + if (animationDelegate && 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 617410f4afd..285df897d1e 100644 --- a/ReactCommon/react/renderer/uimanager/UIManager.h +++ b/ReactCommon/react/renderer/uimanager/UIManager.h @@ -184,8 +184,8 @@ class UIManager final : public ShadowTreeDelegate { ShadowTreeRegistry const &getShadowTreeRegistry() const; SharedComponentDescriptorRegistry componentDescriptorRegistry_; - UIManagerAnimationDelegate *animationDelegate_{nullptr}; std::atomic delegate_; + std::atomic animationDelegate_{nullptr}; RuntimeExecutor const runtimeExecutor_{}; ShadowTreeRegistry shadowTreeRegistry_{}; BackgroundExecutor const backgroundExecutor_{};