react-native-fast-image icon indicating copy to clipboard operation
react-native-fast-image copied to clipboard

Bad Android Scrolling Performance

Open Pipo93 opened this issue 5 years ago • 14 comments

Describe the bug When we have a high amount of images displayed in a ScrollVIew or FlatList, scrolling does not really work when we use FastImage on Android. The same code works very well on iOS Devices.

To Reproduce I tested this example code in a plain react-native app and the same behavior was recognized:

import { FlatList, View, ScrollView } from 'react-native'
import FastImage from 'react-native-fast-image'
const data = Array(100).fill(1)

const App = () => {
    return (
        <View style={{ flex: 1 }}>
            <ScrollView style={{ backgroundColor: '#000' }}>
                {data.map((element, index) => {
                    return (
                        <FastImage
                            onError={() => console.log('error', index)}
                            source={{ uri: `https://picsum.photos/id/${index}/450/253` }}
                            style={{ width: '100%', aspectRatio: 16 / 9 }}
                        />
                    )
                })}
            </ScrollView>
        </View>
    )
}

Expected behavior Smooth scrolling also on android devices

Dependency versions

  • React Native version: 0.61.4
  • React version: 16.11.0
  • React Native Fast Image version: 7.0.2

Pipo93 avatar Nov 18 '19 13:11 Pipo93

In general, Android list performance takes more effort than it does on iOS. You could try using FlatList instead and follow these performance tips.

But in my case, replacing Image with FastImage in my flatlists causes severe scrolling-performance issues on Android (choppy scrolling, unresponsive touches, etc).

pbfrias17 avatar Dec 11 '19 17:12 pbfrias17

Same here [email protected] Many horizontal Flatlists and on Android it sluggish and feels slow. On iOS, it works fine.

yaronlevi avatar Dec 17 '19 17:12 yaronlevi

Same here, unable to get desired performance without switching to standart rn image component. No solutions yet?

auseika avatar Jan 27 '20 08:01 auseika

Same here RN: 0.61.5 Vertical FlatList on Android

I found out that only setting removeClippedSubviews to false would cause the performance issue

JungHsuan avatar Mar 10 '20 08:03 JungHsuan

I don't seem to have any problems in a FlatList but when I use a scrollview the performance is very poor. Maybe it is because I am using images with different sizes? it's weird that scrollview works worst compared to the flatlist. Will experiment a little today.

klaaz0r avatar Apr 06 '20 11:04 klaaz0r

@klaaz0r , did u made it working with scrollView? UPDATE: made it working using removeClippedSubviews={true} for ScrollView

hjhimanshu01 avatar May 03 '20 12:05 hjhimanshu01

Very slow on Android. No FlatList and ScrollView with removeClippedSubviews={true}. Having about 10 images on the screen slows UI and JS frame rate to bellow 10.

lumberman avatar Aug 24 '20 17:08 lumberman

@klaaz0r , did u made it working with scrollView? UPDATE: made it working using removeClippedSubviews={true} for ScrollView

it's working, thanks very much

ez-tech-global avatar Apr 28 '21 08:04 ez-tech-global

RN 0.70.6 removeClippedSubviews={true} can't solve my issue

tomcheung1208 avatar Mar 21 '23 03:03 tomcheung1208

tnks

vmsilva avatar Mar 31 '23 17:03 vmsilva

RN 0.70.6 removeClippedSubviews={true} can't solve my issue

Same here with an infinite Masonry Feed that must be created using a ScrollView. Tried everything and ended up replacing it with the Image component from 'react-native'. Also had to set the resizeMethod to 'resize' for better performance

novirusallowed avatar May 17 '23 15:05 novirusallowed

@novirusallowed It works very well. Thank you.

k0502s avatar Jun 18 '23 14:06 k0502s

@novirusallowed It works very well. Thank you.

Yes, it fixes this problem but other problems arise if you are trying to render large/infinite lists unfortunately.. Really hope they're going to fix this issue soon.

novirusallowed avatar Jul 07 '23 08:07 novirusallowed

@novirusallowed Image component does not have resizeMethod to 'resize'

fukemy avatar Aug 01 '23 09:08 fukemy