Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LayoutAnimationController [sometimes] leaks memory #49958

Open
knappam opened this issue Mar 11, 2025 · 3 comments
Open

LayoutAnimationController [sometimes] leaks memory #49958

knappam opened this issue Mar 11, 2025 · 3 comments
Labels
API: LayoutAnimation Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue.

Comments

@knappam
Copy link
Contributor

knappam commented Mar 11, 2025

Description

Android's onAnimationEnd callback is lossy and ocasionally just does not fire. However the LayoutAnimationController maintains a sparse array of animations (with Strong View refs) that is only cleaned when the onAnimationEnd callback is invoked. This results in a leak of Android View objects over time.

Steps to reproduce

  1. Write an RN application that uses LayoutAnimations (alot)
  2. Collect heap dumps and note the Views that should have been GCed are being held by the mkLayoutHanders field in LayoutAnimationController.java

React Native Version

0.78.0

Affected Platforms

Runtime - Android

Output of npx @react-native-community/cli info

System:
  OS: Linux 6.11 Ubuntu 24.04.2 LTS 24.04.2 LTS (Noble Numbat)
  CPU: (32) x64 AMD Ryzen 9 9950X 16-Core Processor
  Memory: 33.39 GB / 60.45 GB
  Shell:
    version: 5.2.21
    path: /bin/bash
Binaries:
  Node:
    version: 23.2.0
    path: ~/.nvm/versions/node/v23.2.0/bin/node
  Yarn:
    version: 1.22.22
    path: ~/.nvm/versions/node/v23.2.0/bin/yarn
  npm:
    version: 10.9.0
    path: ~/.nvm/versions/node/v23.2.0/bin/npm
  Watchman: Not Found
SDKs:
  Android SDK:
    API Levels:
      - "24"
      - "28"
      - "33"
      - "34"
      - "35"
    Build Tools:
      - 28.0.3
      - 30.0.3
      - 34.0.0
      - 35.0.0
    System Images:
      - android-35 | Google Play Intel x86_64 Atom
    Android NDK: Not Found
IDEs:
  Android Studio: Not Found
Languages:
  Java:
    version: 21.0.5
    path: /usr/bin/javac
  Ruby:
    version: 3.2.3
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 19.0.0
  react-native: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Stacktrace or Logs

Cannot share the heap dumps

Reproducer

n/a

Screenshots and Videos

Image

@react-native-bot react-native-bot added API: LayoutAnimation Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. labels Mar 11, 2025
@react-native-bot
Copy link
Collaborator

Warning

Missing reproducer: We could not detect a reproducible example in your issue report. Please provide either:

@devanshsaini11
Copy link
Collaborator

Hi @knappam can u please provide a repro so it can be validated quickly

@cipolleschi
Copy link
Contributor

cipolleschi commented Mar 12, 2025

@cortinico possible fix in #49959

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API: LayoutAnimation Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue.
Projects
None yet
Development

No branches or pull requests

4 participants