Skip to content

Commit

Permalink
Fix AnimatedEvent leaking topScrollEnded handler (#46576)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #46576

We automatically add this handler in `addAnimatedEventToView` but we do not remove it in `removeAnimatedEventFromView`, which causes us to leak it. This is especially bad as we attach and detach the event handler multiple times while rendering.

Changelog: [Internal]

Reviewed By: tdn120

Differential Revision: D63029768

fbshipit-source-id: 9ef2bc6887fecb7ab448af4dee94463f8be27768
  • Loading branch information
javache authored and facebook-github-bot committed Sep 19, 2024
1 parent 052def0 commit 5f49e27
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,6 @@ public void addAnimatedEventToView(
@UiThread
public void removeAnimatedEventFromView(
int viewTag, String eventHandlerName, int animatedValueTag) {

String eventName = normalizeEventName(eventHandlerName);

ListIterator<EventAnimationDriver> it = mEventDrivers.listIterator();
Expand All @@ -569,6 +568,11 @@ public void removeAnimatedEventFromView(
break;
}
}

if (eventName.equals("topScroll")) {
// Handle the custom topScrollEnded event sent by the ScrollViews when the user stops dragging
removeAnimatedEventFromView(viewTag, "topScrollEnded", animatedValueTag);
}
}

@Override
Expand Down

0 comments on commit 5f49e27

Please sign in to comment.