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

com.facebook.react.ReactRootView instance Leaking(View.mContext references a destoryed activity) #42391

Closed
EliottG-Bam opened this issue Jan 19, 2024 · 4 comments
Labels
Needs: Author Feedback Needs: Triage 🔍 Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@EliottG-Bam
Copy link

EliottG-Bam commented Jan 19, 2024

Description

Memory Leak detected by Leak Canary
com.facebook.react.ReactRootView instance Leaking(View.mContext references a destroyed activity)

Screenshot_2024-01-19-15-39-54-092_com tf1 mobilenews staging debug

See those 2 old & closed issues:
#34192
#34364

Steps to reproduce

https://github.com/EliottG-Bam/repro

A memory leak will be detected after running this project on Android for a few minutes

this project only one page, just run on android , leakcanary-android help detected

Snack, code example, screenshot, or link to a repository
https://github.com/EliottG-Bam/repro

React Native Version

0.73.2

Affected Platforms

Runtime - Android

Output of npx react-native info

System:
  OS: macOS 14.2.1
  CPU: (8) arm64 Apple M1
  Memory: 116.92 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.10.0
    path: ~/Library/Caches/fnm_multishells/14607_1705653699716/bin/node
  Yarn:
    version: 1.22.19
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.2.3
    path: ~/Library/Caches/fnm_multishells/14607_1705653699716/bin/npm
  Watchman:
    version: 2023.09.04.00
    path: /usr/local/bin/watchman
Managers:
  CocoaPods:
    version: 1.13.0
    path: /Users/eliottg/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - visionOS 1.0
      - watchOS 10.2
  Android SDK:
    API Levels:
      - "31"
      - "33"
      - "34"
    Build Tools:
      - 30.0.3
      - 33.0.0
      - 33.0.1
      - 34.0.0
    System Images:
      - android-29 | Google APIs ARM 64 v8a
      - android-30 | Google APIs ARM 64 v8a
      - android-31 | Google APIs ARM 64 v8a
      - android-33 | Google APIs ARM 64 v8a
      - android-34 | Google APIs ARM 64 v8a
      - android-34 | Google Play ARM 64 v8a
      - android-UpsideDownCake-ext5 | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2022.3 AI-223.8836.35.2231.11090377
  Xcode:
    version: 15.2/15C500b
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.9
    path: /usr/bin/javac
  Ruby:
    version: 3.1.0
    path: /Users/eliottg/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.2
    wanted: 0.73.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Stacktrace or Logs

┬───
│ GC Root: Global variable in native code
│
├─ com.swmansion.reanimated.NativeProxy instance
│    Leaking: UNKNOWN
│    Retaining 246 B in 9 objects
│    ↓ NativeProxyCommon.mNodesManager
│                        ~~~~~~~~~~~~~
├─ com.swmansion.reanimated.NodesManager instance
│    Leaking: UNKNOWN
│    Retaining 10.8 kB in 368 objects
│    mContext instance of com.facebook.react.bridge.ReactApplicationContext,
│    wrapping com.mobilenews.MainApplication
│    mReactApplicationContext instance of com.facebook.react.bridge.
│    ReactApplicationContext, wrapping com.mobilenews.MainApplication
│    ↓ NodesManager.mAnimationManager
│                   ~~~~~~~~~~~~~~~~~
├─ com.swmansion.reanimated.layoutReanimation.AnimationsManager instance
│    Leaking: UNKNOWN
│    Retaining 897 B in 28 objects
│    mContext instance of com.facebook.react.bridge.ReactApplicationContext,
│    wrapping com.mobilenews.MainApplication
│    ↓ AnimationsManager.mReanimatedNativeHierarchyManager
│                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
├─ com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager
│  instance
│    Leaking: UNKNOWN
│    Retaining 910.8 kB in 15098 objects
│    ↓ NativeViewHierarchyManager.mTagsToViews
│                                 ~~~~~~~~~~~~
├─ android.util.SparseArray instance
│    Leaking: UNKNOWN
│    Retaining 897.8 kB in 15072 objects
│    ↓ SparseArray.mValues
│                  ~~~~~~~
├─ java.lang.Object[] array
│    Leaking: UNKNOWN
│    Retaining 891.6 kB in 15070 objects
│    ↓ Object[5]
│            ~~~
├─ com.facebook.react.ReactRootView instance
│    Leaking: YES (View.mContext references a destroyed activity)
│    Retaining 1.6 kB in 32 objects
│    View is part of a window view hierarchy
│    View.mAttachInfo is null (view detached)
│    View.mWindowAttachCount = 1
│    mContext instance of com.mobilenews.MainActivity with mDestroyed = true
│    ↓ View.mContext
╰→ com.mobilenews.MainActivity instance
​     Leaking: YES (ObjectWatcher was watching this because com.mobilenews.
​     MainActivity received Activity#onDestroy() callback and
​     Activity#mDestroyed is true)
​     Retaining 15.2 kB in 341 objects
​     key = cb468639-7138-49c8-a25f-b9faed8582e0
​     watchDurationMillis = 6082
​     retainedDurationMillis = 1079
​     mApplication instance of com.mobilenews.MainApplication
​     mEmbeddedApplication instance of com.mobilenews.MainApplication
​     mBase instance of androidx.appcompat.view.ContextThemeWrapper

METADATA

Build.VERSION.SDK_INT: 33
Build.MANUFACTURER: Xiaomi
LeakCanary version: 3.0-alpha-1
App process name: com.tf1.mobilenews.staging.debug
Class count: 42354
Instance count: 830458
Primitive array count: 332418
Object array count: 131667
Thread count: 219
Heap total bytes: 82241440
Bitmap count: 205
Bitmap total bytes: 67885349
Large bitmap count: 0
Large bitmap total bytes: 0
Db 1: open /data/user/0/com.tf1.mobilenews.staging.debug/no_backup/androidx.
work.workdb
Db 2: open /data/user/0/com.tf1.mobilenews.staging.debug/databases/ba_tr.db
Db 3: open /data/user/0/com.tf1.mobilenews.staging.debug/databases/com.google.
android.datatransport.events
Db 4: open /data/user/0/com.tf1.mobilenews.staging.debug/databases/RKStorage
Db 5: open /data/user/0/com.tf1.mobilenews.staging.debug/databases/leaks.db
Db 6: open /data/user/0/com.tf1.mobilenews.staging.
debug/databases/ba_user_profile.db
Count of retained yet cleared: 5 KeyedWeakReference instances
Stats: LruCache[maxSize=3000,hits=396971,misses=839553,hitRate=32%]
RandomAccess[bytes=55355884,reads=839553,travel=541831612629,range=98114713,size
=113645670]
Analysis duration: 69700 ms

Reproducer

https://github.com/EliottG-Bam/repro

Screenshots and Videos

No response

@github-actions github-actions bot added Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. and removed Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. labels Jan 19, 2024
Copy link

This issue is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Feb 13, 2024
Copy link

This issue was closed because it has been stalled for 7 days with no activity.

@chanphiromsok
Copy link

+1

@dlebedynskyi
Copy link

+1 issue seems to be repo on our app as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Author Feedback Needs: Triage 🔍 Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

3 participants