TheWidlarzGroup / rn-emoji-keyboard

Super performant, lightweight, fully customizable emoji picker 🚀
https://thewidlarzgroup.github.io/rn-emoji-keyboard/
MIT License
335 stars 63 forks source link

Performance improvement idea (to be discussed) #152

Open jan-kozinski opened 1 year ago

jan-kozinski commented 1 year ago

Hi, we've been getting some performance issues reports lately, so I wanted to discuss a possible improvement regarding how we render the emojis.

Current solution

As of now, each category of emojis is built with a Flatlist component where each item is a single emoji.

Suggested solution

the renderItem callback of the flatlist could render whole rows of emojis at once, thus having less items to render, and less elements in the React DOM (since entire row will be kept in a single Text element). Then, the onClick callback of each row might check the X position of the touch gesture and determine which emoji the user tapped based on this X position value.

Possible problems

jakex7 commented 1 year ago

Hi, unfortunately it will be quite hard, if not impossible to implement due to selectedEmojis feature and related to that indications

jan-kozinski commented 1 year ago

WDYM? What does the selectedEmojis indicate? Are the emojis growing wider when multi-selected or is there some sophisticated animation going on?

shanoysinc commented 1 year ago

I am currently using an iPhone 11 pro and the start-up for the emoji picker is quite slow the animation is really laggy. what animation/ bottom sheet library are you using? is the app loading all the emojis at once?

jakex7 commented 1 year ago

WDYM? What does the selectedEmojis indicate? Are the emojis growing wider when multi-selected or is there some sophisticated animation going on?

@jan-kozinski As it is described in the documentation, dev can pass an array of selectedEmojis as props to indicate the emojis

https://thewidlarzgroup.github.io/rn-emoji-keyboard/docs/documentation/Examples/selected_emojis

image

jakex7 commented 1 year ago

I am currently using an iPhone 11 pro and the start-up for the emoji picker is quite slow the animation is really laggy. what animation/ bottom sheet library are you using? is the app loading all the emojis at once?

@shanoysinc I am sorry to hear that. We are constantly working to improve performance. Does your issue also occur in the production build?

shanoysinc commented 1 year ago

yes in the production build but when I use the emoji picker in my own modal and not the bottom sheet modal the performance is great @jakex7

jan-kozinski commented 1 year ago

hmm @jakex7 My idea is that the list item component will be a single row component, that has selectedEmojisIndexes in its state, and renders the indications as absolutely positioned divs with zIndex lower than the \<Text> tag with emojis. The indications don't need a flatlist of their own and can use map function, since if a row is rendered than so are all the indications Would it solve the issue?