From 50dde4b7b74ebcc380599249d64ee65325405aa5 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Thu, 3 Dec 2020 17:06:49 -0800 Subject: [PATCH] LayoutAnimations: Fix out-of-order DELETE and REMOVE instruction generation Summary: In very marginal cases, it was possible to set up an animation of the following diffing instructions: ``` REMOVE X from parent Y DELETE X ``` If your LayoutAnimation configuration had no "delete" config, the DELETE would be executed immediately; the REMOVE was erroneously being categorized as an "update" (now fixed) which caused the REMOVE to be delayed, but then executed very shortly thereafter. So the order of instructions would become: ``` DELETE X REMOVE X from parent Y ``` which would crash (or at least fail an assertion) when the REMOVE instruction was processed. This fixes the issue by ensuring that REMOVEs have a corresponding "delete" config, or they are also executed immediately; unless followed by an INSERT (and any combination of `REMOVE, DELETE, INSERT` in the same frame is not possible). Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D25292560 fbshipit-source-id: 7ffdd6cbcb43126de07a70c197dfaf1ebff83555 --- .../renderer/animations/LayoutAnimationKeyFrameManager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp index ddc2353e0ef..512fe8274cd 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp @@ -914,7 +914,9 @@ LayoutAnimationKeyFrameManager::pullTransaction( } auto const &mutationConfig = - (mutation.type == ShadowViewMutation::Type::Delete + (mutation.type == ShadowViewMutation::Type::Delete || + (mutation.type == ShadowViewMutation::Type::Remove && + !wasInsertedTagRemoved) ? layoutAnimationConfig.deleteConfig : (mutation.type == ShadowViewMutation::Type::Insert && !wasInsertedTagRemoved