From 565e06f8d07b1771335d4fd8b0971b5408df3d8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20M=C4=85ka?= Date: Tue, 22 Aug 2023 08:50:47 -0700 Subject: [PATCH] On setting the same state for ShadowNodeFamily, don't mark it as obsolete (#39095) Summary: During investigation of impact of PR https://github.com/facebook/react-native/pull/38706 on `reanimated` I found out that when: - state reconciliation is turned on - `progressState` in `ShadowTree::tryCommit` quite often returns a new pointer to updated shadow tree - above happened due to `newState->getMostRecentStateIfObsolete()` returning precisely the same ptr as `newState` in `progressState` - this is caused by calling `ShadowNodeFamily::setMostRecentState` with the same state as currently held and marking those states as obsolete This PR adds additional check whether `ShadowNodeFamily::setMostRecentState` is called with the same `state` as currently set and skips setting obsolete flag if that happens. ## Changelog: [INTERNAL][FIXED] Setting the same most recent state for ShadowNodeFamily, doesn't mark it as obsolete Pull Request resolved: https://github.com/facebook/react-native/pull/39095 Test Plan: None Reviewed By: cipolleschi Differential Revision: D48526395 Pulled By: sammy-SC fbshipit-source-id: f77cea2364611a42a3363285b4732f33aae8a0a7 --- .../ReactCommon/react/renderer/core/ShadowNodeFamily.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-native/ReactCommon/react/renderer/core/ShadowNodeFamily.cpp b/packages/react-native/ReactCommon/react/renderer/core/ShadowNodeFamily.cpp index 5035656aceb..3d7d7f78cd4 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/ShadowNodeFamily.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/ShadowNodeFamily.cpp @@ -116,7 +116,7 @@ void ShadowNodeFamily::setMostRecentState(State::Shared const &state) const { * Nodes (the evolution of nodes is not linear), however, we never back out * states (they progress linearly). */ - if (state && state->isObsolete_) { + if (state && (state->isObsolete_ || state == mostRecentState_)) { return; }