Images fail to render after a certain number are added to the page [Android, RN 0.36]
See original GitHub issueDescription
I’ve written a simple RN app that displays a large number of images in a horizontal scroll view. After a certain number of images, they being to stop loading.
Reproduction
See code below, I’ve reproduced this on an android device, but it doesn’t reproduce on iOS simulator. I haven’t tried an iOS device or an Android simulator. Run the app and notice images stop loading about half way through the scroll view. See:
import React from "react";
import {
AppRegistry,
Image,
ScrollView,
StyleSheet,
Text,
TouchableHighlight,
View
} from "react-native";
AppRegistry.registerComponent("AwesomeProject", () =>
React.createClass({
render() {
var imageMap = [
"https://avatars2.githubusercontent.com/u/22461323",
// ...
// More Images as necessary, I needed ~ 200 to trigger the issue
"https://avatars2.githubusercontent.com/u/22461323"
];
return (
<View>
<Text>Lots of Images</Text>
<ScrollView
horizontal={true}
automaticallyAdjustContentInsets={false}
directionalLockEnabled={true}>
{imageMap.map((imageUri, i) =>
<View key={i}>
<TouchableHighlight key={i}>
<Image style={styles.image} source={{ uri: imageUri }} key={i}/>
</TouchableHighlight>
</View>
)}
</ScrollView>
</View>
);
}
})
);
const styles = StyleSheet.create({
image: {
width: 150,
height: 150,
marginHorizontal: 20,
resizeMode: "contain"
}
});
Additional Information
*If I load the same number of images in a webview, I don’t run into the issue. So I think the issue is specific to the React Image component logic leaking memory and not just “Your app has too many images”
- React Native version: 0.36
- Platform: Android
- Operating System: MacOS
Issue Analytics
- State:
- Created 7 years ago
- Reactions:13
- Comments:34 (4 by maintainers)
Top Results From Across the Web
Images fail to render after a certain number are added to the ...
I've written a simple RN app that displays a large number of images in a horizontal scroll view. After a certain number of...
Read more >React Native Image not showing, How do i fix? - Stack Overflow
x it is an issue being generated that image is not being shown. Here is some info against that. It can display the...
Read more >VMware Workspace ONE UEM™ Powered by AirWatch 2203 ...
CMCM-189509: Unable to access device details page for all Android devices. CMEM-186566: Devices are getting blocked when turning on DX Mod.
Read more >Troubleshooting | React Navigation
I'm getting an error "Unable to resolve module" after updating to the latest version ... Nothing is visible on the screen after adding...
Read more >Assessing the Theory and Practice of Criminal Sentencing
Figure 1-2 Number of Prison Sentences by Offense Type, 1980-1999. 600,OOo ... The attention given to judicial sentencing should be understood as a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
removeClippedSubviews={true}
resolved this issue for me, thanks @oprisnik. (RN 0.41)I guess something is holding on to the images so that they are kept in memory. Maybe view recycling doesn’t work correctly for the
ScrollView
? Can you try addingremoveClippedSubviews={true}
to theScrollView
? cc @foghina