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.42k stars 2.8k forks source link

Background network processing #50140

Open gedu opened 12 hours ago

gedu commented 12 hours ago

Problem

When a user opens the chat app after a period of inactivity/activity/actions, the NetworkQueue is filled with a large queue of unsent requests. This queue causes significant processing delays, which result in app hangs and infinite loading of messages, preventing users from having a seamless messaging experience.

Solution

To address this problem, consider implementing background task processing that allows the app to handle network requests even when not actively open. For mobile (Android/iOS), you could utilize:

For Android: Use WorkManager to manage background tasks reliably. For iOS: Implement Background Fetch to periodically process network requests. For both: Consider using React Native Background Fetch or https://reactnative.dev/docs/headless-js-android

Additional Solutions for Web and Desktop

Web: Leverage Service Workers for handling background sync when internet connection is re-established. Desktop: Use Electron’s background task handling capabilities (e.g., electron-ipc).

Cases:

  1. User is offline or in a poor network connection

  2. User takes some actions and serializes network requests

  3. User puts app in the background

  4. User regains network connection, requests from the queue start executing.

  5. User opens the app and has no remaining network requests (or maybe a few)

  6. Open the app from a notification

  7. Read it

  8. Write a response

  9. Switch apps

This background processing will prevent a message from not being sent due to moving quickly to the background.

Slack Thread: https://expensify.slack.com/archives/C05LX9D6E07/p1727884875529299

szymonrybczak commented 12 hours ago

Hey, I'm Szymon from Callstack and I can work on this 🫡