Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance issue when using Swipable in flatlist #1531

Closed
UsamaIkraam0099 opened this issue Aug 2, 2021 · 28 comments
Closed

Performance issue when using Swipable in flatlist #1531

UsamaIkraam0099 opened this issue Aug 2, 2021 · 28 comments

Comments

@UsamaIkraam0099
Copy link

Performance issue when using Swipable in Flatlist

Description

Screenshots

Steps To Reproduce

Expected behavior

Actual behavior

Snack or minimal code example

Package versions

  • React: 17.0.1
  • React Native: 0.64.2
  • React Native Gesture Handler: 1.10.3
@jakub-gonet
Copy link
Member

Could you please expand on this one? Preferably with benchmarks and the code you used to show performance issues with Swipeables.

@UsamaIkraam0099
Copy link
Author

Basically i apply this on FlatList and when changing on any FlatList item like backgroundcolor or borderColor its slow and taking time but when I remove Swipeable FlatList working fine no issue there. I'll share some code

@alexstanbury
Copy link

alexstanbury commented Aug 12, 2021

I'm seeing poor performance with Swipeable in a Flatlist too. It can be observed by using the swipeable demo from the example in this repo and increasing the number of data items in the Flatlist (There is an older issue here with users reporting the same). For now I've had to switch over to react-native-interactable but I'd much rather be using this library.

Relevant packages:
"react-native": "^0.64.2",
"react-native-reanimated": "^2.2.0",
"react-native-gesture-handler": "^1.10.3",

@msageryd
Copy link

I'm having this issue too.

As soon as I introduce Swipeable in my Flatlist items the list scrolls much less smoothly. I have a couple of 100 items with a thumbnail and av SVG pie chart. The list scrolls perfectly smooth without Swipeable.

I thought that maybe the flatlist had trouble measuring the height of Swipeable, so I wrapped it with a View with a constant height. This didn't solve the issue. I tried setting height on containerStyle as well as childrenContainerStyle, no difference.

I console.log:ed in the Swipeable source to see if it was re-rendering all the time, but it wasn't. Each Swipeable is rendered twice, but after that no more render is logged while I'm scrolling. I don't know why it renders twice, but this is not the problem anyway.

I'll go ahead and try https://github.com/wix/react-native-interactable instead.

I'd rather use react-native-gesture-handler since I'm using this lib in other places in my app. It would be really awesome if this issue could be solved somehow.

@msageryd
Copy link

msageryd commented Dec 28, 2021

To illustrate the problem I have made two screen recordings from my iPhone X. The first recording is with a Swipeable wrapping the list items. When I scroll slowly, the performance problem is very visible. Actually, when looking at this I don't know if this really is a performance problem. It looks more lika some kind of layout problem.

The second recording is without Swipeable. Buttery smooth, as you can see.

I appologize for the crappy blurring. This is live client data which I cannot show. I have never used iMovie before, so it looks like sh-t.

With Swipeable
https://user-images.githubusercontent.com/4483085/147594877-91e6384b-dee4-41c4-99dc-cb22593de30f.mp4

Without Swipeable
https://user-images.githubusercontent.com/4483085/147594895-4eb82773-eca0-4b76-a5c2-03c193399afc.mp4

Edit:
I think GitHub might have compressed the video. The second video looks a bit jumpy as well, but I assure you that it is buttery smooth without Swipeable.

@Haider3iq
Copy link

Haider3iq commented Feb 3, 2022

Hi @msageryd, I am running into same performance issues.... have you solved this anyhow?

@tylercote
Copy link

I also have this issue, and I think it may be related to some re-renders due to state changes that I am not causing.

2022-12-01 18 56 32

@pierroo
Copy link

pierroo commented Jan 15, 2023

Is there any update about this performance issue?
Swipeable as of now is not usable in flatlist.

@9903SV
Copy link

9903SV commented Aug 18, 2023

@jakub-gonet @kkafar

We are also facing the same issue. We are using Swipeable in Shopify's FlashList. Is there any update regarding the performance issue?

@MensurRasic
Copy link

Same issue here, any solution or alternative to Swipeable ?

@smfunder
Copy link

Same here, I detected this using Shopify's FlashList with Swipeable. When they are together a fast scroll will generate blank areas, while removing Swipeable it works very smooth. Any suggestion or any replacement for Swipeable component?

@Acetyld
Copy link

Acetyld commented Oct 13, 2023

Same, are there any alternatives

@ngocle2497
Copy link

I got same issue, any solution for it?

@crusherblack
Copy link

after i take out swipable the perfomance back to normal, are there any alternatives?

@StasSokolov1
Copy link

