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.

Images fail to render after a certain number are added to the page [Android, RN 0.36]

See original GitHub issue

Description

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: screenshot_2016-10-26-18-10-11

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:closed
  • Created 7 years ago
  • Reactions:13
  • Comments:34 (4 by maintainers)

github_iconTop GitHub Comments

7reactions
Cxxxx100commented, May 19, 2017

removeClippedSubviews={true} resolved this issue for me, thanks @oprisnik. (RN 0.41)

7reactions
oprisnikcommented, May 3, 2017

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 adding removeClippedSubviews={true} to the ScrollView? cc @foghina

Read more comments on GitHub >

github_iconTop 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 >

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