question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android not showing all local images in carousel

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
StuartMorris0commented, Aug 21, 2018

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

0reactions
bd-arccommented, Aug 21, 2018

Thanks a lot for the feedback @StuartMorris0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android not showing all local images in carousel #371 - GitHub
The issue occurs for items further down the carousel. The first 20 items might show fine, then random ones will not show the...
Read more >
React Native: Android is not showing all images (even though ...
There is a known Android issue with dissapearing images in React Native. Try to remove the resizeMode prop altogether from your image and...
Read more >
Why don't the Homepage Carousel images display properly?
The Homepage Carousel images aren't displaying at all. ... You have uploaded images to your Homepage Carousel, but they are not displaying on...
Read more >
Carousel - OutSystems 11 Documentation
The Carousel Pattern optimizes screen space by displaying only a few images from a larger collection which you can view using the navigation ......
Read more >
Displaying Images with the Glide Library - CodePath Cliffnotes
If an image or set of images aren't loading, make sure to check the Android monitor log in Android Studio. There's a good...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found