-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Native Animated - Restore default values when removing props on Android #12842
Native Animated - Restore default values when removing props on Android #12842
Conversation
6203dcb
to
ffc8b92
Compare
Hi Janic, do you know who can review changes to native animated on Android? |
Replied on slack |
@@ -181,6 +182,11 @@ private void enqueueFrameCallback() { | |||
mAnimatedFrameCallback); | |||
} | |||
|
|||
@VisibleForTesting | |||
public void setNodesManager(NativeAnimatedNodesManager nodesManager) { |
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.
Not sure if there is a better way to do this, we have to inject a mock in here but there is no way currently. I tried using PowerMockito.whenNew
but could not get it to work.
InOrder inOrder = inOrder(mNodeManager, otherBlock); | ||
inOrder.verify(mNodeManager, times(1)).disconnectAnimatedNodeFromView(1, 1000); | ||
inOrder.verify(otherBlock, times(1)).execute(any(NativeViewHierarchyManager.class)); | ||
} |
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.
Ideally we'd also test multithreading here to make sure everything gets called on the proper thread and is safe but I'm not sure how to do that.
Also added a regression test and a few extra tests around the scheduling of NativeAnimatedNodesManager operations. |
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.
Sorry for the delayed review. Is there someone on the React or RN team that you think should review this? I can reach out to them.
|
||
private @Nullable NativeAnimatedNodesManager mNodesManager; | ||
|
||
public NativeAnimatedModule(ReactApplicationContext reactContext) { | ||
super(reactContext); | ||
|
||
mReactChoreographer = ReactChoreographer.getInstance(); | ||
mAnimatedFrameCallback = new GuardedFrameCallback(reactContext) { | ||
mAnimatedFrameCallback = new GuardedFrameCallback(reactCtx) { |
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.
Is reactCtx
defined at this point?
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.
You are right, I messed that up when fixing conflicts.
@@ -139,24 +128,30 @@ public void onHostResume() { | |||
} | |||
|
|||
@Override | |||
public void onBatchComplete() { |
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.
Was this method used anywhere?
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.
This is a method native modules can override that gets called when batches are completed so it is fine to remove it since it will just call the one from the super class.
@AaaChiuuu or Andrew Chen could review this |
@hramos Could you try to have this reviewed? |
0ede136
to
f6b3f7f
Compare
Just pinged @AaaChiuuu |
f6b3f7f
to
5fbf352
Compare
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.
Approving this without any further review as it has been a while since the review was requested, and Janic has already been using this in production for a while. I don't want to slow down contributions from the core team unnecessarily.
@hramos has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
I tried to merge this pull request into the Facebook internal repo but some checks failed. To unblock yourself please check the following: Does this pull request pass all open source tests on GitHub? If not please fix those. Does the code still apply cleanly on top of GitHub master? If not can please rebase. In all other cases this means some internal test failed, for example a part of a fb app won't work with this pull request. I've added the Import Failed label to this pull request so it is easy for someone at fb to find the pull request and check what failed. If you don't see anyone comment in a few days feel free to comment mentioning one of the core contributors to the project so they get a notification. |
This PR has been submitted by a core contributor. Attention: @janicduplessis Generated by 🚫 dangerJS |
@hramos Oups, there was a buck build issue and a test I forgot to update, circle is green now it should land smoothly. |
@hramos has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
ac43548 is in the process of being reverted. The NativeAnimatedModuleTest started failing when this landed:
At this point I am not yet sure why this is breaking internally, when the PR passed tests. Tests also passed on master after this landed. |
@hramos Strange that it doesn't fail on OSS CI, is it possible that you are using a different version of mockito internally? According to OSS gradle.properties (https://github.com/facebook/react-native/blob/master/ReactAndroid/gradle.properties#L10) we are using version 1.10.19, same with buck https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/third-party/java/mockito/BUCK#L19. |
Same as #11819 but for Android. I didn't notice the bug initially in my app because I was using different animations on Android which did not trigger this issue.
Test plan
Created a simple repro example and tested that this fixes it. https://gist.github.com/janicduplessis/0f3eb362dae63fedf99a0d3ee041796a