Skip to content

Commit

Permalink
On setting the same state for ShadowNodeFamily, don't mark it as obso…
Browse files Browse the repository at this point in the history
…lete (#39095)

Summary:
During investigation of impact of PR #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: #39095

Test Plan: None

Reviewed By: cipolleschi

Differential Revision: D48526395

Pulled By: sammy-SC

fbshipit-source-id: f77cea2364611a42a3363285b4732f33aae8a0a7
  • Loading branch information
michalmaka authored and facebook-github-bot committed Aug 22, 2023
1 parent 172e2d0 commit 565e06f
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 565e06f

Please sign in to comment.