Comments (3)
Missing Reproducible Example | |
---|---|
âšī¸ | We could not detect a reproducible example in your issue report. Please provide either:
|
from react-native.
There is a memory leak in the dialog management code of React Native's new architecture. When the hide() method is called and the dialog is not currently showing, the ReactRootView is not removed from the view tree. This results in the ReactRootView holding a reference to the Activity, causing a memory leak.
Can you provide a valid repro an a screenshot from the memory profiler of Android Studio?
from react-native.
First, in my issue, I provided the memory leak path captured by LeakCanary. When looking at the code, this issue becomes very clear: Regardless of the state of the Dialog, mReactRootView
will always be indirectly created and held by LogModule
, and when ReactRootView
is created, it holds a reference to the Activity
. Therefore, the hide
method of LogBoxDialogSurfaceDelegate
must ensure that it is removed from the Activity
. However, the current implementation of the hide
method does not do this. When the dialog is not created or shown, it directly returns, causing the view to not release the Activity
reference, which leads to a memory leak.
To reproduce this issue is very simple. You just need to start by creating a Native Activity
in the React Native Android template project, then navigate to a ReactActivity
, and finally return to the main Activity
from the ReactActivity
. This will reliably reproduce the memory leak. Additionally, this reproduction path may also uncover other memory leaks under the new architecture. I suggest conducting similar tests as soon as possible and fixing the related issues.
My local fix code like this:
@Override
public void hide() {
if (isShowing()) {
mDialog.dismiss();
}
if (mReactRootView != null && mReactRootView.getParent() != null) {
((ViewGroup) mReactRootView.getParent()).removeView(mReactRootView);
}
mDialog = null;
}
from react-native.
Related Issues (20)
- AppState 'change' fires redundant 'active' when app is already active the first time the listener is added on Android iOS Prod HOT 3
- Build failure in Fabric when implementing custom Shadow Node with Swift integration
- build error HOT 3
- Strange Issue with PagerView/Image in a Full Screen Overlay (iOS only) HOT 3
- TextInput menu is not hidden even contextMenuHidden is true on Android HOT 2
- onEndReached does not trigger even though onEndReachedThreshold is set HOT 2
- [iOS] Hash Generated Using Broken Cryptography API (SHA1) HOT 3
- Failed to generate podfile.lock HOT 4
- RN Alert button sometimes renders in the upper-left corner of the screen (iOS)
- [0.76.0 (nightly)] `react-native` command fails silently HOT 1
- Accessibility in android- With talkback elements are not clickable while on a screen from stack navigator. HOT 6
- PermissionsModule$1.invoke java.lang.IllegalArgumentException - Unknown permission: android.permission.POST_NOTIFICATIONS HOT 3
- React Native app works fine on ios but Axios network request in android not working HOT 6
- Modal is getting truncated when rendering at bottom on Android 15 HOT 4
- Dimensions.addEventListener not firing react native 0.74.3 HOT 6
- Inspector Tools issue when view are transformed in Fabric
- React Native Android fails with Desugaring enabled HOT 6
- The onChangeText and onChange events on a TextInput fire twice on Android HOT 8
- Android - Composer - Previous text is cut off after creating next line HOT 5
- [0.75.0-rc.5] Android crashes at app launch on New Architecture HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
đ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. đđđ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google â¤ī¸ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native.