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

Native Animated - Restore default values when removing props on Android #12842

Conversation

janicduplessis
Copy link
Contributor

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

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. GH Review: review-needed labels Mar 10, 2017
@janicduplessis janicduplessis force-pushed the native-animated-default-values-android branch from 6203dcb to ffc8b92 Compare March 10, 2017 02:04
@mkonicek
Copy link
Contributor

Hi Janic, do you know who can review changes to native animated on Android?

@janicduplessis
Copy link
Contributor Author

Replied on slack

@@ -181,6 +182,11 @@ private void enqueueFrameCallback() {
mAnimatedFrameCallback);
}

@VisibleForTesting
public void setNodesManager(NativeAnimatedNodesManager nodesManager) {
Copy link
Contributor Author

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));
}
Copy link
Contributor Author

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.

@janicduplessis
Copy link
Contributor Author

Also added a regression test and a few extra tests around the scheduling of NativeAnimatedNodesManager operations.

Copy link
Contributor

@hramos hramos left a 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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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() {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@janicduplessis
Copy link
Contributor Author

@AaaChiuuu or Andrew Chen could review this

@janicduplessis
Copy link
Contributor Author

@hramos Could you try to have this reviewed?

@janicduplessis janicduplessis force-pushed the native-animated-default-values-android branch from 0ede136 to f6b3f7f Compare May 26, 2017 21:33
@hramos
Copy link
Contributor

hramos commented May 26, 2017

Just pinged @AaaChiuuu

@janicduplessis janicduplessis force-pushed the native-animated-default-values-android branch from f6b3f7f to 5fbf352 Compare June 28, 2017 05:29
Copy link
Contributor

@hramos hramos left a 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.

@facebook-github-bot facebook-github-bot added GH Review: accepted Import Started This pull request has been imported. This does not imply the PR has been approved. and removed GH Review: review-needed labels Aug 3, 2017
@facebook-github-bot
Copy link
Contributor

@hramos has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot facebook-github-bot added Import Failed and removed Import Started This pull request has been imported. This does not imply the PR has been approved. labels Aug 4, 2017
@facebook-github-bot
Copy link
Contributor

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.

@pull-bot
Copy link

pull-bot commented Aug 4, 2017

This PR has been submitted by a core contributor.

Attention: @janicduplessis

Generated by 🚫 dangerJS

@janicduplessis
Copy link
Contributor Author

@hramos Oups, there was a buck build issue and a test I forgot to update, circle is green now it should land smoothly.

@facebook-github-bot facebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Aug 4, 2017
@facebook-github-bot
Copy link
Contributor

@hramos has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@hramos
Copy link
Contributor

hramos commented Aug 4, 2017

ac43548 is in the process of being reverted. The NativeAnimatedModuleTest started failing when this landed:

javac_jar
stderr: ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedModuleTest.java:67: error: cannot find symbol
        mUIBlocks.add(invocation.getArgumentAt(0, UIBlock.class));
                                ^
  symbol:   method getArgumentAt(int,java.lang.Class<com.facebook.react.uimanager.UIBlock>)
  location: variable invocation of type org.mockito.invocation.InvocationOnMock

ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedModuleTest.java:74: error: cannot find symbol
        mUIBlocks.add(0, invocation.getArgumentAt(0, UIBlock.class));
                                   ^
  symbol:   method getArgumentAt(int,java.lang.Class<com.facebook.react.uimanager.UIBlock>)
  location: variable invocation of type org.mockito.invocation.InvocationOnMock
Errors: 2. Warnings: 0.

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.

@janicduplessis
Copy link
Contributor Author

janicduplessis commented Aug 4, 2017

@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.

facebook-github-bot pushed a commit that referenced this pull request Oct 12, 2017
Summary:
Rebased version of #12842 that was reverted because of failing fb internal tests.
Closes #15919

Differential Revision: D5823956

Pulled By: hramos

fbshipit-source-id: 4ece19a403f5ebbe4829c4c26696ea0575ab1d0e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Import Started This pull request has been imported. This does not imply the PR has been approved.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants