-
-
Notifications
You must be signed in to change notification settings - Fork 600
fix: remove javapart ref from cpp nativeproxy #2934
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
Conversation
tjzel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but make sure that RNScreens doesn't actually try to use anything from javaPart_ once it was nulled.
In the case of Reanimated and Worklets some (concurrent) code always expected that it's not nulled.
|
But isn't it prohibited behavior for the code to run anything after |
|
It is prohibited - but the question is, if it's actually respected. For instance, in Worklets and Reanimated we have to make sure that other threads do gracefully abort when |
kkafar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me.
Regarding what @tjzel has said: we should be safe on that front, because:
- the lifecycle of a native proxy is tied & bound by lifecycle of
RNScreensModule, which in turn is managed by React, - If React calls our
RNSScreenRemovalListenerafter the screen module has been invalidated it would mean that something went seriously wrong - am I right here @WoLewicki? Or is it possible for native modules to be invalidated && before the view hierarchy is torn down?
|
|
||
| external fun nativeAddMutationsListener(fabricUIManager: FabricUIManager) | ||
|
|
||
| external fun invalidateCpp() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have native proxy, native methods in Java, we use Java Native interface => let's call it invalidateNativePart or invalidateNative.
Haven't seen it be a case in the in the apps I worked on so hopefully there is no way. I think it would lead to other problems then anyway 🤷♂️ |
kkafar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can proceed then
Description
PR analogous to software-mansion/react-native-reanimated#7515 regarding the
javaPart_.Right now when you do a reload in a simple app with screens installed, you will see in AS profiler that instances of all NativeProxys are still in the memory. It is caused by
javaPart_never being released thus keeping java part after reload.I also removed empty destructor of
NativeProxy.Test code and steps to reproduce
Make simple app with screens and do a couple of reloads and check in profiler if the NativeProxy leaks.