Skip to content

Commit

Permalink
LayoutAnimations: force props to update when executing "final" mutations
Browse files Browse the repository at this point in the history
Summary:
When an animation is completed or a conflicting animation is detected, force props, state, layout, etc to update.

Currently, when a final animation mutation is queued, some attributes can be updated but not others, causing unexpected visual glitches at least on Android.

Some of these are arguably component bugs, but it's easier to just flush all attributes by tricking the platforms into updating all attributes. This will also prevent us from having to track down more of these bugs, potentially.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D23886519

fbshipit-source-id: 8e5081bbe3b7843c16c0f283fa07fdec0e211aa8
  • Loading branch information
JoshuaGross authored and facebook-github-bot committed Sep 24, 2020
1 parent d5f7622 commit 9f00752
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,15 @@ void LayoutAnimationDriver::animationMutationsForFrame(

// Copy so that if something else mutates the inflight animations, it
// won't change this mutation after this point.
ShadowView oldShadowView{};
if (finalMutationForKeyFrame.type !=
ShadowViewMutation::Type::Update) {
oldShadowView = finalMutationForKeyFrame.oldChildShadowView;
}
mutationsList.push_back(
ShadowViewMutation{finalMutationForKeyFrame.type,
finalMutationForKeyFrame.parentShadowView,
finalMutationForKeyFrame.oldChildShadowView,
oldShadowView,
finalMutationForKeyFrame.newChildShadowView,
finalMutationForKeyFrame.index});
} else {
Expand All @@ -217,7 +222,7 @@ void LayoutAnimationDriver::animationMutationsForFrame(
mutationsList.push_back(
ShadowViewMutation{ShadowViewMutation::Type::Update,
keyframe.parentView,
keyframe.viewStart,
{},
keyframe.viewEnd,
-1});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,16 @@ LayoutAnimationKeyFrameManager::pullTransaction(
auto &keyFrame = std::get<0>(conflictingKeyframeTuple);
if (keyFrame.finalMutationForKeyFrame.hasValue()) {
auto &mutation = *keyFrame.finalMutationForKeyFrame;
finalConflictingMutations.push_back(mutation);
if (mutation.type == ShadowViewMutation::Type::Update) {
finalConflictingMutations.push_back(
ShadowViewMutation::UpdateMutation(
mutation.parentShadowView,
{},
mutation.newChildShadowView,
mutation.index));
} else {
finalConflictingMutations.push_back(mutation);
}
}
}

Expand Down

0 comments on commit 9f00752

Please sign in to comment.