StasSokolov1 commented Mar 7, 2024

@crusherblack @ngocle2497 @Acetyld @smfunder @UsamaIkraam0099
hello guys, check please code below, works much more smoothly for me
<Swipeable onSwipeableWillClose={() => setShowRightAction(false)} onActivated={() => setShowRightAction(true)} renderLeftActions={showRightAction ? renderLeftActions : undefined}> ... </Swipeable>

@Acetyld
Copy link

Acetyld commented Mar 8, 2024

@crusherblack @ngocle2497 @Acetyld @smfunder @UsamaIkraam0099 hello guys, check please code below, works much more smoothly for me <Swipeable onSwipeableWillClose={() => setShowRightAction(false)} onActivated={() => setShowRightAction(true)} renderLeftActions={showRightAction ? renderLeftActions : undefined}> ... </Swipeable>

Did you check performance / fps after implementing this For me it dropped to 30/40fps

@StasSokolov1
Copy link

@Acetyld

Yes, I'm using FlashList and when i pass undefined to renderLeftActions it works more smoothly but not smooth like without Swipeable, which list you use?

@smfunder
Copy link

smfunder commented Mar 8, 2024

hey @Acetyld @StasSokolov1 and all the people here. I ended up using Interactable.View. And I use it in combination of FlashList and it is super smooth.

import Interactable from 'react-native-interactable'

  const leftSwipe = (item) => {
    // NOTE: We are no longer using TouchableOpacity in a flat list because it created this issue:
    // https://github.com/facebook/react-native/issues/34376#issuecomment-1231324454
    return (
      <View>
        <Pressable onPress={handlePinUnPinCallback}>
          <FastImage style={styles.pinUnpinMsg} source={item?.isFavorite ? Images.UNPIN_MSG : Images.PIN_MSG} />
        </Pressable>
      </View>
    )
  }

return (
    <View>
      {leftSwipe(groupDetail)}
      <Interactable.View
        ref={swipeRef}
        horizontalOnly={true}
        dragEnabled={isEnableSwipe}
        snapPoints={[{ x: 100 }, { x: 0 }, { x: -150 }]}
        alertAreas={[{ id: 'leftArea', influenceArea: { left: 5 } }, { id: 'rightArea', influenceArea: { right: 5 } }]}
        onAlert={handleOnSwipeAlert}
       >
       <View> Content of the cell </View>
     </Interactable.View>
</View>

@rparrett
Copy link

rparrett commented Mar 8, 2024

I ended up using Interactable.View. And I use it in combination of FlashList and it is super smooth.

This is exciting. Which specific react-native-interactable package are you using?

@smfunder
Copy link

smfunder commented Mar 8, 2024

I ended up using Interactable.View. And I use it in combination of FlashList and it is super smooth.

This is exciting. Which specific react-native-interactable package are you using?

@rparrett I'm using "react-native-interactable": "^2.0.1"
https://github.com/wix-incubator/react-native-interactable

@Acetyld
Copy link

Acetyld commented Mar 8, 2024

I ended up using Interactable.View. And I use it in combination of FlashList and it is super smooth.

This is exciting. Which specific react-native-interactable package are you using?

@rparrett I'm using "react-native-interactable": "^2.0.1" https://github.com/wix-incubator/react-native-interactable

Does it work in expo dev build?

@smfunder
Copy link

smfunder commented Mar 8, 2024

I ended up using Interactable.View. And I use it in combination of FlashList and it is super smooth.

This is exciting. Which specific react-native-interactable package are you using?

@rparrett I'm using "react-native-interactable": "^2.0.1" https://github.com/wix-incubator/react-native-interactable

Does it work in expo dev build?

@Acetyld sorry I don't know, I'm not using expo.

@imyanglu
Copy link

: (

@maksim-romanov
Copy link

same problem for me!

@pranavbabu
Copy link

Same here

1 similar comment
@stichingsd-vitrion
Copy link

Same here

@kkafar
Copy link
Member

kkafar commented Jul 26, 2024

Guys, I'm not on gesture-handler team, but I would recommend doing following for this issue to get attention of the maintainers:

  1. properly describing the issue, with videos (if there are visual glitches), ideally benchmarks on release build profile of your app / example if you conducted some,
  2. proper reproduction (a code snippet / repository with reproducer),
  3. list of library versions you're using
  4. any related info such as platform (Android / iOS), react-native architecture (Fabric / Paper / both)

It would also be most likely beneficial to open a new issue that has above information in the description.

@j-piasecki
Copy link
Member

This issue seems to be describing exactly the same thing as #3141, but that one is newer and has a better description and reproduction so I'll close this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests