[$250] [Performance] Implement a debug setting that simulates a poor connection by going online/offline a bunch
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:
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 Owner
Current Issue Owner: @hoangzinh
Auto-assigning issues to engineers is no longer supported. If you think this issue should receive engineering attention, please raise it in #whatsnext.
Huh... This is 4 days overdue. Who can take care of this?
6 days overdue. This is scarier than being forced to listen to Vogon poetry!
8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!
12 days overdue. Walking. Toward. The. Light...
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!
@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.
Job added to Upwork: https://www.upwork.com/jobs/~021864308224556700727
Triggered auto assignment to Contributor-plus team member for initial proposal review - @hoangzinh (External)
Sure!
Hi, I'm Viktoryia from Callstack - expert contributor group - and I would like to work on this issue.
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?
@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.
I think you can just log that information with Log.info() and it should be fine.
- Should it be counted when poor connection simulation is turned on or real-life cases only?
- 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)?
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 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.
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
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
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 I think so. Therefore it makes sense to disable other options if one option is enabled.
@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 Okay, I'll update the PR within the next couple of hours 👌
Updates:
- Moved logic of simulating a poor connection into
src/libs/NetworkConnection.tsso 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:
But it will require some side updates.
@tgolen wdyt?
I think the UI you have already (where the other toggles get disabled) will work perfectly fine for now. Let's stick with that.
Triggered auto assignment to @flodnv, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
Reviewing label has been removed, please complete the "BugZero Checklist".
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
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!
Payment Summary
- 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
Requested payment in ND