App icon indicating copy to clipboard operation
App copied to clipboard

[$250] [Performance] Implement a debug setting that simulates a poor connection by going online/offline a bunch

Open muttmuure opened this issue 1 year ago • 19 comments


What performance issue do we need to solve?

When on a poor connection, authentication calls can sometimes fail. This is sometimes de-authing users from the app (logging them out) when it shouldn't be, because we have infinite sessions.

What is the impact of this on end-users?

Users need to re-authenticate when this happens, and this is annoying.

List any benchmarks that show the severity of the issue

It has been reported numerous times in the #quality Slack channel.

Proposed solution (if any)

Implement a debug setting that simulates a poor connection, then see how much of the app breaks and try to fix those spots.

This could be done by setting up some code that will call NetworkActions.setNetWorkStatus(networkStatus); with a random value of CONST.NETWORK.NETWORK_STATUS at random intervals like every 2-5 seconds.

https://expensify.slack.com/archives/C05LX9D6E07/p1728935338695029?thread_ts=1728600237.229689&cid=C05LX9D6E07

List any benchmarks after implementing the changes to show impacts of the proposed solution (if any)

It might be time to add some benchmarking for how often the network connection is changing. How about logging every hour how many times the network connection state changed?

Platforms:

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

  • [x] Android: Native
  • [x] Android: mWeb Chrome
  • [x] iOS: Native
  • [x] iOS: mWeb Safari
  • [x] MacOS: Chrome / Safari
  • [x] MacOS: Desktop

Version Number: Reproducible in staging?: Reproducible in production?: Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Notes/Photos/Videos: Any additional supporting documentation Expensify/Expensify Issue URL: Issue reported by: Slack conversation:

View all open jobs on Upwork

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021864308224556700727
  • Upwork Job ID: 1864308224556700727
  • Last Price Increase: 2024-12-04
Issue OwnerCurrent Issue Owner: @hoangzinh

muttmuure avatar Oct 23 '24 12:10 muttmuure

Auto-assigning issues to engineers is no longer supported. If you think this issue should receive engineering attention, please raise it in #whatsnext.

melvin-bot[bot] avatar Oct 23 '24 12:10 melvin-bot[bot]

Huh... This is 4 days overdue. Who can take care of this?

melvin-bot[bot] avatar Oct 28 '24 18:10 melvin-bot[bot]

6 days overdue. This is scarier than being forced to listen to Vogon poetry!

melvin-bot[bot] avatar Oct 30 '24 18:10 melvin-bot[bot]

8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!

melvin-bot[bot] avatar Nov 01 '24 18:11 melvin-bot[bot]

12 days overdue. Walking. Toward. The. Light...

melvin-bot[bot] avatar Nov 05 '24 18:11 melvin-bot[bot]

This issue has not been updated in over 15 days. eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

melvin-bot[bot] avatar Dec 02 '24 10:12 melvin-bot[bot]

@muttmuure for this one, can we just send it to contributors to have this done? I don't think it needs anything from anyone internal.

tgolen avatar Dec 03 '24 18:12 tgolen

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

melvin-bot[bot] avatar Dec 04 '24 13:12 melvin-bot[bot]

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

melvin-bot[bot] avatar Dec 04 '24 13:12 melvin-bot[bot]

Sure!

muttmuure avatar Dec 04 '24 13:12 muttmuure

Hi, I'm Viktoryia from Callstack - expert contributor group - and I would like to work on this issue.

VickyStash avatar Dec 06 '24 07:12 VickyStash

I've opened a PR , which adds the Simulate poor internet connection toggle. It changes connection from online to offline randomly every 2-5 seconds using NetworkActions.setShouldForceOffline method (NetworkActions.setNetWorkStatus didn't have the expected effect on the app). Please, let me know what you think! @hoangzinh @tgolen

Also, I have a question regarding this part:

How about logging every hour how many times the network connection state changed?

@muttmuure Where do we want to log this value?

VickyStash avatar Dec 06 '24 14:12 VickyStash

@muttmuure Where do we want to log this value?

I think you can just log that information with Log.info() and it should be fine.

tgolen avatar Dec 06 '24 16:12 tgolen

I think you can just log that information with Log.info() and it should be fine.

  1. Should it be counted when poor connection simulation is turned on or real-life cases only?
  2. Should it be counted within one session only or persist between several sessions within an hour (I mean if user close/re-open the app)?

VickyStash avatar Dec 06 '24 16:12 VickyStash

It would be nice to log it whether or not the setting is turned on. In fact, let's add the state of the setting in the log itself. I think it would also be nice to span sessions if that's not too much extra work. I'm not worried about losing it if they sign out though.

tgolen avatar Dec 06 '24 16:12 tgolen

@tgolen I've added the log in this commit : https://github.com/Expensify/App/pull/53698/commits/5e52653975b8eeb83dfa441ea46498858c6f7f7f, let me know what you think. It is triggered by the connection change on its own and reports the connection changes within the 1+ hour.

VickyStash avatar Dec 09 '24 08:12 VickyStash

It changes connection from online to offline randomly every 2-5 seconds using NetworkActions.setShouldForceOffline method (NetworkActions.setNetWorkStatus didn't have the expected effect on the app).

@tgolen @VickyStash, if we use NetworkActions.setShouldForceOffline, basically it works but it auto switch ForceOffline like this recording

https://github.com/user-attachments/assets/b3fa9e0a-3b0e-45e8-970f-f6367f2e7800

Does it look good to you? Otherwise, I think if we can use function NetworkConnection.setOfflineStatus here, it might work

hoangzinh avatar Dec 09 '24 11:12 hoangzinh

I don't feel too strongly about that. If I were thinking about this with a fresh perspective I guess it wouldn't be three on/off settings, but one setting with several options:

  • Always offline
  • Poor connection
  • Failing requests

tgolen avatar Dec 09 '24 16:12 tgolen

I don't feel too strongly about that. If I were thinking about this with a fresh perspective I guess it wouldn't be three on/off settings, but one setting with several options:

  • Always offline
  • Poor connection
  • Failing requests

@tgolen But you can't use all options at once, right? You can use only one out of three options per time?

VickyStash avatar Dec 09 '24 22:12 VickyStash

@VickyStash I think so. Therefore it makes sense to disable other options if one option is enabled.

hoangzinh avatar Dec 10 '24 09:12 hoangzinh

@VickyStash what do you think if we move logic of simulating a poor connection into src/libs/NetworkConnection.ts, same as Force offline here, then using NetworkConnection.setOfflineStatus. I think it would help to avoid auto on-off Force offline when simulating a poor connection (also avoid Force offline logs as well)

hoangzinh avatar Dec 10 '24 09:12 hoangzinh

@hoangzinh Okay, I'll update the PR within the next couple of hours 👌

VickyStash avatar Dec 10 '24 09:12 VickyStash

Updates:

  • Moved logic of simulating a poor connection into src/libs/NetworkConnection.ts so the code is aligned with force offline functionality
  • Use NetworkConnection.setOfflineStatus instead of forceOffline
  • Made it possible to turn on only one network test toggle per time:

https://github.com/user-attachments/assets/63d07b17-cbd7-4cbe-84f6-ccb13884c5de

TODOs: I haven't had enough time to re-test it fully, so plan to do it tomorrow.

Questions: We can try to update the UI to something like: image But it will require some side updates. @tgolen wdyt?

VickyStash avatar Dec 10 '24 16:12 VickyStash

I think the UI you have already (where the other toggles get disabled) will work perfectly fine for now. Let's stick with that.

tgolen avatar Dec 10 '24 20:12 tgolen

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

melvin-bot[bot] avatar Dec 12 '24 23:12 melvin-bot[bot]

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

melvin-bot[bot] avatar Dec 23 '24 21:12 melvin-bot[bot]

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

  • https://github.com/Expensify/App/pull/53698

If no regressions arise, payment will be issued on 2024-12-30. :confetti_ball:

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

  • @hoangzinh requires payment through NewDot Manual Requests

melvin-bot[bot] avatar Dec 23 '24 21:12 melvin-bot[bot]

Issue is ready for payment but no BZ is assigned. @sonialiap you are the lucky winner! Please verify the payment summary looks correct and complete the checklist. Thanks!

melvin-bot[bot] avatar Dec 30 '24 09:12 melvin-bot[bot]

Payment Summary

Upwork Job

  • Reviewer: @hoangzinh owed $250 via NewDot

BugZero Checklist (@sonialiap)

  • [x] I have verified the correct assignees and roles are listed above and updated the neccesary manual offers
  • [x] I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1864308224556700727/hired)
  • [ ] I have paid out the Upwork contracts or cancelled the ones that are incorrect
  • [x] I have verified the payment summary above is correct

melvin-bot[bot] avatar Dec 30 '24 09:12 melvin-bot[bot]

Requested payment in ND

hoangzinh avatar Dec 30 '24 09:12 hoangzinh