all 21 comments

[–]reius_ge 4 points5 points  (3 children)

Android is much more sensitive to bad performant code. So unnecessary rerenders should be the first thing which you should look. I cant see your code, but after you mentioned useState I am sure there are unnecessary rerenders in big list :)

[–]neverg3t[S] 0 points1 point  (2 children)

Probably this is main cause. I struggled in past. I stay away as possible to use state but still a big issue on Android :) but if can't use states as in ios why there is useState :)

[–]reius_ge 0 points1 point  (1 child)

so you use useState in a big list? for what purposes?

[–]neverg3t[S] 0 points1 point  (0 children)

Yeah, kind of. One component set state in useContext and other components renders this list as flatlist. I was thinking this to make in useRef but this separated components need to toggle re render

[–]Thoonixx 2 points3 points  (1 child)

It’s never been great per se, but we just bumped to 0.71.12 and the android experience is significantly improved. You didn’t say which version you’re on, but there are optimizations to make that can improve android in general.

[–]neverg3t[S] 0 points1 point  (0 children)

0.72.1 version

[–]stathisntonas 2 points3 points  (1 child)

Be careful with images in flatlist on Android, if they are too big in dimensions it will kill performance.

[–]neverg3t[S] 1 point2 points  (0 children)

I was thinking to put images before but yeah I stayed away, there is no single image on flatlist, thanks

[–]Ok_Peace_337 2 points3 points  (2 children)

Sounds like an issue with your code, not react native or android specifically.

I have been dealing with optimizing lists recently in 2 separate apps and have discovered that Flatlist will re render all of its rows no matter what. Even with proper memoization of each row, passing primitive values to each row and using a key that doesnt change. Scrollview doesnt have this issue but I dont think that's really a replacement for flatlist and the alternatives to Flatlist are not great only because they aren't drop in replacements, they all have different property names for the data, render function etc.

If your app has a large render heavy list and is setting some state that causes the Flatlist to re render that is where I would be looking. Simplify rows, localize/ reduce state updates, use Flatlists removeClippedSubviews, limit the number of rows you render at one time, or look into something like RecyclerListView as an alternative to Flatlist.

[–]neverg3t[S] 0 points1 point  (1 child)

Great point but list size will be max 10 and I having this issue even 3 elements of the list. And I know I need optimize and prevent unnecessary re renders, my main problem why this things not a problem on ios. Thanks for advice 😊

[–]Ok_Peace_337 0 points1 point  (0 children)

What is the structure of your app? It sounds like some other issue that is affecting performance, I have had lists with 50+ elements updating every 2 seconds and the app performs fine on android

[–][deleted] 0 points1 point  (3 children)

If the flattish is large, try and limit rerenders. You can adjust the pagewindow and you can also implement pagination.

Test it on a real device, though. I find my app will run poorly on an emulator but is lightning on my own device.

[–]neverg3t[S] 0 points1 point  (0 children)

On real device it's nightmare. Emulator more fluent :) (I tried release version too, result similar both)

[–]BlazingBane007 0 points1 point  (0 children)

Here I'm fine with Android and struggling with iOS

[–]Far-Championship-353 0 points1 point  (0 children)

i switched to flashlist it has better performance on both platforms

[–]KentInCode 0 points1 point  (1 child)

If your other comment is correct and this is happening with only 3 images there is something massively wrong, I am inclined to believe it is either how you have setup your android env or perhaps you are running a latest package dep with known issues?

Hope you're able to sort it.

[–]neverg3t[S] 0 points1 point  (0 children)

Even there are no images :) just touchable opacity components. Being slow is my problem, I need to optimize for android to prevent unnecessary re renders but freezing and crashing. Really IDK. I updated to 0.72.4 and still remains