Skip to content

fix: Stop CA animations from leaking onto recycled layers#9508

Open
MatiPl01 wants to merge 1 commit into
mainfrom
@matipl01/fix-ios-ca-transition-cleanup
Open

fix: Stop CA animations from leaking onto recycled layers#9508
MatiPl01 wants to merge 1 commit into
mainfrom
@matipl01/fix-ios-ca-transition-cleanup

Conversation

@MatiPl01
Copy link
Copy Markdown
Member

@MatiPl01 MatiPl01 commented May 22, 2026

Summary

Animations were created with removedOnCompletion=NO and fillMode=kCAFillModeBoth, so once an opacity transition finished it kept painting its toValue over the model layer forever. When RN later recycled that layer onto a different view, the animation was incorrectly applied to views that shouldn't be animated.

To fix the issue, we switched to removedOnCompletion=YES + fillMode=kCAFillModeBackwards, and commit toValue to the model in the same setDisableActions transaction as the addAnimation call. The model holds toValue throughout the animation's lifetime; once the animation auto-removes, the layer simply reads the model and there's no snap. Stale animations can no longer outlive their duration.

Example recording

Parts of the app were disappearing on each navigation to the screen in which just a single component was using a Core Animation

Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-05-22.at.21.12.12.mp4

Animations were created with removedOnCompletion=NO and
fillMode=kCAFillModeBoth, so once an opacity transition finished it
kept painting its toValue over the model layer forever. When RN later
recycled that layer onto a different view, the lingering animation
hid (or showed) the new view incorrectly - 'components that weren't
animated with core animation disappear'.

Switch to removedOnCompletion=YES + fillMode=kCAFillModeBackwards, and
commit toValue to the model in the same setDisableActions transaction
as the addAnimation: call. The model holds toValue throughout the
animation's lifetime; once the animation auto-removes, the layer
simply reads the model and there's no snap. Stale animations can no
longer outlive their duration.
@MatiPl01 MatiPl01 self-assigned this May 22, 2026
@MatiPl01 MatiPl01 changed the title Stop CA opacity transitions from leaking onto recycled layers fix: Stop CA opacity transitions from leaking onto recycled layers May 22, 2026
@MatiPl01 MatiPl01 changed the title fix: Stop CA opacity transitions from leaking onto recycled layers fix: Stop CA animations from leaking onto recycled layers May 22, 2026
@MatiPl01 MatiPl01 marked this pull request as ready for review May 22, 2026 19:09
@MatiPl01 MatiPl01 requested a review from tjzel May 22, 2026 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant