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

Android not showing all local images in carousel #371

Closed
StuartMorris0 opened this issue Aug 10, 2018 · 7 comments
Closed

Android not showing all local images in carousel #371

StuartMorris0 opened this issue Aug 10, 2018 · 7 comments

Comments

@StuartMorris0
Copy link

StuartMorris0 commented Aug 10, 2018

Is this a bug report, a feature request, or a question?

Bug Report/Question

Have you followed the required steps before opening a bug report?

(Check the step you've followed - replace the space character between the square brackets ([]) by an x.)

Have you made sure that it wasn't a React Native bug?

Yes, unsure.

Is the bug specific to iOS or Android? Or can it be reproduced on both platforms?

Android, any version. Release or Debug build reproducible

Is the bug reproductible in a production environment (not a debug one)?

Both.

Environment

react-native-cli: 2.0.1
react-native: 0.55.3
react-native-snap-carousel 4.6.1

Expected Behavior

Show all images in the carousel

Actual Behavior

The issue occurs for items further down the carousel. The first 20 items might show fine, then random ones will not show the image.

Steps to Reproduce

This is an example of our Carousel setup. Please note, I have tried different options with the removeClippedSubviews and the initialNumToRender and useScrollView props to no avail.

export default class GameTypeCarousel extends React.Component<*> {
  render() {
    return (
      <Carousel
        ref={this.props.reference}
        data={ENTRIES}
        renderItem={this.renderItem}
        sliderWidth={viewportWidth}
        itemWidth={itemWidth}
        removeClippedSubviews={false}
        enableMomentum
        initialNumToRender={1}
      />
    );
  }

  renderItem({ item, index }) {
    return (
      <GameTypeEntry data={item} index={index} />
    );
  }
}

The actual entry is simple text and image.
`export default class GameTypeEntry extends Component {
static propTypes = {
data: PropTypes.object.isRequired,
};

renderImage () {
  if (this.props.data.title === "Default") {
    return (
      <Image source={DefaultImage} style={styles.imageStyle} resizeMode="contain" resizeMethod="resize" />
    );
  }
  if (this.props.data.title === "Baseball") {
    return (
      <Image source={BaseballImage} style={styles.imageStyle} resizeMode="contain" resizeMethod="resize" />
    );
  }
  return (
    <Image source={DefaultImage} style={styles.imageStyle} resizeMode="contain" resizeMethod="resize" />
  );
}

render () {
  return (
    <View style={styles.slide}>
      { this.renderImage() }
      <Text style={styles.title}>{ this.props.data.title }</Text>
    </View>
  );
}

}`

What we find is that random indexed items in the carousel will not show the image. Even though with the above setup most will be using the same default image. So we know the image is there and it works for other slides (so to speak). It just doesn't show for all.

I've read the performance notes on Android. I'm not sure about the note on 'Implement shouldComponentUpdate' wether that would help or where that even needs to be implemented. Checking the examples I cannot see it anywhere.

@evert-smit
Copy link

Do your images or image containers (the ones where nothing shows up) show a loading indicator?

@StuartMorris0
Copy link
Author

No loading indicator. Note these images are local and so we use Source not uri for them.

@wachidyulio
Copy link

Have same problem here

@bd-arc
Copy link
Contributor

bd-arc commented Aug 13, 2018

@StuartMorris0 I haven't been able to reproduce the issue so far. It would really help if you could provide me with a Snack example.

Also, here are two things to check:

  1. Can you try setting the inherited prop initialNumToRender to something like 50 and see if this has any kind of effect?
  2. Can you reproduce the issue if you use remote images only?

@bd-arc
Copy link
Contributor

bd-arc commented Aug 21, 2018

@StuartMorris0 @wachidyulio Did you have time to try what I've previously suggested?

@StuartMorris0
Copy link
Author

I was able to resolve the issue in the end.

I used a flatlist and was able to reproduce the issue. The issue seemed to be because we were using large images at 1600x1600. The issue only occurred on Android devices and not emulators.

We tried the large heap change too to no avail. Making the images smaller worked out the issue for us with flatlist, so at a guess it will be the same issue here. We moved away from this package in the end, but it might help someone in the future.

Using the scrolllist variable for this package made no difference in our issue either. Thanks

@bd-arc
Copy link
Contributor

bd-arc commented Aug 21, 2018

Thanks a lot for the feedback @StuartMorris0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants