App icon indicating copy to clipboard operation
App copied to clipboard

[Performance] CMD + K is slow and laggy

Open isagoico opened this issue 5 years ago • 28 comments

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Action Performed:

  1. While using e.cash use the cmd+k command
  2. Type on the search field

Expected Result:

App should be fast and search should be responsive as soon as the command is used

Actual Result:

Cmd + K is super slow and laggy and is locking up the whole app when used. Search functionality seems completely broken (on desktop staging

Workaround:

No workaround found.

Platform:

Where is this issue occurring?

Web iOS Android Desktop App ✔️ Mobile Web

Version Number: 1.0.68-4

Logs: https://stackoverflow.com/c/expensify/questions/4856

Notes/Photos/Videos: (Unable to add video since I don't have MacOS)

Expensify/Expensify Issue URL: https://github.com/Expensify/Expensify/issues/168172

View all open jobs on Upwork

Upwork job: https://www.upwork.com/jobs/~015673ac7d22fbbd42


From @puneetlath https://expensify.slack.com/archives/C01GTK53T8Q/p1623719515341400

ISSUE: cmd + K is super slow and laggy and is locking up the whole app when used. Search functionality seems completely broken (on desktop staging v1.0.68-4)

isagoico avatar Jun 15 '21 22:06 isagoico

Triggered auto assignment to @MariaHCD (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

MelvinBot avatar Jun 15 '21 22:06 MelvinBot

Triggered auto assignment to @jliexpensify (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

MelvinBot avatar Jun 17 '21 14:06 MelvinBot

Hi @isagoico - I wasn't able to test this on your version, as I have 1.0.71-0. Here's a video of the search feature - it seems to be working and I don't think it's slow (personally):

https://user-images.githubusercontent.com/30815269/122483349-b7b64b00-d015-11eb-96aa-47d9b588cdd4.mp4

Do you think we can close this GH?

jliexpensify avatar Jun 17 '21 23:06 jliexpensify

Investigating this now.

marcaaron avatar Jun 18 '21 00:06 marcaaron

Reopening the issue following @puneetlath feedback. Looks like the Chat Switcher is faster but it's still a bit sluggish.


The chat switcher seems to have improved, but is still pretty slow. Takes a second to open, then takes another second to filter the results based on what I’ve typed

isagoico avatar Jun 21 '21 20:06 isagoico

Gonna unassign myself as I can't look into further improvements atm. The chat switcher speed should be related to how many chats you have in general.

marcaaron avatar Jun 21 '21 20:06 marcaaron

Triggered auto assignment to @NicMendonca (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

MelvinBot avatar Jun 21 '21 20:06 MelvinBot

To confirm, it's a lil laggy for me too, it almost always misses the first letter I type

mallenexpensify avatar Jun 21 '21 22:06 mallenexpensify

Triggered auto assignment to @timszot (Exported), see https://stackoverflow.com/c/expensify/questions/7972 for more details.

MelvinBot avatar Jun 22 '21 13:06 MelvinBot

Posted to Upwork: https://www.upwork.com/jobs/~015673ac7d22fbbd42

NicMendonca avatar Jun 22 '21 13:06 NicMendonca

Reason: Too many re-renders As you see the following screencast, there are too many re-renders every time when I type "Concierge".

There are 2 workarounds

  • Need to use shouldComponentUpdate OptionsList component is a good example. The component includes "shouldComponentUpdate" on itself and it does not make re-render as long as "props.sections" is not changed.

  • Need to avoid changing the state in the main body of the components Here is a structure. SearchPage -> OptionsSelector -> OptionsList Here, OptionsSelector does not need to have an event onChangeText.

In conclusion, however, I recommend 2nd one because OptionsSelector component does not need to have the onChangeText which is a root of all issues. In this case, OptionSelector can be an unconditional component because "props.sections" is not a data which changes by any user input.

Thibault LAURIAONO (I post this after reading the job description on Upwork)

https://user-images.githubusercontent.com/1319853/122999024-08c79580-d3ae-11eb-9bea-31fd7a20d77a.mp4

Looxor avatar Jun 22 '21 21:06 Looxor

@Looxor Thanks for the proposal! Could you please clarify a couple of things for me?

Reason: Too many re-renders

Can you please quantify this somehow (eg. how many re-renders are happening, and what number are you trying to optimize for?)

OptionsSelector component does not need to have the onChangeText

I'm not really following this because I see that onChangeText is used by the parent SearchPage.js, so I don't see how it needs to be removed. Can you add some more details about that?

OptionSelector can be an unconditional component because "props.sections" is not a data which changes by any user input.

I don't understand this either. Primarily, I'm not sure what "unconditional component" means and I'm also not sure what props.sections has to do with the problem (I thought onChangeText was the problem).

tgolen avatar Jun 23 '21 20:06 tgolen

#1 Reason: Too many re-renders Can you please quantify this somehow (eg. how many re-renders are happening, and what number are you trying to optimize for?)

For more convenient, I made a diagram to show you the result. Please look at the following pic. expensify-answer-01

#2 OptionsSelector component does not need to have the onChangeText I'm not really following this because I see that onChangeText is used by the parent SearchPage.js, so I don't see how it needs to be removed. Can you add some more details about that?

I made a simple screencast for you to show how to do that. I removed onChangeText on SearchPage's OptionsSelector.

https://user-images.githubusercontent.com/1319853/123221014-c77ad700-d4ce-11eb-811e-89cabbf5a422.mp4

#3 OptionSelector can be an unconditional component because "props.sections" is not a data which changes by any user input.

I don't understand this either. Primarily, I'm not sure what "unconditional component" means and I'm also not sure what props.sections has to do with the problem (I thought onChangeText was the problem).

I am sorry for my typo. I meant the uncontrolled component. As you can see the video above, TextInputWithFocusStyles does not have a prop named "value" on OptionsSelector.js. It means that "TextInputWithFocusStyles" is not controlled by React and we refer its value only by using onChangeText on itself.

Thibault LAURIANO

Looxor avatar Jun 24 '21 07:06 Looxor

I upload this screencast again because above one is crashed.

https://user-images.githubusercontent.com/1319853/123221693-7c14f880-d4cf-11eb-8973-27416ca68d44.mp4

Looxor avatar Jun 24 '21 07:06 Looxor

OK, thanks for the additional information. I think I understand what the proposal is now. It was a little difficult seeing what code changes were being made in the video. In the future, it would help to either link directly to a diff of the code changes you are proposing, or to write out the specific changes that would be made (just to help you write better proposals).

Looks like the rendering is indeed decreased, but it's hard to know if that will totally fix the problem. It's probably a good place to start though and we can test it out with larger data sets once it's been deployed.

🟢 to hire @Looxor for this one.

tgolen avatar Jun 24 '21 16:06 tgolen

@Looxor hired on Upwork 🎉

NicMendonca avatar Jun 24 '21 17:06 NicMendonca

@Looxor the PR created several regressions that were linked in this PR https://github.com/Expensify/Expensify.cash/pull/3824 that reverted your original one. Can you please submit a follow-up PR if you'd still like to complete this one?

nickmurray47 avatar Jun 30 '21 18:06 nickmurray47

@nickmurray47 , Can you please provide a demo user credential to check "Search" and "New chat" with many users? I have one, but it's only one user and I have no idea to create members for testing. Thank you.

Looxor avatar Jul 07 '21 13:07 Looxor

@Looxor can you please post the same question in the #expensify-open-source channel first? Someone there might already have set up an account for you to use. If no one is available to assist then I can help from there. Thanks.

nickmurray47 avatar Jul 07 '21 17:07 nickmurray47

@nickmurray47 , I didn't join the Slack channels so I sent an email "Slack Channel Invite" to [email protected] (as mentioned in guideline). But I didn't get any invitation from there. Can you please check this for me?

Looxor avatar Jul 08 '21 15:07 Looxor