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) Images loading causes that app crashes

See original GitHub issue

I’m using:

react-native: 0.39.0 npm: 4.0.2 node: 6.9.1

The problem is when I try to take a few pictures in a row, after fifth taken image the app crashes. I’m not getting any errors of warnings.

It crashes also if the camera is opened and if I wait for about 15-20 seconds with camera opened, without taking photo.

On newer, better phone (s8 galaxy) and newer android versions (7) it works as expected, but on this one it isn’t working. Thus, I suppose that it has something to do with memory issues. But I’m not sure.

I’ve added largeMemoryHeap to the manifest file.

In android studio I get log file as follows: screen shot 2017-09-14 at 11 11 58

Thus, no errors, nothing. But the app doesn’t work.

The stuck of code where those photos are rendered is as follows:

<ScrollView removeClippedSubviews={true}>
      <StatusBar backgroundColor="blue" barStyle="light-content"/>
      <Zoom visible={this.state.zoomVisible} close={() => this.setState({zoomVisible: false})} image={this.state.zoomImage} imageIndex={this.state.zoomIndex} pictures={this.state.zoomPictures} remove={this.onRemoveImage.bind(this)} />
      <View style={{width: width, height: 1, backgroundColor: '#ddd'}} />
           <View style={styles.container}>
               {cards}
           </View>
 </ScrollView>

And one card is as follows, and I have a stuck of 10:

<TouchableHighlight onPress={this.props.onPress} style={styles.card} underlayColor={s.color}>
       <View style={styles.innerCard}>
             <View style={styles.innerImageContainer}>
                  <Image contain='contain' style={styles.innerImage} source={this.props.image}/>
              </View>
              <View style={[styles.innerTitle, {borderBottomWidth: 4, borderBottomColor: this.props.mandatory ? this.props.noImage ? s.paletteMandatory : s.success : '#fff'}]}>
                   <Text style={styles.textTitle} allowFontScaling={false} numberOfLines={1} ellipsizeMode={'tail'}>{this.props.title}</Text>
              </View>
        </View>
</TouchableHighlight>

I found here that I need to add removeClippedSubviews={true} to ScrollView, but it does not help.

On IOS it works just fine.

It looks something like:

simulator screen shot 15 sep 2017 09 27 34

When they click on one of the cards the camera is opened and after they take the photo, the get something like: simulator screen shot 15 sep 2017 09 27 52

Thus, on IOS and on Android phones with more memory (Samsung S8) it works as expected.

Issue Analytics

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

github_iconTop GitHub Comments

5reactions
flynnchcommented, Sep 17, 2017
  1. resizeMethod={‘resize’} http://facebook.github.io/react-native/docs/image.html 2.use Flatlist
0reactions
deehueycommented, Apr 13, 2018

@flynnch You are a god amongst men. Thank you, we were displaying shop logos in a ScrollView and getting crashes the further you scrolled down. Now I can quintuple the list length without a single performance hit, all with adding resizeMethod="resize".

Dumb, but glad to have found the issue 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

app crashes on adding image in android studio - Stack Overflow
1.sometimes it happens that all your code is right and you were getting app crash due to you've put the images in drawable...
Read more >
Detect and diagnose crashes - Android Developers
There are many situations that can cause a crash in your app. Some reasons are obvious, like checking for a null value or...
Read more >
IMGDroid: Detecting Image Loading Defects in Android ...
summarize five common image loading anti-patterns in. Android apps that can degrade app performance and quality or even lead to app crashes.
Read more >
How to Fix Crashing Apps on an iPhone or Android?
Sometimes app-crashing is not caused by your phone, but rather the app itself. An internal error, or bug, may have brought the app...
Read more >
Why Do My Apps Keep Crashing on Android? - Avast
Apps on Android can crash because of low storage space, too many apps running simultaneously, a weak internet connection, or not having the ......
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