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

Wrong initial state using useNativeDriver: true and production bundle #16003

Closed
ferrannp opened this issue Sep 19, 2017 · 6 comments
Closed

Wrong initial state using useNativeDriver: true and production bundle #16003

ferrannp opened this issue Sep 19, 2017 · 6 comments
Assignees
Labels
Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@ferrannp
Copy link
Contributor

Is this a bug report?

Yes.

Have you read the Contributing Guidelines?

Yes.

Environment

  1. react-native -v: 0.48.3
  2. node -v: 8.4.0
  3. npm -v: 5.4.2
  4. yarn --version: 1.0.2

Then, specify:

  • Target Platform: Android O

  • Development Operating System: macOS

Steps to Reproduce

  1. Use onScroll event on FlatList
onScroll={Animated.event(
  [{ nativeEvent: { contentOffset: { y: scrollY } } }],
  { useNativeDriver: true }
)}
  1. Use the value for some interpolations:
const imageTranslate = scrollY.interpolate({
  inputRange: [0, bannerHeight],
  outputRange: [0, -bannerHeight],
  extrapolate: 'clamp',
});

const opacityInterpolator = scrollY.interpolate({
  inputRange: [bannerHeight-56-24-24, bannerHeight-56-24],
  outputRange: [0, 1],
  extrapolate: 'clamp',
});

const fontScale = scrollY.interpolate({
  inputRange: [0.0, bannerHeight-56-24],
  outputRange: [1.5, 1.0],
  extrapolate: 'clamp',
});

const fontTranslateX = scrollY.interpolate({
  inputRange: [0, bannerHeight-56-24],
  outputRange: [0, -24],
  extrapolate: 'clamp',
});

const fontTranslateY = scrollY.interpolate({
  inputRange: [0, bannerHeight - 56 - 24],
  outputRange: [0, -bannerHeight + 56 + 24],
  extrapolate: 'clamp',
});
  1. Apply them to Animated.View and Animated.Text. With state scrollY: new Animated.Value(0), the View should have 0 opacity and the text should be big (initial state).

Expected Behavior

See gif:

expected

Actual Behavior

actual

The issue happens only in production and in my real device (Nexus 5X) which is now using Android O. I cannot reproduce it in Genymotion. Initial state is wrong and it goes ok just when touching and scrolling a bit.

Temporal solution

this.state = {
  scrollY: new Animated.Value(0),
  useNativeDriver: true,
};

componentDidMount() {
  setTimeout(() => this.setState({ useNativeDriver: true }), 10);
}
@satya164
Copy link
Contributor

cc @janicduplessis

@janicduplessis janicduplessis self-assigned this Sep 22, 2017
@janicduplessis janicduplessis added Animated Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. labels Sep 22, 2017
@ferrannp
Copy link
Contributor Author

Temporal solution does not really work always. At some point, if I click something in the list, the bug reappears.

@janicduplessis
Copy link
Contributor

I'm not sure if it is the issue but could you try with this PR #15919?

@ferrannp
Copy link
Contributor Author

ferrannp commented Sep 26, 2017

Ok, gonna try that and let you know.

@janicduplessis I am having a hard time building my app using your PR. I followed all the instructions http://facebook.github.io/react-native/docs/android-building-from-source.html but I am having problems with external dependencies (had to disable some).

But basically, I have Realm. The app builds and works in dev but I get errors in prod... Not sure if there is some compatibility issue. So maybe I need to set up a totally new repo without external third party modules.

Anyway, maybe there is a place (Slack) we can chat? I could use some help.

@janicduplessis
Copy link
Contributor

@ferrannp Hmm I'm not sure what could cause the issue in prod only. I'm around on the Expo slack if you want to give me more info I can try to help.

@stale
Copy link

stale bot commented Nov 28, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Nov 28, 2017
@stale stale bot closed this as completed Dec 5, 2017
@facebook facebook locked and limited conversation to collaborators May 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

3 participants