fix: collect orphaned AnimatedPropsRegistry entry on last animated view unmount#9730
Open
MatiPl01 wants to merge 2 commits into
Open
fix: collect orphaned AnimatedPropsRegistry entry on last animated view unmount#9730MatiPl01 wants to merge 2 commits into
MatiPl01 wants to merge 2 commits into
Conversation
…mount An in-flight worklet frame can re-add an unmounting view's props after handleNodeRemovals drained the tag. With no animated views left the props GC interval has stopped and no further commit drains it, so the entry leaks. Clear the orphaned registry one UI frame after the last view unmounts, and switch the GC view counter to viewsMap.size (the old counter drifted negative for nested AnimatedComponents sharing a viewTag).
2b4d93f to
9b20b33
Compare
tomekzaw
reviewed
Jun 22, 2026
Comment on lines
+77
to
+81
| scheduleOnUI(() => { | ||
| 'worklet'; | ||
| requestAnimationFrame(() => { | ||
| 'worklet'; | ||
| scheduleOnRN(removeOrphanedProps); |
Member
There was a problem hiding this comment.
Looks a bit hacky (scheduleOnUI -> requestAnimationFrame -> scheduleOnRN), it might be flaky
Collaborator
There was a problem hiding this comment.
+1, what exactly are you trying to achieve here? Maybe you can just do setTimeout with some heuristic delay?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the last animated view unmounts mid-animation, an in-flight worklet frame can re-add its props to
AnimatedPropsRegistryafterhandleNodeRemovalsalready drained the tag. The props GC interval has stopped by then (no animated views left) and no further commit drains it, so the entry leaks permanently.This clears the now fully-orphaned registry one UI frame after the last animated view unmounts (
scheduleOnUI->requestAnimationFrame->scheduleOnRN), so the late re-add is collected without relying on a further Fabric commit. It also switches the GC view counter toviewsMap.size- the oldviewsCountcould drift negative for nested AnimatedComponents that share a viewTag, which would skip the cleanup.Verified on Android (new arch) with the FreezeExample leak meter: the same repro that leaves
AnimatedPropsRegistryleaked onmainreports it clean with this change.