Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.44k stars 2.8k forks source link

[HOLD for payment 2024-07-24] [$250] [Critical] [UX Reliability] Input in the pushed in page moves around causing wrong message typed #43983

Closed mountiny closed 2 months ago

mountiny commented 3 months ago

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: Reproducible in staging?: Reproducible in production?: If this was caught during regression testing, add the test name, ID and link from TestRail: Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by: @mountiny
Slack conversation: https://expensify.slack.com/archives/C05LX9D6E07/p1718793199252419

Action Performed:

Break down in numbered steps

There is many flows where this can be experienced. Wherever we push a page with input to autofocus. In this video I have:

  1. Go to workspace chat
  2. Submit expense
  3. Scan a receipt
  4. Click on Description row
  5. Start typing quickly

Expected Result:

Describe what you think should've happened

The message you type is correctly applied

Actual Result:

Describe what actually happened

It seems like after first of second character the cursor jumped to the front of the input

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

Platforms:

Which of our officially supported platforms is this issue occurring on?

Screenshots/Videos

https://github.com/Expensify/App/assets/36083550/c4f61ccc-075d-4ee4-87e2-a2fd4102c150

he logs and traces are in slack convo Add any screenshot/video evidence

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~013581c71c8dab48d3
  • Upwork Job ID: 1803380011113187610
  • Last Price Increase: 2024-07-03
Issue OwnerCurrent Issue Owner: @muttmuure
melvin-bot[bot] commented 3 months ago

