mattermost / mattermost-mobile

Next generation iOS and Android apps for Mattermost in React Native
https://about.mattermost.com/
Apache License 2.0
2.25k stars 1.36k forks source link

Copy Text is very slow #7287

Closed moussetc closed 1 year ago

moussetc commented 1 year ago

Per Mattermost guidelines, GitHub issues are for bug reports: http://www.mattermost.org/filing-issues/.

For troubleshooting see: http://forum.mattermost.org/. For feature proposals see: http://www.mattermost.org/feature-requests/

If you've found a bug--something appears unintentional--please follow these steps:

  1. Confirm you’re filing a new issue. Search existing tickets in Jira to ensure that the ticket does not already exist.
  2. Confirm your issue does not involve security. Otherwise, please see our Responsible Disclosure Policy.
  3. File a new issue using the format below. Mattermost will confirm steps to reproduce and file in Jira, or ask for more details if there is trouble reproducing it. If there's already an existing bug in Jira, it will be linked back to the GitHub issue so you can track when it gets fixed.

Summary

Using the action Copy Text on a message is very slow

Environment Information

Steps to reproduce

  1. Write a message in mattermost app, it can be a very short message
  2. Maintain click on it to open the actions menu
  3. Click on Copy Text
  4. Immediately switch to another app, for example an app for taking notes
  5. Try pasting the text: it is not the text you have copied, it is the previous text in your copy-paste history
  6. Go back to the mattermost app: with some delay, you see a "text copied" notification
  7. Go back to the other app, paste, now you have the expected message that is pasted

Expected behavior

Copying a message, especially a very short message, should be near instantaneous (like it is in other apps and like it was in MM App V1).

Observed behavior (that appears unintentional)

I have several pasted the wrong stuff because the MM App had not actually copied the text before i switched app because it seems to take more than one whole second to do so.

Maybe in https://github.com/mattermost/mattermost-mobile/blob/7aa5bd0611e89e2d20b8bbfdfc589cd20de94ede/app/screens/post_options/options/copy_text_option.tsx#L22 we dont need to wait for bottom sheet dismissal to actually do the copying? (If the issue is not in the clipboard.copy call itself which i have no means of testing)

amyblais commented 1 year ago

Opened https://mattermost.atlassian.net/browse/MM-52218.

enahum commented 1 year ago

can you give the apk attached to this post a try and report back? https://github.com/mattermost/mattermost-mobile/issues/7098#issuecomment-1499349492

We've been having some issues with some Android devices where the text input may be causing the app to perform really poor. The RN team introduced a potential fix and I would love to validate that is the case, thus I patched that custom build in order to check if the fix works correctly.

Thanks

moussetc commented 1 year ago

Hi @enahum, i tried the APK you linked but the copying still takes around 1s to be effective (it feels "instantaneous" on other apps, as it did on Mattermost app v1).

larkox commented 1 year ago

The reason for this is that we are closing the bottom sheet (and waiting for it to be closed) before putting the text in the clipboard. Switching lines 22 and 23 from app/screens/post_options/options/copy_text_option.tsx should fix part of the problem.

The perceived performance problem, though, may be a bit harder to fix.

@moussetc do you want to fill a PR for this? Or do you prefer me creating it?

moussetc commented 1 year ago

@moussetc do you want to fill a PR for this? Or do you prefer me creating it?

Hi @larkox, i won't be able to open the PR, please do if you dont mind :)