-
Notifications
You must be signed in to change notification settings - Fork 24.9k
feat: add listener for mount operations on Android #40738
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
feat: add listener for mount operations on Android #40738
Conversation
cc @cortinico if you could check the PR if the current direction is correct, or maybe cc someone that could help with merging it? |
Could you address the Circle CI failures here before the merge ? |
Base commit: c5258b5 |
@arushikesarwani94 all the checks are passing now 🚀 |
cc. @cortinico @arushikesarwani94 could one of you lead the landing of this? 🙏 |
cc @mdvacca also |
Did anyone have a chance to look at it? It would be perfect if it could land before 0.74 is cut. |
I created an internal task in our backlog. We are starting a periodical review of those pending tasks on Monday afternoon and Wednesday afternoon, so expect some answer by Tuesday, probably. I'm sorry that it is taking so long. :( |
/rebase |
Please when will this PR be merged |
@cortinico do you want me to rebase or does this comment does it automatically? |
@WoLewicki if you could rebase manually that would be really helpful. |
Ok I rebased, let me know if you have any info about it 🚀 |
Thanks for the work and for rebasing, I will take a look at it today or tomorrow. Two things that stand up:
|
Do you suggest some other approach? I'm not sure how could it be done differently.
I am aware that it is critical and I haven't noticed any immediate performance drops. I'm making small, short lived objects that keep the information for listeners and then are used for dispatching the mutations. As long as it is not introducing performance decrease, it should be fine. |
The initial implementation also relied on small short lived objects, but we've refactored the code this way because we found regressions on low end devices. I'm curious, how did you measure and confirmed there is no performance drop? We could try again, but we will need to refactor the code, add a feature flag and create an a/b testing to verify lack of performance regressions.
One approach is adding a method in UIManager and implement it inside FabricUIManager. |
mIntBuffer[i++] == 1); | ||
int reactTag = mIntBuffer[i++]; | ||
View view = null; | ||
if (surfaceMountingManager.getViewExists(reactTag)) { |
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.
Other than creating objects we are increasing cost of this method my resolving Views earlier just to share with the listener, but we are not reusing these views on the call to surfaceMountingManager below, again this method is part of the critical path, and this will bring unnecessary regressions
Just to provide a quick update here. @WoLewicki it would be really helpful if you can provide concrete examples of usages of this API. for example current usages of RCTMountingTransactionObserving where you are making usage of the MountingTransaction objects. or how would you use MountingTransaction objects in Android Thank you! cc @cortinico |
Tbh, I did not test it extensively, just in the example app for
As I mentioned in the description, it would be basically the same as on |
We are mostly interested to understand what information you need from the mountingTranstacion/mountItem, just the type and component name as you do in iOS? |
Yes, exactly. |
Not sure if some other libs would like to have more information, but for |
@WoLewicki thanks again for opening the discussion on exposing mount operations in Android and for implementing this PR We've discussed internally about this PR and we have several concerns to move forward with it:
I'm closing the PR because we decided that we won't add this API in React Native Android and we recommend overriding viewManager.removeViewAt() method instead. CC @cortinico , @javache , @cipolleschi , @sammy-SC |
yeah, we already use this mechanism on old arch: https://github.com/software-mansion/react-native-screens/blob/3b35894f1f83bc4c9daa518d68f3bcb0e832129a/android/src/main/java/com/swmansion/rnscreens/ScreenStackViewManager.kt#L33. The problem is the same as on |
Hey! I took another approach for getting the list of mutations that is unified between Could you elaborate if it is a proper solution? The only problem with it for now is that there can be only one delegate right now and |
Summary:
This PR introduces kind of the same API that is available on
iOS
for subscribing to view mutations (see https://github.com/facebook/react-native/blob/67384cf5a07662b5030c20cf666b0f10b402bf23/packages/react-native/React/Fabric/Mounting/RCTMountingTransactionObserving.h) but forAndroid
. The concept is needed there for e.g. fornative-stack
, with the same use case as oniOS
, where we want to know that the views will be removed to start transition on them, and we need to know it before they are removed (and it is done in a bottom-up manner on new arch).The current implementation uses
UIManagerModule
as the place where the listeners live, since it is possible to get to this module both from this code and from library's code. All the mutations are first added to an array, then the listeners are fired, and the changes are applied afterwards.Changelog:
[ANDROID] [ADDED] - Listener for view mutations
Test Plan:
Run the
RNTester
app and see that all mutations are still mounted correctly. Add subscriber and see that you can check the mutations and act based on them in other components before they are mounted.