Triggered auto assignment to @muttmuure (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

hannojg commented 3 months ago

πŸ‘‹

melvin-bot[bot] commented 3 months ago

Job added to Upwork: https://www.upwork.com/jobs/~013581c71c8dab48d3

melvin-bot[bot] commented 3 months ago

Triggered auto assignment to Contributor-plus team member for initial proposal review - @mkhutornyi (External)

hannojg commented 3 months ago

No new update yet here specifically. The problem basically being similar to the one in:

so we want to tackle that issue first

hannojg commented 3 months ago

Still prioritising the aforementioned issue - do we want to put this one on hold for the other issue?

jacobkim9881 commented 3 months ago

@hannojg πŸ˜ƒ I found a cause for the issue but it seems the issue's root cause is from other repository. I would like to report.

hannojg commented 3 months ago

Sure, feel free to share what you've found

jacobkim9881 commented 3 months ago

https://github.com/Expensify/App/blob/c0d3e79466d7b6abde4409a9247cccd55f579f0e/src/pages/tasks/TaskDescriptionPage.tsx#L125

I found the issue noticeably decreased after off the props. And the props activate a component from other repository, which somebody can handle.

jacobkim9881 commented 3 months ago

Which decides a comp between 2:

https://github.com/Expensify/App/blob/7eeede6ea989c653ea92506d84d7aa053ccd2a4a/src/components/TextInput/BaseTextInput/index.native.tsx#L71

And RNMarkdownTextInput comp is from @expensify/react-native-live-markdown that is from other. Shame I couldn't PR!

hannojg commented 3 months ago

Okay, so it seems that you pined the issue down to react-native-live-markdown. Great, thanks for the insight!

Two things I want to let you know about:

What I am trying to say is that we need to continue to investigate whats exactly causing the issue when using react-native-live-markdown. (This is something I have on my todo list now, as the issue is assigned to me).

hannojg commented 3 months ago

What do you mean by

Shame I couldn't PR!

there is nothing stopping from you from checking out the code of react-native-live-markdown 😊

jacobkim9881 commented 3 months ago

Okay, so it seems that you pined the issue down to react-native-live-markdown

Yes. I assume we can find the root cause from there πŸ˜ƒ So we can continue to found the issue upstream! So we still have more chances to fix. That's nice!

react-native-live-markdown is a library owned and developed by expensify (in partnership with SWM). So you can think of react-native-live-markdown being another folder in the expensify app.

So it would be easy to get helps since it's partner shipped with SWM. That's cool! I found it in node_modules.

jacobkim9881 commented 3 months ago

there is nothing stopping from you from checking out the code of react-native-live-markdown 😊

Would like to continue πŸ˜„

jacobkim9881 commented 3 months ago

So I found performance better noticeably in the input tag without this comp:

https://github.com/Expensify/react-native-live-markdown/blob/d05065948bf36414705fe9148b25686adfab2181/src/MarkdownTextInput.tsx#L53-L55

which uses this: https://github.com/Expensify/react-native-live-markdown/blob/d05065948bf36414705fe9148b25686adfab2181/src/MarkdownTextInputDecoratorViewNativeComponent.ts#L4

The only comp used is from react-native. I can continue though it's from another repo? πŸ˜„

mountiny commented 3 months ago

Hey @jacobkim9881! thanks for help on this one. I recommend you to first read through the contributing guidelines we have for the Expensify App repo https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md. We have a format for new proposals which you should use if you want to submit a proposal.

If the issue is in the https://github.com/Expensify/react-native-live-markdown/blob/d05065948bf36414705fe9148b25686adfab2181/src/MarkdownTextInputDecoratorViewNativeComponent.ts#L4 you can also submit a proposal here with clearly identifying the rootcause and how you propose to fix it. If that will be correct, you can do the work and get paid for it through Upwork. Thanks!

jacobkim9881 commented 3 months ago

Hey, @mountiny! Thank you for the guidance! Let me give proposals to issues in other time.

you can also submit a proposal here with clearly identifying the rootcause

I would like to submit proposals if I find the solution. Thanks for letting me know again!

jacobkim9881 commented 3 months ago

@mountiny I have a question. If I contribute in anyway, is there a chance I can get paid? Though I couldn't get paid, am happy to be helped in anyway!

melvin-bot[bot] commented 3 months ago

@hannojg, @mountiny, @muttmuure, @mkhutornyi Eep! 4 days overdue now. Issues have feelings too...

mountiny commented 3 months ago

If you substantially help to find the root cause of this issue (by pinpointing the line causing the issue and how to fix it for example), we usually issue partial payment even if you do not fix the issue yourself.

jacobkim9881 commented 3 months ago

@mountiny Thanks for the answer! That sounds sweet. Hope I can fix or find root causes next time.

BartoszGrajdek commented 3 months ago

I believe this issue could be related to live markdown. @mountiny can we add it temporarily to the Live Markdown project? I'll try to revisit it later this week to at least pinpoint the root cause if no one finds it.

mountiny commented 3 months ago

Added it to the project, but I think this is urgent issue enough to still deserve daily updates if possible

BartoszGrajdek commented 3 months ago

Agreed, I'll also try working on it tomorrow! πŸ‘€

mkhutornyi commented 3 months ago

Not overdue

melvin-bot[bot] commented 3 months ago

πŸ“£ It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? πŸ’Έ

melvin-bot[bot] commented 3 months ago

@hannojg, @mountiny, @muttmuure, @mkhutornyi Eep! 4 days overdue now. Issues have feelings too...

mkhutornyi commented 3 months ago

Same

BartoszGrajdek commented 3 months ago

Hi! Sorry for the delay, but I had a couple of other tasks at hand. πŸ™‡πŸ»

I tried reproducing this issue but didn't manage to. I've tested it with several iOS simulators (iOS 16.0-17.5).

@mountiny can you confirm if this is still reproducible for you? If so do you mind sharing what device & iOS version are you using? πŸ™πŸ»

Looking into the problem specifically - it's very similar to some of the bugs we've had before in composer & it most likely stems from E/App code itself not react-native-live-markdown lib, but I'm not 100% till I'm able to reproduce it. πŸ‘€

hannojg commented 3 months ago

(I should be done with my other task today and then can start looking into this as well!)

melvin-bot[bot] commented 3 months ago

πŸ“£ It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? πŸ’Έ

melvin-bot[bot] commented 3 months ago

@hannojg @mountiny @muttmuure @mkhutornyi this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

hannojg commented 3 months ago

Alright, sorry guys, today is the day - just started looking into the issue!!

hannojg commented 3 months ago

Note: I also wasn't able to reproduce on the simulators either, but was on a physical device. You may not see it in the video immediately but the first character I typed was an N and then an a which then got deleted. So it seems like the selection / value of the input are being reset for some reason. Looking into it!

https://github.com/Expensify/App/assets/16821682/113b53bd-0a37-48e1-a82d-e0f8e3e0a84e

hannojg commented 3 months ago

Update: I pinpointed the issue to react-native-live-markdown and specifically this code:

https://github.com/Expensify/react-native-live-markdown/blob/5d4e1060d79ba12dec052e295c16541bf9f0aec0/ios/MarkdownCommitHook.mm#L115-L186

I completely commented out all code in MarkdownTextInputDecoratorComponentView, so it's not that. When disabling the code shown above the bug doesn't happen.

If I have to guess I say there might be a race condition between the user typing new text and us updating the shadow node with stale data by then. Have to look more detailed into what could cause the bug tomorrow to come up with a fix.

Probably also good to discuss with your team @BartoszGrajdek @tomekzaw

Here is a screenshot of the text updates in the commit hook, looks like we operate on some stale data. This is me trying to type Hallo:

Screenshot 2024-07-04 at 21 14 24

As in the logs visibly in the UI I see:

  1. "H"
  2. ""
  3. "H"
  4. "A"
  5. "Al"
  6. ...
  7. "Allo"
  8. "All"
  9. "Allo"

Although I typed "Hallo" in one go

tomekzaw commented 3 months ago

cc-ing @j-piasecki who's the man behind clever MarkdownCommitHook

mountiny commented 3 months ago

Thanks for pushing this ahead Hanno! I am still able to reproduce on physical device

hannojg commented 3 months ago

Okay, I found a fix for this, lets discuss if you agree @j-piasecki 😊 :

The issue is very specifically on this line:

https://github.com/Expensify/react-native-live-markdown/blob/5d4e1060d79ba12dec052e295c16541bf9f0aec0/ios/MarkdownCommitHook.mm#L143-L151

The problem is that it not only runs on the first render, but every time there is a mismatch between the props and the native state (and the AttributedStringBox::Mode::Value). Lets imagine the following flow:

Note: There are multiple flows to this race condition.

You can see one example here: Screenshot 2024-07-05 at 11 09 27

The fix from my perspective is to really only run this code on the first render. Borrowing from TextInputShadowNode we can add a check like textInputState.getRevision() == State::initialRevisionValue to the if condition.

With this in place I can't reproduce the bug:

https://github.com/Expensify/App/assets/16821682/7cb22d52-c6d9-4e3e-bb99-37d0bd01e6c9

hannojg commented 3 months ago

I think btw this is also the reason we are seeing this bug:

mountiny commented 3 months ago

Great job @hannojg as always, looking forwards the PR with the patch so we can make a build for testing

hannojg commented 3 months ago

Draft PR is here @mountiny

In this PR I bumped rn-live-markdown as SWM already merged the PR. Let me know if that works, because there is another PR for bumping rn-live-markdown first where a few bugs have been addressed (so that one needs to be merged first, I linked it in the PR)

tomekzaw commented 3 months ago

cc-ing @Skalakid and @BartoszGrajdek here as one of the recently merged PRs to live-markdown turns out to cause a regression on web and they should have the context

hannojg commented 2 months ago

Note: the fix was implemented in rn-live-markdown and we are waiting for this PR to be merged to fix it:

melvin-bot[bot] commented 2 months ago

Reviewing label has been removed, please complete the "BugZero Checklist".

melvin-bot[bot] commented 2 months ago

The solution for this issue has been :rocket: deployed to production :rocket: in version 9.0.7-8 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-07-24. :confetti_ball:

For reference, here are some details about the assignees on this issue:

melvin-bot[bot] commented 2 months ago

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

mvtglobally commented 2 months ago

Issue not reproducible during KI retests. (First week)

melvin-bot[bot] commented 2 months ago

Payment Summary

Upwork Job

BugZero Checklist (@muttmuure)

mountiny commented 2 months ago

@mkhutornyi can you please summarize the payment here? which PRs did you review?

melvin-bot[bot] commented 2 months ago

@hannojg, @mountiny, @muttmuure, @mkhutornyi Whoops! This issue is 2 days overdue. Let's get this updated quick!